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
ctx := context.Background() | |
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) | |
if err != nil { | |
return err | |
} | |
resp, err := cli.ContainerCreate(ctx, &container.Config{ | |
Image: image, | |
Env: env, | |
Tty: true, |
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
sepal_length | sepal_width | petal_length | petal_width | species | |
---|---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa | |
4.9 | 3.0 | 1.4 | 0.2 | setosa | |
4.7 | 3.2 | 1.3 | 0.2 | setosa | |
4.6 | 3.1 | 1.5 | 0.2 | setosa | |
5.0 | 3.6 | 1.4 | 0.2 | setosa | |
5.4 | 3.9 | 1.7 | 0.4 | setosa | |
4.6 | 3.4 | 1.4 | 0.3 | setosa | |
5.0 | 3.4 | 1.5 | 0.2 | setosa | |
4.4 | 2.9 | 1.4 | 0.2 | setosa |
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
# results on training set | |
y_pred = xgb_test.predict(dtrain, ntree_limit=xgb_test.best_iteration+1) | |
y_true = train_df['class'].values | |
print(roc_auc(y_pred, dtrain)) | |
# results on test set | |
y_pred = xgb_test.predict(dtest, ntree_limit=xgb_test.best_iteration+1) | |
y_true = test_df['class'].values | |
print(roc_auc(y_pred, dtest)) |
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
dsyn = xgb.DMatrix(syn[X_col], syn[y_col], feature_names=X_col) | |
y_pred = xgb_test.predict(dsyn, ntree_limit=xgb_test.best_iteration+1) | |
y_true = syn['class'].values | |
print(recall(y_pred, dsyn)) | |
print(precision(y_pred, dsyn)) |
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
t1 = gmm.sample(len(real_data)) | |
data_new = t1[0] | |
points_new = pca.inverse_transform(data_new) | |
syn = pd.DataFrame(points_new, columns=list(real_data)) |
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
gmm = GaussianMixture(20, covariance_type='full', random_state=0) | |
gmm.fit(data) | |
t1 = gmm.sample(len(data_real)) | |
data_new = t1[0] | |
points_new = pca.inverse_transform(data_new) | |
df_fake = pd.DataFrame(points_new, columns=list(data_real)[:-2]) |
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
from sklearn.decomposition import PCA | |
pca = PCA(0.99, whiten=True) | |
data = pca.fit_transform(df_real) |
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
n_components = np.arange(5, 30, 5) | |
models = [GaussianMixture(n, covariance_type='full', random_state=0) | |
for n in n_components] | |
aics = [model.fit(data).aic(data) for model in models] | |
plt.plot(n_components, aics) | |
plt.show() |
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
results_dict = {} | |
xgb_params = { | |
'objective': 'binary:logistic', | |
'random_state': 0, | |
'eval_metric': 'auc', # auc, error | |
} | |
xgb_test = xgb.train(xgb_params, dtrain, num_boost_round=100, | |
verbose_eval=False, |
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
np.random.seed(0) | |
n_real = np.sum(data.Class==0) | |
n_test = np.sum(data.Class==1) | |
train_fraction = 0.7 | |
fn_real = int(n_real * train_fraction) | |
fn_test = int(n_test * train_fraction) | |
real_samples = data.loc[ data.Class==0, test_cols].sample(n_real, replace=False).reset_index(drop=True) | |
test_samples = data.loc[ data.Class==1, test_cols].sample(n_test, replace=False).reset_index(drop=True) |