5.5 KiB
5.5 KiB
In [3]:
## prepare env, read and prepare data
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
codepath = '../2_code' ## for import of user defined module
datapath = '../3_data'
from sys import path; path.insert(1, codepath)
from os import chdir; chdir(datapath)
from bfh_cas_pml import prep_data
X_train, X_test, y_train, y_test = prep_data('bank_data_prep.csv', target='y', seed=1234)In [4]:
## train a model
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(random_state=1234)
model.fit(X_train, y_train)
## prediction using .predict_proba()
y_pred_p_no = model.predict_proba(X_test)[:, 0]In [5]:
## inspect different threshold values
from sklearn.metrics import accuracy_score
thresholds = np.arange(0, 1.01, 0.1) ## test over 10
#thresholds = np.arange(0, 1.01, 0.01)
scores = []
for threshold in thresholds:
## tbd
print(threshold)
0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 0.8 0.9 1.0
In [6]:
## results
## tbd
In [7]:
## viszalization
## tbd