COMPUSDT.csv
I am just trying out neural prophet for the first. I used this code to run as a test. I configured it to run a forecast for a day. but it does not show for a day it only forcast to the date and time the dataframe contains. The data contains a 3-days data. As an example, starting from today, and counting 3 days backward. makes a 3-day data. What i want it to do is to forecast for tomorrow. It didn't do it.
import pandas as pd
from neuralprophet import NeuralProphet, set_log_level
set_log_level("ERROR")
import plotly.express as px
import plotly.graph_objects as go
from statsmodels.graphics.tsaplots import plot_acf
# Load your data
df = pd.read_csv("COMPUSDT.csv")
print(df.head(10))
# Rename the necessary columns
df = df.rename(columns={"Opened": "ds", "Close": "y"})
print(df)
# Convert the 'ds' column to datetime format
df['ds'] = pd.to_datetime(df['ds'], format='%Y-%m-%d %H:%M:%S')
print(df)
# List of columns to drop
columns_to_drop = ['Open', 'High', 'Low', 'Volume', 'Adj Close']
# Check if columns exist in the DataFrame and drop them if they do
df = df.drop(columns=[col for col in columns_to_drop if col in df.columns])
print(df)
# Initialize NeuralProphet model
m = NeuralProphet(
growth="linear", # Determine trend types: 'linear', 'discontinuous', 'off'
changepoints_range=0.95,
trend_reg=0,
trend_reg_threshold=False,
yearly_seasonality="auto",
weekly_seasonality="auto",
daily_seasonality="auto",
seasonality_mode="additive",
seasonality_reg=0,
n_lags=7,
batch_size=32,
learning_rate=None,
epochs=100,
loss_func="Huber",
normalize="auto", # Type of normalization ('minmax', 'standardize', 'soft', 'off')
impute_missing=True
)
metrics = m.fit(df, freq="30min")
metrics.head(10)
# future = m.make_future_dataframe(df, periods=100, n_historic_predictions=len(df))
future = m.make_future_dataframe(df, periods=48, n_historic_predictions=len(df))
future.tail(3)
forecast = m.predict(future)
print(list(forecast.columns))
# Visualize the forecast
m.plot(forecast, figsize=(20, 12))
m.plot_parameters(components=["trend", "seasonality"])
# plots the model predictions
fig1 = m.plot(forecast, figsize=(20, 12))
fig1.show()
# visualizes the model parameters.
fig2 = m.plot_parameters()
fig2.show()
fig = go.Figure()
fig.add_scatter(x=metrics.index, y=metrics['RMSE'], mode='lines', name="RMSE")
fig.add_scatter(x=metrics.index, y=metrics['MAE'], mode='lines', name="MAE")
fig.update_layout( yaxis_title='Error', title='Compound', hovermode="x")
fig.show()
fig = go.Figure()
fig.add_scatter(x=df['ds'], y=df['y'], mode='lines', name="original")
fig.add_scatter(x=forecast['ds'], y=forecast['yhat1'], mode='lines', name="prediction")
fig.update_layout(yaxis_title='Price', title='Compound', hovermode="x")
fig.show()
Can someone help look into the issue, and what to do.
Example: print(forecast.tail()) displays the result below
COMPUSDT.csv I am just trying out neural prophet for the first. I used this code to run as a test. I configured it to run a forecast for a day. but it does not show for a day it only forcast to the date and time the dataframe contains. The data contains a 3-days data. As an example, starting from today, and counting 3 days backward. makes a 3-day data. What i want it to do is to forecast for tomorrow. It didn't do it.
Can someone help look into the issue, and what to do.
Example:
print(forecast.tail())
displays the result belowAs seen yhat1 does not show the forecast