Skip to content

Instantly share code, notes, and snippets.

@takashioya
takashioya / noglobal.py
Created December 6, 2020 08:47 — forked from raven38/noglobal.py
Useful Noglobal in Python
# 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
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))))
@takashioya
takashioya / calc_auc.py
Created August 22, 2018 15:04
aucの計算
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]