AutoTS in Python (Tutorial)

AutoTS is an automatic machine learning library in Python which is developed for the task of automatic time series forecasting. You can use this library for any task of time series forecasting such as predicting the stock prices for the next n number of days. In this article, I will take you through a tutorial on the AutoTS library in Python.

What is AutoTS in Python?

AutoTS means Automatic Time Series, it is a machine learning library in Python used for the task of time series forecasting. I recently used it for forecasting the stock prices of Apple for the next 10 days and the resulting figures were so accurate. Some of the popular features of the AutoTS library in Python are:

  1. It can be used to find the best time series forecasting model which depends on the type of data you are using.
  2. It can handle both the univariate and multivariate time series.
  3. It can also handle messy data by removing and filling the NaN values and it can also handle the outliers.
  4. You can use the models provided by this Python library for deployment also.

These were some of the important features of the AutoTS library in Python. It has more features for time series forecasting, you can explore more about this library from its official documentation from here. In the section below, I will take you through a tutorial on the AutoTS library in Python for the task of stock price prediction.

AutoTS in Python (Tutorial)

If you have never used this Python library for the task of time series forecasting before, then you can easily install it in your system by using the pip command; pip install autots. Now let’s see how to use the AutoTS library in Python for the task of stock price prediction. I will start this task by importing the necessary Python libraries and the dataset:

import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv("AAPL.csv")

In this tutorial, I am using the stock price data of Apple which has been downloaded from Yahoo Finance. Now before using the AutoTs library for the task of stock price prediction, let’s prepare the data and have a look at the closing stock prices of Apple:

stock price visualization using matplotlib

Now let’s see how to use the AutoTS library for the task of automatic time series forecasting:

In the code section above, I have set the forecast_length parameter as 10, which means the period for which we want to predict the stock prices. So in the output, we will get the closing stock prices of Apple for the next 10 days. So let’s use the predict function and have a look at the output:

Stock Price Prediction of Apple
                 Close
2021-04-19  132.794042
2021-04-20  132.882870
2021-04-21  132.971698
2021-04-22  133.060526
2021-04-23  133.149354
2021-04-26  133.415838
2021-04-27  133.504666
2021-04-28  133.593494
2021-04-29  133.682322
2021-04-30  133.771150

Also, Read – Python Projects with Source Code.

Summary

AutoTS means automatic time series, it is an AutoML library in Python which can be used for every task of the time series forecasting. I hope you liked this article on a tutorial on the AutoTS library in Python. Feel free to ask your valuable questions in the comments section below.

Default image
Aman Kharwal
Coder with the ♥️ of a Writer || Data Scientist | Solopreneur | Founder
Articles: 1054

Leave a Reply