Tutorial: Create a time series anomaly prediction experiment
Use sample data to train a time series experiment in AutoAI to detect if daily electricity usage values are normal or anomalies (outlier).
When you set up the sample experiment, you load data that analyzes daily electricity usage from Industry A to determine whether a value is normal or an anomaly. Then, the experiment generates pipelines that use algorithms to label these predicted values as normal or an anomaly. After generating the pipelines, AutoAI chooses the best performers, and presents them in a leaderboard for you to review.
Before you begin
Make sure you have the following services available:
- Watson Studio
- Watson Machine Learning
Data set overview
For this tutorial, use the Electricity usage anomalies sample data set from the Gallery. This data set comes from another pipeline that describes annual electricity usages for Industry A. The first column indicates the electricity usages and the second column indicates the date, which is in a day-by-day format. Use this data set to configure your AutoAI experiment.
Tasks overview
In this tutorial, follow these steps to create an anomaly prediction experiment that uses:
Create an AutoAI experiment
Create an AutoAI experiment and add sample data to your experiment.
- From the Cloud Pak for Data navigation menu , click Projects > View all projects.
- Open an existing project or create a new project to store the anomaly prediction experiment.
- Click New Asset and select AutoAI.
- Click Gallery sample > Electricity usage anomalies sample data, then select Next. The AutoAI experiment name and description are pre-populated by the sample data.
- If prompted, associate a Watson Machine Learning instance with your AutoAI experiment.
- Click Associate a Machine Learning service instance and select an instance of Watson Machine Learning.
- Click Reload to confirm your configuration.
- Click Create.
View the experiment details
AutoAI pre-populates the details fields for the sample experiment:
- Type series analysis type: Anomaly prediction predicts whether future values in a series are anomalies (outliers). A prediction of 1 indicates a normal value and a prediction of -1 indicates an anomaly.
- Feature column: industry_a_usage is the predicted value and indicates how much electricity Industry A consumes.
- Date/Time column: date indicates the time increments for the experiment. For this experiment, there is one prediction value per day.
- This experiment is optimized for the model performance metric: Average Precision. Average precision evaluates the performance of object detection and segmentation systems.
Click Run experiment to train the model. The experiment takes several minutes to complete.
Review the experiment results
The relationship map shows the transformations that are used to create pipelines. Follow these steps to review experiment results and save the pipeline with the best performance.
- The three best performing pipelines are listed and saved to the leaderboard. Click the pipeline name with Rank 1 to review the details of the pipeline. For details on anomaly prediction metrics, see Creating a time series anomaly prediction experiment.
- Select the pipeline with Rank 1 and Save the pipeline as a model. The model name is pre-populated with the default name. Click Create.
Deploy the trained model
Before the trained model can make predictions on external values, you must deploy the model. Follow these steps to promote your trained model to a deployment space.
-
Deploy the model from the model details page. To access the model details page, choose one of these options:
- From the notification displayed when you save the model, click View in project.
- From the project's Assets, select the model’s name in Models.
-
From the Model details page, click Promote to Deployment Space. Then, select or create a deployment space where the model will be deployed.
-
Select to Go to the model in the space after promoting it.
-
Click Promote.
Testing the model
After promoting the model to the deployment space, you are ready to test your trained model with new data values.
-
Select New Deployment.
-
Create a new deployment with the following fields:
- Deployment type:
Online
- Name:
Electricity usage online deployment
- Deployment type:
-
Click Create and wait for the status to update to Deployed
-
After the deployment initializes, click the deployment. Use Test input to manually enter and evaluate values. Or, use JSON input to attach a data set.
-
Click Predict to see whether there are any anomalies in the values.
Note: -1 indicates an anomaly; 1 indicates a normal value.
Next steps
Parent topic: Building a time series forecast experiment