# NeuralProphet Model with Python

Predicting stock prices is one of the most widely used areas where machine learning is used. This is an unpredictable area as there are so many factors that can affect the stock price at any time. In this article, I will introduce you to a machine learning tutorial on the Facebook NeuralProphet model with Python, which is one of the best methods for predicting stock prices.

## NeuralProphet Model

The NeuralProphet model is an open-source Python library used for time series modelling created by Facebook. This is a time series forecasting model based on PyTorch. This is an improved version of the Facebook Prophet model. The best thing about it is that this model is based on artificial neural networks.

Also, Read – 100+ Machine Learning Projects Solved and Explained.

The NeuralProphet model addresses some key points regarding customization, scalability, and extensionality. As it is built on top of statistical and neural network models for time series modelling so we can say it is mostly used for time series forecasting and anomaly detection.

In the section below, I’ll walk you through a machine learning tutorial on the NeuralProphet model using Python to see how this model works.

## NeuralProphet Model with Python: Tutorial

You can easily install this library by using the pip command; pip install neuralprophet[live]. Now let’s import the necessary libraries and see how to work with this machine learning model:

```import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from neuralprophet import NeuralProphet```

The dataset that I am using is a stock price data of Coal India. Now let’s import the dataset:

`df = pd.read_csv("COALINDIA.csv", parse_dates=["Date"])`

Now let’s prepare the dataset to fit into the model. It also follows the same way used by the Facebook Prophet model of representing timestamps as ds and dependent variables as y:

```df = df[["Date", "VWAP"]]
df.rename(columns={"Date": "ds", "VWAP": "y"}, inplace=True)```

Now let’s fit the dataset in the model:

```model = NeuralProphet()
metrics = model.fit(df, validate_each_epoch=True, freq="D")```

Now the final step is to make predictions:

`fig_comp = model.plot_components(forecast)`

### Conclusion

So we can say that there is a decline in stock prices. I hope you liked this article on NeuralProphet model in Machine Learning with Python. It is very easy to use and understand how to analyze the time series data using this model. Feel free to ask your valuable questions in the comments section below. ##### Aman Kharwal
Coder with the ♥️ of a Writer || Data Scientist | Solopreneur | Founder
Articles: 1109