0

With the code block below, I do the polynomial regression.

poly = PolynomialFeatures(degree=2, include_bias=False)
poly.fit(X_train)
X_poly_train = poly.transform(X_train)
X_poly_test = poly.transform(X_test)
poly_reg = LinearRegression()
poly_reg.fit(X_poly_train, y_train)
print()
print(f"2 polynomials score on training set: {poly_reg.score(X_poly_train, y_train):.2f}")
print(f"2 polynomials score on test set: {poly_reg.score(X_poly_test, y_test):.2f}")

But when I run the code below to plot the prediction, it just gives a straight line.

plt.scatter(X_train, y_train)
plt.scatter(X_test, y_test, color = "r")
poly_pred = poly_reg.predict(X_poly_test)
plt.plot(X_test, poly_pred,'m' )

The dataset I used is a pokemon one from Kaggle, and my task is to predict weight from size.

I have tried all other reponses for similar questions in StackOverflow, but non of them seem to apply.

y0g3n
  • 1
  • 1

0 Answers0