BaşlayınÜcretsiz başlayın

Tahmin sonuçlarını görselleştirme

Backtesting kullanarak modelleri tanımlayıp eğittikten sonra, sırada sonuçları görselleştirmek var. Görselleştirme, bölümler (partitions) arasında model performansını hızlı ve etkili bir şekilde değerlendirmek için harika bir yöntemdir.

Önceki egzersizlerden ts ve bkt_df DataFrame'leri ile Plotly kütüphanesi senin için önceden yüklendi. Hadi modellerimizin ne kadar iyi performans gösterdiğini keşfedelim!

Bu egzersiz, kursun bir parçasıdır

Üretim için Tahmin (Forecasting) Hatları Tasarlama

Kursa Göz Atın

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

partitions_labels = bkt_df["cutoff"].unique()
ts_sub = ts[ts["ds"] > ts["ds"].max() - datetime.timedelta(hours=24 * 7)]

# Create subplots with four rows (one for each partition)
fig = make_subplots(rows=4, cols=1, subplot_titles=["Partitions: " + str(i) for i in partitions_labels])

r = 1  

for i in partitions_labels:
    if r == 1:
        showlegend = True
    else:
        showlegend = False
    bkt_sub = bkt_df[bkt_df["cutoff"] == i]
    # Add actual values to the plot
    fig.append_trace(go.Scatter(x=ts_sub["ds"], y=ts_sub["y"], legendgroup="actual", showlegend=showlegend, 
                                mode='lines', name='Actual', line=dict(color='#023047', width=2)), row=r, col=1)
    # Add k-nearest neighbors predictions
    fig.append_trace(go.Scatter(x=bkt_sub["ds"], y=bkt_sub["knn"], mode='lines', name='k-nearest neighbors', 
                                legendgroup="knn", showlegend=showlegend, line=dict(color='#2a9d8f', width=1.5, dash="dash")), row=r, col=1)
    # Add Multi-layer Perceptron predictions
    fig.append_trace(go.Scatter(x=bkt_sub["ds"], y=bkt_sub["mlp"], mode='lines', name='Multi-layer Perceptron', 
                                legendgroup="mlp", showlegend=showlegend, line=dict(color='#0077b6', width=1.5, dash="dot")), row=r, col=1)
    # Add ElasticNet predictions
    fig.append_trace(go.Scatter(x=bkt_sub["ds"], y=bkt_sub["enet"], mode='lines', name='ElasticNet', 
                                legendgroup="enet", showlegend=showlegend, line=dict(color='#ffc8dd', width=1.5, dash="dot")), row=r, col=1)
    r = r + 1 

fig.update_layout(height=500)
fig.show()
Kodu Düzenle ve Çalıştır