This file contains hidden or 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
| # subplots | |
| plt.figure(figsize=(20,10)) | |
| for i,col in enumerate(wine_df.columns[:-1]): | |
| plt.subplot(2,6,i+1) | |
| sns.boxplot(x=wine_df['quality'], y=wine_df[col]) | |
| plt.tight_layout() | |
| # boxplots for each column | |
| plt.figure(figsize = (20,10)) |
This file contains hidden or 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
| df['variable_bins'] = pd.qcut(df['variable'], 5) | |
| def calculate_woe_iv(dataset, feature, target): | |
| lst = [] | |
| for i in range(dataset[feature].nunique()): | |
| val = list(dataset[feature].unique())[i] | |
| lst.append({ | |
| 'Value': val, | |
| 'All': dataset[dataset[feature] == val].count()[feature], | |
| 'Good': dataset[(dataset[feature] == val) & (dataset[target] == 0)].count()[feature], |
This file contains hidden or 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
| import pandas as pd | |
| import numpy as np | |
| import pandas.core.algorithms as algos | |
| from pandas import Series | |
| import scipy.stats.stats as stats | |
| import re | |
| import traceback | |
| import string | |
| max_bin = 20 |
This file contains hidden or 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_decision_regions(X, y, clf, | |
| feature_index=None, | |
| filler_feature_values=None, | |
| filler_feature_ranges=None, | |
| ax=None, | |
| X_highlight=None, | |
| res=0.02, legend=1, | |
| hide_spines=True, | |
| markers='s^oxv<>', | |
| colors='red,blue,limegreen,gray,cyan'): |
This file contains hidden or 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
| # display branches | |
| git branch | |
| # checkout to master | |
| git checkout master | |
| # create and checkout to a new branch | |
| git checkout -b new_branch | |
| # share the branch and track it | |
| git push -u origin new_branch |
This file contains hidden or 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.metrics import roc_curve, roc_auc_score, auc | |
| from scipy import stats | |
| import matplotlib.pyplot as plt | |
| # %matplotlib inline | |
| def plot_roc_curve(y, y_pred, gini, ks): | |
| fpr, tpr, thresholds = roc_curve(y, y_pred) | |
| roc_auc = auc(fpr, tpr) | |
| fig = plt.figure() |
This file contains hidden or 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 IPython.display import Audio, display | |
| def all_done(): | |
| display(Audio(url='https://sound.peal.io/ps/audios/000/000/537/original/woo_vu_luvub_dub_dub.wav', autoplay=True)) |