Skip to content

Instantly share code, notes, and snippets.

# 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))
@blawok
blawok / woe
Created July 8, 2020 05:52
WoE computation
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],
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
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'):
# 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
@blawok
blawok / gini
Created May 9, 2020 12:28
Gini and roc curve
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()
@blawok
blawok / dub_dub
Created April 30, 2020 12:18
Sound notification for jupyter
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))