<jupyter_start><jupyter_text>随机森林<jupyter_code>from sklearn.ensemble import RandomForestClassifier
# n_estimators 多少个分类器
# oob_score 是否记录oob
rf_clf = RandomForestClassifier(n_estimators=500, random_state=666, oob_score=True, n_jobs=-1)

rf_clf.fit(X, y)
rf_clf.oob_score_
rf_clf2 = RandomForestClassifier(n_estimators=500,
                                 random_state=666, 
                                 oob_score=True, 
                                 max_leaf_nodes=16,
                                 n_jobs=-1)

rf_clf2.fit(X, y)
rf_clf2.oob_score_<jupyter_output><empty_output><jupyter_text>Extre-Trees<jupyter_code>from sklearn.ensemble import ExtraTreesClassifier

et_clf = ExtraTreesClassifier(n_estimators=500, bootstrap=True, oob_score=True, n_jobs=-1, random_state=666)
et_clf.fit(X, y)
et_clf.oob_score_<jupyter_output><empty_output><jupyter_text>回归问题<jupyter_code>from sklearn.ensemble import BaggingRegressor, RandomForestRegressor, ExtraTreesRegressor<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08582834331337326, 'fraction_numerical': 0.02594810379241517, 'mean_word_length': 4.091370558375634, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '116217', 'license': 'MIT', 'n_tokens_mistral': 418, 'n_tokens_neox': 404, 'n_words': 42, 'path': 'ml/ensemble/random_forest.ipynb', 'repo_name': 'tangchunbo/machine-learning', 'size': '1002'}