डेटा स्केलिंग और KNN रिग्रेशन

Python में Finance के लिए Machine Learning

Nathan George

Data Science Professor

फीचर इम्पॉर्टेंस

Python में Finance के लिए Machine Learning

फीचर चयन: weekdays हटाएँ

print(feature_names)
['10d_close_pct',
 '14-day SMA',
 '14-day RSI',
 '200-day SMA',
 '200-day RSI',
 'Adj_Volume_1d_change',
 'Adj_Volume_1d_change_SMA',
 'weekday_1',
 'weekday_2',
 'weekday_3',
 'weekday_4']
print(feature_names[:-4])
['10d_close_pct',
 '14-day SMA',
 '14-day RSI',
 '200-day SMA',
 '200-day RSI',
 'Adj_Volume_1d_change',
 'Adj_Volume_1d_change_SMA']
Python में Finance के लिए Machine Learning

weekdays हटाएँ

train_features = train_features.iloc[:, :-4]
test_features = test_features.iloc[:, :-4]
Python में Finance के लिए Machine Learning

2D फीचर प्लॉट

Python में Finance के लिए Machine Learning

KNN प्रिडिक्शन अज्ञात

Python में Finance के लिए Machine Learning

2 निकटतम पॉइंट से KNN प्रिडिक्शन

Python में Finance के लिए Machine Learning

मिनकोव्स्की डिस्टेंस

Python में Finance के लिए Machine Learning

बड़े और छोटे फीचर

Python में Finance के लिए Machine Learning

स्केलिंग विकल्प

स्केलिंग विकल्प:

  • min-max
  • standardization
  • median-MAD
  • मनचाही फंक्शन पर मैप करें (जैसे sigmoid, tanh)
Python में Finance के लिए Machine Learning

स्केलिंग से पहले और बाद के 2D फीचर प्लॉट

Python में Finance के लिए Machine Learning

sklearn का scale

from sklearn.preprocessing import scale

sc = scale()
scaled_train_features = sc.fit_transform(train_features)
scaled_test_features = sc.transform(test_features)
Python में Finance के लिए Machine Learning

स्टैंडर्डाइजेशन से पहले और बाद

Python में Finance के लिए Machine Learning

सबप्लॉट बनाना

# create figure and list containing axes
f, ax = plt.subplots(nrows=2, ncols=1)

# plot histograms of before and after scaling train_features.iloc[:, 2].hist(ax=ax[0]) ax[1].hist(scaled_train_features[:, 2]) plt.show()
Python में Finance के लिए Machine Learning

डेटा स्केल करें और KNN चलाएँ!

Python में Finance के लिए Machine Learning

Preparing Video For Download...