EXP4DV
EXP4DV
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, mean_squared_error
# Train Model
model = LinearRegression()
model.fit(X_train, y_train)
# Predict Sales
predictions = model.predict(X_test)
# Evaluate Model
mae = mean_absolute_error(y_test, predictions)
mse = mean_squared_error(y_test, predictions)
print(f"Mean Absolute Error: {mae}")
print(f"Mean Squared Error: {mse}")
# Visualizing Predictions
plt.scatter(df["Year"], df["Sales"], color='blue', label='Actual Data')
plt.plot(future_years, future_sales, color='red', linestyle='dashed',
label='Predicted Trend')
plt.xlabel("Year")
plt.ylabel("Sales")
plt.title("Future Sales Prediction")
plt.legend()
plt.show()