skip to Main Content
[font_awesome icon="phone"] 1-800-987-654[font_awesome icon="envelope"] admin@totalwptheme.com[font_awesome icon="user"][wp_login_url text="User Login" logout_text="Logout"]

feature splitter

a code in python to split features using all possible combinations without repetition

import re
from itertools import combinations_with_replacement

feature_list = ['most_similar_match', 'most_similar_match_ner', 'polyfuzz_match', 'polyfuzz_score','n_e_r_points',
'total_points']
#feature_list = ['most_similar_match', 'most_similar_match_ner', 'polyfuzz_match']
features_to_train = []
features_to_add = []
all_features_list = []
final_features_list = []


for f in range(len(feature_list)):
features_combinantions = list(combinations_with_replacement(feature_list, r=f + 1))
dim1 = len(features_combinantions)
dim2 = len(features_combinantions[0])
print('--------------------------------------')
print(dim1, dim2, features_combinantions)
print('--------------------------------------')

for i in range(dim1):
for z in range(dim2):
features = features_combinantions[i]
features = re.sub(r"[\(']|[']|['\)]", '', str(features))
for f in features.split(','):
if (len(f) > 0):
features_to_add.append(f.strip())
all_features_list.append([features_to_add])
if (features_to_add not in all_features_list):
features_to_train.append(f.strip())

features_to_train_set = {*features_to_train}
features_to_train = [*features_to_train_set]

all_features_set = {*features_to_train}
print('1: ', features_to_train, len(features_to_train), len(all_features_list))
if (features_to_train not in final_features_list):
final_features_list.append(features_to_train)
features_to_train = []
features_to_add = []

print('********************************')
print(final_features_list)
print('********************************')
This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top