This file contains hidden or 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
# License: | |
# I hereby state this snippet is below "threshold of originality" where applicable (public domain). | |
# | |
# Otherwise, since initially posted on Stackoverflow, use as: | |
# CC-BY-SA 3.0 skyking, Glenn Maynard, Axel Huebl | |
# http://stackoverflow.com/a/31047259/2719194 | |
# http://stackoverflow.com/a/4858123/2719194 | |
import builtins | |
import types |
This file contains hidden or 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
from itertools import permutations | |
import numpy as np | |
import pandas as pd | |
def get_optimal_solution(random_seed, answers_df): | |
answers = answers_df.values | |
names = answers_df.index.values | |
N = answers.shape[0] | |
# 全パターンの順位を取得 (8!通り) | |
all_orders = np.array(list(permutations(range(N)))) |
This file contains hidden or 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
import numpy as np | |
from itertools import combinations | |
from sklearn.metrics import roc_auc_score | |
def calc_auc_slow(label, pred): | |
#激遅 | |
n = label.shape[0] | |
all_combs = np.array(list(combinations(np.arange(n), 2))) | |
label_pairs = label[all_combs] | |
pred_pairs = pred[all_combs] |