<jupyter_start><jupyter_text>AutoPrognosis API TutorialA demonstration for AP functionality and operation This tutorial shows how to use [Autoprognosis](https://arxiv.org/abs/1802.07207). We are using the UCI Spam dataset.See [installation instructions](../../doc/install.md) to install the dependencies.Load dataset and show the first five samples:<jupyter_code>import pandas as pd
import initpath_ap
initpath_ap.init_sys_path()
import utilmlab

df = pd.read_csv('{}/spambase.csv.gz'.format(utilmlab.get_data_dir()))  # get UCI spam dataset
target = 'label'
features = list(df.columns)
features.remove(target)

X_ = df[features]
Y_ = df[target]

df.head()<jupyter_output><empty_output><jupyter_text>Import the AutoPrognosis library<jupyter_code>import model<jupyter_output><empty_output><jupyter_text>Run the model with few iterations<jupyter_code>metric = 'aucprc'
acquisition_type = 'MPI' # default and prefered is LCB but this generates excessive warnings, MPI is a good compromise.
AP_mdl   = model.AutoPrognosis_Classifier(
    metric=metric, CV=5, num_iter=3, kernel_freq=100, ensemble=True,
    ensemble_size=3, Gibbs_iter=100, burn_in=50, num_components=3, 
    acquisition_type=acquisition_type)

AP_mdl.fit(X_, Y_)<jupyter_output><empty_output><jupyter_text>Computing model predictions  ~~~First element in the output is the predictions of a single model, the second element is the prediction of the ensemble~~~<jupyter_code>AP_mdl.predict(X_)<jupyter_output><empty_output><jupyter_text>Compute performance via multi-fold cross-validation<jupyter_code>model.evaluate_ens(X_, Y_, AP_mdl, n_folds=5, visualize=True)<jupyter_output><empty_output><jupyter_text>Visualize data...<jupyter_code>AP_mdl.visualize_data(X_)<jupyter_output><empty_output><jupyter_text>Visualize the model...<jupyter_code>AP_mdl.APReport()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10480821177741761, 'fraction_numerical': 0.011885467314964884, 'mean_word_length': 7.903846153846154, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '464143', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 660, 'n_tokens_neox': 635, 'n_words': 135, 'path': 'alg/autoprognosis/tutorial_autoprognosis_api.ipynb', 'repo_name': 'migelekarapet/mlforhealthlabpub', 'size': '1851'}