Skip to content

Instantly share code, notes, and snippets.

View khurchla's full-sized avatar
📊
studio|classroom|office

Kathryn Hurchla khurchla

📊
studio|classroom|office
View GitHub Profile
cond_reference = (wine['alcohol']<=11)
wine_reference = wine.loc[cond_reference]
cond_target = (wine['alcohol']>11)
wine_target = wine.loc[cond_target]
# add some missing values to a feature to see how they
ixs = wine.iloc[100:110].index
wine.loc[ixs,'citric acid'] = None
bins = (2, 6.5, 8)
group_names = ['bad', 'good']
wine_reference['quality'] = pd.cut(wine_reference['quality'], bins = bins, labels = group_names)
wine_target['quality'] = pd.cut(wine_target['quality'], bins = bins, labels = group_names)
@khurchla
khurchla / whylogs_profile_views.py
Last active June 7, 2022 02:33
whylogs v1 profile visualizer examples
import whylogs as why
result = why.log(pandas=wine_target)
prof_view = result.view()
result_ref = why.log(pandas=wine_reference)
prof_view_ref = result_ref.view()
from whylogs.viz import NotebookProfileVisualizer
visualization = NotebookProfileVisualizer()
@khurchla
khurchla / numpy_unique.py
Created July 15, 2022 13:46
factorize string objects with python numpy courtesy of Matt
unique = np.unique(df[['Rank 1','Rank 2','Rank 3','Rank 78','Rank 79','Rank 80']])
factors = np.arange(len(unique))
df[['Rank 1','Rank 2','Rank 3','Rank 78','Rank 79','Rank 80']] = df[['Rank 1','Rank 2','Rank 3','Rank 78','Rank 79','Rank 80']].replace(unique, factors)
df