import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.ensemble import RandomForestRegressor


dataset = pd.read_csv("./Position_Salaries.csv")
x = dataset.iloc[:, 1:2].values
y = dataset.iloc[:, 2].values
regressor = RandomForestRegressor(n_estimators=10, random_state=0)
regressor.fit(x, y)
y_pred = regressor.predict(6.5)

plt.scatter(x, y, color='red')
x_grid = np.arange(min(x), max(x), 0.001)
x_grid = x_grid.reshape((len(x_grid), 1))
plt.plot(x_grid, regressor.predict(x_grid), color='blue')
plt.title('Random tree regresiion')
plt.xlabel('position level')
plt.ylabel('Salary')
plt.show()
