def iris_data(): iris = datasets.load_iris() X = pd.DataFrame(iris.data[:, :2], columns=iris.feature_names[:2]) y = pd.Series(iris.target, name="label", dtype=np.float32) return TabularDataLoaders.from_df(df=pd.concat([X, y], axis=1), cont_names=list(X.columns), y_names="label")
def fastai_model(): iris = datasets.load_iris() X = pd.DataFrame(iris.data[:, :2], columns=iris.feature_names[:2]) y = pd.Series(iris.target, name="label") dl = TabularDataLoaders.from_df(df=pd.concat([X, y], axis=1), cont_names=list(X.columns), y_names="label") model = tabular_learner(dl, metrics=accuracy, layers=[3]) model.fit(1) return ModelWithData(model=model, inference_dataframe=X)
def data_loader(): path = untar_data(URLs.ADULT_SAMPLE) dls = TabularDataLoaders.from_csv( path / "adult.csv", path=path, y_names="salary", cat_names=[ "workclass", "education", "marital-status", "occupation", "relationship", "race", ], cont_names=["age", "fnlwgt", "education-num"], procs=[Categorify, FillMissing, Normalize], ) return dls
def get_data_loaders(): X, y = load_iris(return_X_y=True, as_frame=True) y = y.astype(np.float32) return TabularDataLoaders.from_df(X.assign(target=y), cont_names=list(X.columns), y_names=y.name)