import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import warnings
'ignore')
warnings.filterwarnings(
= pd.read_csv('_data/04.csv')
dataset = dataset.iloc[:, 1:-1].values
x = dataset.iloc[:, -1].values y
random forest
machine learning
Preprocessing
Modeling
from sklearn.ensemble import RandomForestRegressor
= RandomForestRegressor(n_estimators=10, random_state=0)
regressor
# 모델 학습
regressor.fit(x, y)
RandomForestRegressor(n_estimators=10, random_state=0)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
RandomForestRegressor(n_estimators=10, random_state=0)
Visualization
= np.arange(min(x), max(x), 0.1)
x_grid = x_grid.reshape((len(x_grid), 1))
x_grid ='red')
plt.scatter(x, y, color='blue')
plt.plot(x_grid, regressor.predict(x_grid), color plt.show()