Home > other >  Sklearn DecisionTreeRegressor - Extend prediction
Sklearn DecisionTreeRegressor - Extend prediction

Time:06-08

Trying to build a sklearn DecisionTreeRegressor, I'm following the steps listed enter image description here


Linear model



X_train = np.array([[100],[500],[1500],[3500]])
y_train = np.array([23, 43, 44, 55])

reg = LinearRegression().fit(X_train, y_train)

x_outside_range = np.array([[4000], [10000]])

plt.plot(X_train,y_train, label='train data')
plt.plot(x_outside_range ,reg.predict(x_outside_range), label='prediction outside train data range')
plt.legend()

enter image description here

  • Related