You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"\n# Tabular Classification with user passed feature types\n\nThe following example shows how to pass feature typesfor datasets which are in \nnumpy format (also works for dataframes and lists) fit a sample classification \nmodel with AutoPyTorch.\n\nAutoPyTorch relies on column dtypes for intepreting the feature types. But they \ncan be misinterpreted for example, when dataset is passed as a numpy array, all \nthe data is interpreted as numerical if it's dtype is int or float. However, the \ncategorical values could have been encoded as integers.\n\nPassing feature types helps AutoPyTorch interpreting them correctly as well as\nvalidates the dataset by checking the dtype of the columns for any incompatibilities.\n"
"task = openml.tasks.get_task(task_id=146821)\ndataset = task.get_dataset()\nX, y, categorical_indicator, _ = dataset.get_data(\n dataset_format='array',\n target=dataset.default_target_attribute,\n)\nX_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(\n X,\n y,\n random_state=1,\n)\n\nfeat_types = [\"numerical\" if not indicator else \"categorical\" for indicator in categorical_indicator]\n\n#"
48
+
]
49
+
},
50
+
{
51
+
"cell_type": "markdown",
52
+
"metadata": {},
53
+
"source": [
54
+
"## Build and fit a classifier\n\n"
55
+
]
56
+
},
57
+
{
58
+
"cell_type": "code",
59
+
"execution_count": null,
60
+
"metadata": {
61
+
"collapsed": false
62
+
},
63
+
"outputs": [],
64
+
"source": [
65
+
"api = TabularClassificationTask(\n # To maintain logs of the run, you can uncomment the\n # Following lines\n # temporary_directory='./tmp/autoPyTorch_example_tmp_01',\n # output_directory='./tmp/autoPyTorch_example_out_01',\n # delete_tmp_folder_after_terminate=False,\n # delete_output_folder_after_terminate=False,\n seed=42,\n)"
66
+
]
67
+
},
68
+
{
69
+
"cell_type": "markdown",
70
+
"metadata": {},
71
+
"source": [
72
+
"## Search for an ensemble of machine learning algorithms\n\n"
"y_pred = api.predict(X_test)\nscore = api.score(y_pred, y_test)\nprint(score)\n# Print the final ensemble built by AutoPyTorch\nprint(api.show_models())\n\n# Print statistics from search\nprint(api.sprint_statistics())"
0 commit comments