Predictive Model
Predictive Model learns from your own historical data, organised as a table (one row per record and one column per value), and saves what it learned as a named model. Later, in the same flow or in another one, you use that model to make predictions on new rows or to measure how accurate it is.
It covers four kinds of problem: predicting a category (for example, whether a customer will leave), predicting a number (for example, the price of a home), spotting rows that do not look like the rest (for example, suspicious transactions) and grouping similar rows (for example, customer segments). It does not need an AI model or credentials: everything happens inside NappAI.
When to use it
- Predict which customers are most likely to leave, based on their purchase and contact history.
- Estimate the price or amount of a deal from its characteristics.
- Flag payments or orders that are out of the ordinary so they can be reviewed.
- Split your customer base into groups with similar habits for different campaigns.
- Check from time to time whether a trained model is still accurate on recent data.
How it works
The Operation field decides what the component does on each run:
- Train: learns from your historical data and saves the model under the name in Model Name. You do this once, or whenever you want to retrain.
- Predict: applies a saved model to new rows and returns the prediction for each one.
- Evaluate: compares a saved model’s predictions with real results you already know and returns accuracy measures.
Trained models are saved in your storage, in the Predictive models section. From there you can download them, delete them or upload them to another environment (see Upload a trained model).
Configuration
The fields change with the chosen operation.
| Field | What it does |
|---|---|
| Operation (required) | Train, Predict or Evaluate. Default: Train. |
| Data (required) | The rows the component works with; connect a list of data here, for example from a database query, an API call or a CSV. In Train, this is the historical data and it must include the input columns and, when needed, the column to predict. In Predict, these are the new rows, with the same input columns as in training. In Evaluate, these are rows with known real results. |
| Model Type (required in Train) | The kind of problem: Classification (predict a category from a list), Regression (predict a number), Anomaly Detection (flag rows that differ from the rest) or Clustering (group similar rows). Default: Classification. |
| Algorithm (required in Train) | The learning method. The options depend on the kind of problem. If you are not sure which one to choose, keep the default: Random Forest for Classification and Regression, Isolation Forest for Anomaly Detection and K-Means for Clustering. |
| Model Name (required) | In Train, the name the model is saved under; a name with the date and time is suggested, and you can change it to something recognisable such as customer_churn_v1. It cannot match a model you already have. In Predict and Evaluate, it is a dropdown with your trained models; use the refresh button if you have just trained one. |
| Number of Features | Train only. How many input columns the model uses, from 1 to 50. Default: 3. For each one a Feature 1, Feature 2… field appears, where you type or drag the exact column name. Columns can be numbers or text. Do not include the column you want to predict here. |
| Target Column (required for Classification and Regression) | The column you want to predict, for example price or will_churn. It appears in Train and Evaluate. |
Advanced options
| Field | What it does |
|---|---|
| Test Size | Train only, with Classification and Regression. The share of the data set aside to measure accuracy instead of being used for learning. Default: 0.2 (20%). With 0, everything is used for learning and nothing is set aside for measuring. |
| Number of Clusters | Train only, with Clustering. How many groups K-Means or Agglomerative should look for. Default: 3. DBSCAN decides the number of groups by itself and ignores this value. |
Output
The Result output returns data you can connect to any component that works with data, for example to save it to a database, send it by email or pass it to an agent.
- Train: a summary of the training with the model name, the columns used, the number of rows and the accuracy measures. For Classification it includes the share of correct answers (
accuracy) and other quality measures (precision,recall,f1); for Regression, the average error (mae,rmse) and how much the model explains (r2); for Anomaly Detection, how many training rows look unusual; for Clustering, how many groups it found. - Predict: one row for each input row, with its original columns plus the result:
prediction(with the probability of each category in Classification),is_anomaly(true or false) in Anomaly Detection, orcluster_id(the group number) in Clustering. - Evaluate: the same accuracy measures as in training, calculated on the data you connected.
Example
A gym chain, Gimnasios Brisa, wants to know which members might cancel:
- In one flow, a query to its database returns the member history with the columns
monthly_visits,months_member,planandcancelled. - Connect that data to Data, choose Train and Classification, set Number of Features to 3 and type
monthly_visits,months_memberandplanin the Feature fields. In Target Column typecancelledand name the modelmember_churn_v1. - In another flow scheduled every Monday, the query returns the current members. With Predict and the
member_churn_v1model, each member comes out with a prediction and its probability, and the flow sends the sales team the list of those most at risk.
Good practices
- Start with a few columns you believe really matter. More columns do not always improve the result.
- Use the same column names in Train, Predict and Evaluate: they must match exactly, including upper and lower case.
- Evaluate with recent data now and then to find out whether the model has stopped being accurate.
- To retrain, use a new name (for example
v2) or delete the previous model from storage first: if the name already exists, training stops with an error so it is not overwritten.
Related components
- Text Classifier: to classify free text instead of tables.
- Recommender: to recommend products or content based on a history.
- CSV to Data List: to turn a CSV into the list of rows that Data needs.