Decision Trees

Machine Learning สำหรับการเงินด้วย Python

Nathan George

Data Science Professor

Decision trees

ต้นไม้การตัดสินใจพื้นฐาน

Machine Learning สำหรับการเงินด้วย Python

Decision trees

ต้นไม้การตัดสินใจพร้อมค่าเป้าหมาย

Machine Learning สำหรับการเงินด้วย Python

การแบ่งข้อมูลใน decision tree

การแบ่งข้อมูลแบบหมวดหมู่ใน decision tree

Machine Learning สำหรับการเงินด้วย Python

การแบ่งข้อมูลใน decision tree

การแบ่งข้อมูลแบบตัวเลขใน decision tree

Machine Learning สำหรับการเงินด้วย Python

ต้นไม้ที่ไม่ดี

การแบ่งข้อมูล regression ที่ไม่ดี

Machine Learning สำหรับการเงินด้วย Python

ต้นไม้ที่ดี

การแบ่งข้อมูล regression ที่ดี

Machine Learning สำหรับการเงินด้วย Python

Decision tree สำหรับ regression

การพยากรณ์ด้วย decision tree

Machine Learning สำหรับการเงินด้วย Python

Regression trees

from sklearn.tree import DecisionTreeRegressor

decision_tree = DecisionTreeRegressor(max_depth=5)

decision_tree.fit(train_features, train_targets)
Machine Learning สำหรับการเงินด้วย Python

Hyperparameters ของ decision tree

ความลึกสูงสุดของต้นไม้

Machine Learning สำหรับการเงินด้วย Python

Max depth เท่ากับ 3

decision tree ที่มี max depth เท่ากับ 3

Machine Learning สำหรับการเงินด้วย Python

ประเมินโมเดล

print(decision_tree.score(train_features, train_targets))
print(decision_tree.score(test_features, test_targets))
0.6662215501032416
-0.08917300191734268
train_predictions = decision_tree.predict(train_features)
test_predictions = decision_tree.predict(test_features)
plt.scatter(train_predictions, train_targets, label='train')
plt.scatter(test_predictions, test_targets, label='test')
plt.legend()
plt.show()
Machine Learning สำหรับการเงินด้วย Python

ค่าพยากรณ์เทียบกับค่าจริง

Machine Learning สำหรับการเงินด้วย Python

มาฝึกกันเถอะ!

Machine Learning สำหรับการเงินด้วย Python

Preparing Video For Download...