0 / 0
Tutorial: Create a time series anomaly prediction experiment

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.

a preview of the Electricity usage anomalies sample data

Tasks overview

In this tutorial, follow these steps to create an anomaly prediction experiment that uses:

  1. Create an AutoAI experiment
  2. View the experiment
  3. Review experiment results
  4. Deploy the trained model
  5. Test the deployed model

Create an AutoAI experiment

Create an AutoAI experiment and add sample data to your experiment.

  1. From the Cloud Pak for Data navigation menu Navigation menu, click Projects > View all projects.
  2. Open an existing project or create a new project to store the anomaly prediction experiment.
  3. Click New Asset and select AutoAI.
  4. Click Gallery sample > Electricity usage anomalies sample data, then select Next. The AutoAI experiment name and description are pre-populated by the sample data.
  5. If prompted, associate a Watson Machine Learning instance with your AutoAI experiment.
    1. Click Associate a Machine Learning service instance and select an instance of Watson Machine Learning.
    2. Click Reload to confirm your configuration.
  6. Click Create.

View the experiment details

AutoAI pre-populates the details fields for the sample experiment:

anomaly prediction pre-populated detail fields

  • 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. anomaly prediction relationship map and pipeline leaderboard

  1. 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.
  2. 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.

  1. 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.
  2. From the Model details page, click Promote to Deployment Space. Then, select or create a deployment space where the model will be deployed.

  3. Select to Go to the model in the space after promoting it.

  4. 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.

  1. Select New Deployment.

  2. Create a new deployment with the following fields:

    1. Deployment type: Online
    2. Name: Electricity usage online deployment
  3. Click Create and wait for the status to update to Deployed

  4. 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.

    anomaly prediction sample input data

  5. Click Predict to see whether there are any anomalies in the values.
    Note: -1 indicates an anomaly; 1 indicates a normal value.

anomaly prediction results table and chart

Next steps

Parent topic: Building a time series forecast experiment

Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more