အချိန်အစဉ် သို့မဟုတ် Group အလိုက် Model စစ်ခြင်း

scikit-learn 1.9.1

နောင်ကဒေတာကို training ထဲ မထည့်ပါနဲ့။ Evaluation row နဲ့ entity တူတဲ့ record တွေကို ခွဲရာမှာ သတိထားပါ။

ဒီစာမျက်နှာမှာ

Training ကို Evaluation ရှေ့မှာ ထားခြင်း

Forecasting မှာ shuffle split သုံးရင် နောင် observation က training ထဲ ဝင်နိုင်ပါတယ်။ အချိန်အစဉ်စီပြီး နောက်ကျ observation ပေါ် အကဲဖြတ်ပါ။ TimeSeriesSplit က training window ကို တဖြည်းဖြည်း ချဲ့ပြီး evaluation ရှေ့ gap ချန်နိုင်ပါတယ်။ ကြာချိန်တူ fold လိုရင် observation ကြား အချိန်အကွာ ညီဖို့ လိုပါတယ်။

import numpy as np
from sklearn.model_selection import TimeSeriesSplit

rows = np.arange(8)
for train, test in TimeSeriesSplit(n_splits=2, test_size=2, gap=1).split(rows):
    print(train[-1], test[0])
နမူနာ ရလဒ်
2 4
4 6

Entity တစ်ခုစီကို တစ်ကြိမ်မှာ Fold တစ်ခုထဲ ထားခြင်း

Customer၊ order သို့မဟုတ် session တူတဲ့ row တွေရှိရင် အဲဒီ entity နဲ့ စုပါ။ GroupKFold က split တစ်ခုစီမှာ test group ကို train group ထဲ မပါအောင် ခွဲပါတယ်။ ခန့်မှန်းချိန်မှာ ဘာအသစ်ဖြစ်မလဲနဲ့ ကိုက်တဲ့ group ရွေးပါ။

တရားဝင် ကိုးကားချက်များ