Created
September 9, 2017 06:35
-
-
Save supachaic/06886d9ec8d103303984a7509ca8f204 to your computer and use it in GitHub Desktop.
Search Combination and Vote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def all_subs(idx_list): | |
if idx_list == []: | |
return [[]] | |
indices = all_subs(idx_list[1:]) | |
return indices + [[idx_list[0]] + i for i in indices] | |
def search_combination(predict_list, y_val, score_name): | |
idx_list = list(range(len(predict_list))) | |
combi_idx = all_subs(idx_list) | |
combi_idx.pop(0) | |
best_combi = None | |
score = 0.0 | |
for combi in combi_idx: | |
pred_list = [predict_list[i] for i in combi] | |
y_pred = np.mean(pred_list, axis=0) | |
y_pred = np.argmax(y_pred, axis=1) | |
pred_score = matric_score(y_val, y_pred, score_name) | |
if pred_score >= score: | |
score = pred_score | |
best_combi = combi | |
return best_combi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment