Regression models

Python में Model Validation

Kasey Jones

Data Scientist

scikit-learn में Random forests

from sklearn.ensemble import RandomForestRegressor
from sklearn.ensemble import RandomForestClassifier
rfr = RandomForestRegressor(random_state=1111)
rfc = RandomForestClassifier(random_state=1111)
Python में Model Validation

डिसीजन ट्री सभी पॉइंट्स से शुरू होते हैं और ऊपर से अलग-अलग स्प्लिट के आधार पर शाखाएँ बनाते हैं। हर डेटा पॉइंट के गुणों के अनुसार आप ट्री की शाखाओं पर अलग-अलग रास्ते फॉलो करते हैं।

Python में Model Validation

एक random forest बनने पर, हर डेटा पॉइंट के लिए अलग-अलग डिसीजन ट्री के नतीजों का औसत लेकर उसी पॉइंट की फाइनल prediction मिलती है।

Python में Model Validation

Random forest parameters

n_estimators: जंगल में ट्री की संख्या

max_depth: ट्री की अधिकतम गहराई

random_state: random seed

from sklearn.ensemble import RandomForestRegressor
rfr = RandomForestRegressor(n_estimators=50, max_depth=10)
rfr = RandomForestRegressor(random_state=1111)
rfr.n_estimators = 50
rfr.max_depth = 10
Python में Model Validation

Feature importance

मॉडल में हर कॉलम की अहमियत प्रिंट करें

for i, item in enumerate(rfr.feature_importances_):
    print("{0:s}: {1:.2f}".format(X.columns[i], item))
weight: 0.50
height: 0.39
left_handed: 0.72
union_preference: 0.05
eye_color: 0.03
Python में Model Validation

चलें शुरू करें

Python में Model Validation

Preparing Video For Download...