Skip to content

Instantly share code, notes, and snippets.

@kvnkho
Created January 6, 2022 18:48
Show Gist options
  • Save kvnkho/61c65406061a3e70194affcee6657ada to your computer and use it in GitHub Desktop.
Save kvnkho/61c65406061a3e70194affcee6657ada to your computer and use it in GitHub Desktop.
from fugue import transform
import pandas as pd
schema = """Model:str, Accuracy:float, AUC:float, Recall:float, Prec:float,
F1:float, Kappa:float, MCC:float, TT_Sec:float"""
def wrapper(df: pd.DataFrame) -> pd.DataFrame:
clf = setup(data = df,
target = 'Survived',
session_id=123,
silent = True,
verbose=False,
html=False)
models = compare_models(fold = 10,
round = 4,
sort = "Accuracy",
turbo = True,
n_select=5,
verbose=False)
results = pull().reset_index(drop=True)
# Fugue can't have spaces or . in column names
results = results.rename(columns={"TT (Sec)": "TT_Sec",
"Prec.": "Prec"})
return results.iloc[0:5]
res = transform(df, wrapper, schema=schema)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment