<jupyter_start><jupyter_text>Random ForestHave multiple decision trees, which slightly differ. When learning each decision tree one or more columns are not considered in a 'burst node'. Pro- Mostly more approximate then singale tree Con- Harder to understand decision- More computing power<jupyter_code># imports
import pandas as pd
import graphviz
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
# Read CSV
df = pd.read_csv("../res/classification.csv")
df.head()
# Prepare data

x = df[["age", "interest"]].values
y = df["success"].values

x_train, x_test, y_train, y_test = train_test_split(x, y, random_state = 0, test_size = 0.25)
# Train random forest
model = RandomForestClassifier(criterion = "entropy", n_estimators = 30)
model.fit(x_train, y_train)

print(model.score(x_test, y_test))
# Visualize Decision Tree
from plai.visualization.sklearn_visualization_helper import plot_classifier
plot_classifier(model, x_train, y_train, proba = False, xlabel = "Alter", ylabel = "Interesse")
# Show decision trees
model.estimators_<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08997429305912596, 'fraction_numerical': 0.005141388174807198, 'mean_word_length': 6.535483870967742, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '640373', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 374, 'n_tokens_neox': 361, 'n_words': 112, 'path': 'common/tutorials/src/ML_28_random_forest.ipynb', 'repo_name': 'maximilianharr/plai', 'size': '1167'}