MAPE Hatam Hakkında

Herkese merhabalar,

Yapmış olduğum Covid19 yapay sinir ağı projemde MAPE değerim için hocam hatalı dedi. Ancak kodlarımda nerede hata yapıyorum bilemiyorum. Acaba hatam nerede ve nasıl düzeltebilrim? Kodlarımı aşağıda paylaşıyorum.

Teşekkürler.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from seaborn import heatmap
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.preprocessing import MinMaxScaler
from sklearn.neural_network import MLPRegressor
import matplotlib.style as mplstyle
plt.style.use('seaborn-white')
csv_file_url = 'http://www.facadium.com.tr/cvd19/29072020-29062021.csv'
dataset = pd.read_csv(csv_file_url, sep = ',', index_col=0)
pd.set_option("display.max.rows", None)
dataset.head(2000)
for i, col in enumerate(dataset.columns.tolist()):
    plt.figure(figsize=(10, 6))
    x_axis = dataset.index.values
    y_axis = dataset[col].values
    plt.plot(x_axis, y_axis, label=col,marker='o')
    plt.title(col)
    plt.xlabel("Günler")
    plt.ylabel("Veriler")
    counter = 0
    for a, b in zip(x_axis, y_axis):
        counter +=1
        if counter % 60 == 0:
            plt.annotate(str(b), xy=(a,b))

dataset_shifted = dataset.iloc[0:,:]
dataset_shifted.head(2000)
dataset_shifted.describe()
scaler = MinMaxScaler()
dataset_scaled = scaler.fit_transform(dataset_shifted.values)
dataset_scaled = pd.DataFrame(scaler.fit_transform(dataset_shifted),columns=dataset_shifted.columns)
dataset_scaled.index = dataset_shifted.index
dataset_scaled.head(2000)
korelasyon = dataset_scaled.corr()
korelasyon
heatmap(korelasyon, xticklabels=dataset_shifted.columns, yticklabels=dataset_shifted.columns)
x = dataset_scaled.iloc[:,[0,1,2,5]]
y = dataset_scaled.iloc[:,[4]]
x
y
mlp = MLPRegressor(hidden_layer_sizes=(75,), max_iter=10000, learning_rate_init=0.05, random_state=41)
mlp.fit(x.values, y.values)
y_predicted = mlp.predict(x.values)
y_predicted
y.values.round(3)
mean_squared_error(y.values, y_predicted)
r2_score(y.values, y_predicted)
mlp.coefs_[0].round(3)
mlp.intercepts_
fig, ax = plt.subplots(figsize=(14, 7))


y.round(3).mul(5988).plot(label="gerçek", ls="-", c="g", ax=ax)


y_pred = pd.Series(y_predicted, index=y.index)
y_pred.mul(5988).plot(label="tahmini ağır hasta sayısı", ls="--", c="r", ax=ax)

plt.xlabel("",
         fontdict={
             'family' : 'Times New Roman',
             'color' : 'black',
             'size' : 10
         })


plt.title("Gerçek Ağır Hasta Sayısı ve Tahmini Ağır Hasta Sayısı Grafiği",
         fontdict={
             'family' : 'Times New Roman',
             'color' : 'black',
             'size' : 20
         })

# ayarlamalar
ax.legend(loc="upper left")
ax.grid(which="both")
ax = y.plot(linestyle='-')
plt.legend()
from sklearn.metrics import mean_absolute_error
mae = mean_absolute_error(y.values, y_predicted)
print('MAE: %f' % mae)
from sklearn.metrics import mean_squared_error
mse = mean_squared_error(y.values, y_predicted)
print('MSE: %f' % mse)
from sklearn.metrics import mean_squared_error
from math import sqrt
mse = mean_squared_error(y.values, y_predicted)
rmse = sqrt(mse)
print('RMSE: %f' % rmse)
from sklearn.metrics import mean_absolute_percentage_error
mape = mean_absolute_percentage_error(y.values, y_predicted)
print('MAPE: %f' % mape)