Python में Model Validation
Kasey Jones
Data Scientist
पैरामीटर होते हैं:
पैरामीटर मॉडल फिट करने पर बनते हैं:
from sklearn.linear_model import LinearRegression
lr = LinearRegression()
lr.fit(X, y)
print(lr.coef_, lr.intercept_)
[[0.798, 0.452]] [1.786]
मॉडल फिट होने से पहले पैरामीटर मौजूद नहीं होते:
lr = LinearRegression()
print(lr.coef_, lr.intercept_)
AttributeError: 'LinearRegression' object has no attribute 'coef_'
हाइपरपैरामीटर:
| Hyperparameter | विवरण | संभावित मान (डिफ़ॉल्ट) |
|---|---|---|
| n_estimators | फॉरेस्ट में decision trees की संख्या | 2+ (10) |
| max_depth | decision trees की अधिकतम गहराई | 2+ (None) |
| max_features | स्प्लिट करते समय विचार किए जाने वाले फीचर्स की संख्या | See documentation |
| min_samples_split | स्प्लिट के लिए न्यूनतम जरूरी सैंपल्स | 2+ (2) |
हाइपरपैरामीटर ट्यूनिंग:
depth = [4, 6, 8, 10, 12] samples = [2, 4, 6, 8] features = [2, 4, 6, 8, 10]# हाइपरपैरामीटर तय करें rfc = RandomForestRegressor( n_estimators=100, max_depth=depth[0], min_samples_split=samples[3], max_features=features[1])rfr.get_params()
{'bootstrap': True,
'criterion': 'mse'
...
}
rfr.get_params()
{'bootstrap': True,
'criterion': 'mse',
'max_depth': 4,
'max_features': 4,
'max_leaf_nodes': None,
'min_impurity_decrease': 0.0,
'min_impurity_split': None,
'min_samples_leaf': 1,
'min_samples_split': 8,
...
}
Python में Model Validation