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
def plot_calibration(y_true, y_probability,model_name='LGBM'): | |
# compute calibration | |
prob_df_clf = pd.DataFrame({'y': y_true, 'y_hat': y_probability}) | |
# binning the dataframe, so we can see success rates for bins of probability | |
bins = np.arange(0.05, 1.00, 0.05) | |
prob_df_clf.loc[:,'prob_bin'] = np.digitize(prob_df_clf['y_hat'], bins) | |
prob_df_clf.loc[:,'prob_bin_val'] = prob_df_clf['prob_bin'].replace(dict(zip(range(len(bins)), bins))) | |
# opening figure | |
plt.figure(figsize=(12,7), dpi=150) |
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
# Def plot distribution | |
def plot_distribution(data_select,data,h,limit=()): | |
""" | |
Plot_Distribution to see how 2 classes are seperated on different features | |
data_select = which feature we want to see | |
data = the DataFrame | |
h = column of the two classes | |
limit = non mendatory, tuple to limit the x_axis | |
""" | |
figsize =( 15, 8) |