Ravindra BagaleCourses & study guides English Track your progress

35. Decision Trees आणि Random Forests — Python मध्ये

Data Science

35.4 छोटे Random Forest Copy-Run

का गरजेचे आहे. त्याच data वर मजबूत समिती — laptop-friendly demo साठी छोटे n_estimators सह RandomForest.

हे काय आहे. RandomForestClassifier(n_estimators=50) 50 trees बांधते आणि class साठी majority-vote करते.

कसे करायचे.

छोटे forest fit करा

  1. त्याच X_train, y_train वापरा.
  2. RandomForestClassifier fit करा.
  3. X_test वर single tree शी predict तुलना करा (फक्त spot-check).
from sklearn.ensemble import RandomForestClassifier

forest = RandomForestClassifier(n_estimators=50, random_state=0)
forest.fit(X_train, y_train)
print("tree preds: ", tree.predict(X_test))
print("forest preds:", forest.predict(X_test))
print("feature_importances_:", forest.feature_importances_.round(3))

तुम्हाला काय दिसायला हवे. दोन्ही models कडून predictions; सुमारे 1.0 पर्यंत बेरीज होणारे importances — “forest ने कोणता column जास्त वापरला” असा rough संकेत, causal proof नाही.

काल्पनिक data

तोच शिकवण्याचा churn table — production CRM extract नाही.