Python में Time Series Data के लिए Machine Learning
Chris Holdgraf
Fellow, Berkeley Institute for Data Science
print(df)
df
0 0.0
1 1.0
2 2.0
3 3.0
4 4.0
# DataFrame/Series को 3 इंडेक्स मान अतीत की ओर शिफ्ट करें
print(df.shift(3))
df
0 NaN
1 NaN
2 NaN
3 0.0
4 1.0
# data एक pandas Series है जिसमें time series डेटा है
data = pd.Series(...)
# Shifts
shifts = [0, 1, 2, 3, 4, 5, 6, 7]
# टाइम-शिफ्टेड डेटा की डिक्शनरी बनाएँ
many_shifts = {'lag_{}'.format(ii): data.shift(ii) for ii in shifts}
# इन्हें DataFrame में बदलें
many_shifts = pd.DataFrame(many_shifts)
# इन इनपुट फीचर्स से मॉडल फिट करें
model = Ridge()
model.fit(many_shifts, data)
# फिट मॉडल के कोएफ़िशिएंट्स देखें
fig, ax = plt.subplots()
ax.bar(many_shifts.columns, model.coef_)
ax.set(xlabel='Coefficient name', ylabel='Coefficient value')
# फॉर्मैटिंग ताकि ग्राफ़ साफ दिखे
plt.setp(ax.get_xticklabels(), rotation=45, horizontalalignment='right')


Python में Time Series Data के लिए Machine Learning