# Gluon Predict

This notebook is used for prediction using a prediction model built by *gluon_train* notebook.

### Sample Output

If the same column name to label that is used in training (e.g., y) exists in *input_table* , prediction result is resulted in *predicted_y* with *predicted* prefix_. If the label column does not exist in *input_table* , prediction is resulted in *y* column.

The columns *predicted_proba* and *predicted_probabilities* are results for binary or multiclass classifications. For binary classification, *predict_proba* is probability of positive class. You can get the probability of a negative class by 1.0 - *predict_proba*. For multiclass classification, *predict_proba* is probability of predicted class.

| y | predicted_y | predicted_proba | predicted_probabilities |
|  --- | --- | --- | --- |
| yes | no | 0.29304519295692444 | {"no": 0.706954836845398, "yes": 0.29304519295692444} |
| no | no | 0.00487339636310935 | {"no": 0.9951266050338745, "yes": 0.00487339636310935} |
| ... | ... | ... | ... |
| yes | yes | 0.5266873240470886 | {"no": 0.4733126759529114, "yes": 0.5266873240470886} |


If *rowid_column* is provided, it only appends prediction results to the *rowid* column and the resulting size of table will be small. It is assumed that *user_id* or *product_id* is unique for the *rowid_column*.

### Workflow Example

For a sample workflow, see [Treasure Boxes](https://github.com/treasure-data/treasure-boxes/blob/automl/machine-learning-box/automl/ml_experiment.dig).


```yaml
+gluon_predict:
  ml_predict>:
    notebook: gluon_predict
    model_name: gluon_model
    input_table: ml_datasets.bank_marketing_test
    output_table: ml_test.predicted
```

### Parameters

| Parameter name | Parameter on Console | Description | Default Value |
|  --- | --- | --- | --- |
| docker.task_mem | Docker Task Mem | Task memory size. Available values are 64g, 128g (default), 256g, 384g, or 512g depending on your contracted tiers | 128g |
| model_name | Model Name | Prediction model name | - |
| input_table | Input Table | TD table name used for test data | - |
| output_table | Output Table | TD table name to export the prediction result | - |
| output_mode | Output Mode | Output mode for exporting *output_table:* overwrite or replace or append. Usually, there is no need to specify and append for semi-realtime prediction with *rowid_filter* | overwrite |
| ignore_columns | Ignore Columns | Columns to ignore when building a prediction model | time |
| rowid_column | Rowid Column | The *rowid* (primary key) column. Note that when *rowid_column* is specified, only rowid column and prediction result columns are displayed in the output table. | None |
| rowid_filter | Rowid Filter | Filtering rows for prediction by *rowid* column values | None |
| export_leaderboard | Export Leaderboard | Export leaderboard as a TD table, if specified | None |
| export_feature_importance | Export Feature Importance | Export feature importance as a TD table, if specified | None |
| hide_table_contents | Hide Table Contents | Suppress showing table contents | false |
| shared_model | Shared Model | Specify a shared model UUID | None |
| audience_name | Audience Name | Audience parent (master) segment name to merge an attribute table | None |
| foreign_key | Foreign Key | Foreign key in an Audience parent (master) table to merge an attribute table | None |