code
stringlengths
3
6.57k
__init__(self)
principles (density functional theory)
pu_stats (dict)
df_U (DataFrame)
df_P (DataFrame)
synth_scores (list)
scores (between 0 and 1)
labels (list)
synthesizable (1)
not (0)
feat_importances (DataFrame)
cv_baggingDT(self, pu_data, splits=10, repeats=10, bags=100, filename="")
pu_data (json)
synthesized (positive)
splits (int)
repeats (int)
bags (int)
filename (string)
pu_stats (dict)
print("Start PU Learning.")
pd.read_json(pu_data)
self._process_pu_data(df)
RepeatedKFold(n_splits=splits, n_repeats=repeats, random_state=42)
learning (tpr = True Positive Rate)
np.ones(shape=(X_P.shape[0], splits * repeats)
np.ones(shape=(X_U.shape[0], splits * repeats)
np.zeros(shape=(X_P.shape[1], splits * repeats)
for (ptrain, ptest)
zip(kfold.split(X_P)
kfold.split(X_U)
np.zeros(shape=(N_ptrain + K,)
Synthesized (positive)
np.zeros(shape=(N_utrain,)
np.zeros(shape=(N_utrain, 2)
np.zeros(shape=(X_P[ptest].shape[0], 2)
np.zeros(shape=(X_U[utest].shape[0], 2)
range(bags)
np.arange(N_utrain)
model.fit(data_bootstrap, train_label)
set(range(N_utrain)
set(np.unique(bootstrap_sample)
model.predict_proba(X_U[utrain][idx_oob])
model.predict_proba(X_P[ptest])
model.predict_proba(X_U[utest])
np.where(predict_ptest > 0.5)
np.where(predict_utest > 0.5)
recall (TPR)
scores.append(score)
tprs.append(recall)
if (idsp + 1)
np.asarray(tprs[-splits - 1 : -1])
str(splits)
str(idsp // splits + 1)
str(repeats)
f (+/- %0.2f)
tpr_tmp.mean()
tpr_tmp.std()
np.zeros(shape=(X_U.shape[0], splits * repeats + 1)
np.where(prob_U > 0.5)
np.asarray(tprs)
np.asarray(scores)
np.zeros(shape=(X_U.shape[0], repeats)
np.zeros(shape=(X_U.shape[0], repeats)
np.zeros(shape=(X_U.shape[1], repeats)
np.zeros(shape=(repeats,)
np.zeros(shape=(repeats,)
np.zeros(shape=(X_U.shape[0],)
range(repeats)
mean(axis=1)
mean()
mean()
np.where(prob_U_rp > 0.5)
prob_U_rp.mean(axis=1)
np.where(prob > 0.5)
self.bootstrapCI(tpr_rp)
self.bootstrapCI(scores_rp)
tpr_rp.mean()
scores_rp.mean()
print("Accuracy: %0.2f" % (tpr_rp.mean()
print("95%% confidence interval: [%0.2f, %0.2f]" % (tpr_low, tpr_up)
filename.endswith(".json")
dumpfn(pu_stats, filename)
filename.endswith(".pkl")
open(filename, "wb")
pickle.dump(pu_stats, file, protocol=pickle.HIGHEST_PROTOCOL)
bootstrapCI(self, data, ci=95, ns=10000)
data (array)
ci (int)
ns (int)
lower (float)
upper (float)
range(ns)
resample(data, n_samples=len(data)
bs_rsample.append(np.mean(rsample)
np.asarray(bs_rsample)
np.percentile(bs_rsample, (100 - ci)
np.percentile(bs_rsample, ci + (100 - ci)
corr_heatmap(self, num_feats=10, fname="")
num_feats (int)
fname (str)