import pandas as pd
from prophet import Prophet
import [Link] as plt
# Load the dataset
file_path = '/content/ASIANPAINT.NS_stock_data_inr.csv' # Adjust the path if
necessary
df = pd.read_csv(file_path)
# Rename columns to fit Prophet's requirements
[Link](columns={'Date': 'ds', 'Close': 'y'}, inplace=True)
# Convert 'ds' to datetime format
df['ds'] = pd.to_datetime(df['ds'])
# Initialize and fit the Prophet model
model = Prophet()
[Link](df)
# Create a dataframe to predict the next 3 months (approximately 90 days)
future = model.make_future_dataframe(periods=90)
# Make predictions
forecast = [Link](future)
# Get the last actual value from the original data
last_actual_value = df['y'].iloc[-1]
# Calculate percentage change for predictions
forecast['percent_change'] = ((forecast['yhat'] - last_actual_value) /
last_actual_value) * 100
# Filter the forecast to show predictions for the third month only
third_month_start = future['ds'].iloc[-90] + [Link](days=60)
third_month_end = future['ds'].iloc[-90] + [Link](days=90)
third_month_forecast = forecast[(forecast['ds'] >= third_month_start) &
(forecast['ds'] <= third_month_end)]
# Display relevant columns with percentage change for the third month
forecast_with_percentage = third_month_forecast[['ds', 'yhat', 'yhat_lower',
'yhat_upper', 'percent_change']]
print(forecast_with_percentage)
# Plot the forecast for all data
fig1 = [Link](forecast)
[Link]('Stock Price Forecast')
[Link]('Date')
[Link]('Close Price')
[Link]()
# Plot forecast components
fig2 = model.plot_components(forecast)
[Link]()