Python Forum
Machine Learning Polynomial Regression
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Machine Learning Polynomial Regression
#1
Hello All,

I am facing some problem while implementing polynomial regression for my machine learning module. Part of my code is as below:
poly = PolynomialFeatures(degree = 4) 
X_poly = poly.fit_transform(X) 
lin = LinearRegression() 
lin.fit(X_poly, Y)
y_poly_pred = lin.predict(X_poly)
plt.scatter(X['Totalizer'], Y, color='red')
plt.plot(X['Totalizer'], y_poly_pred, color='b')
plt.title('Polynomial Regression')
plt.xlabel('Totalizer')
plt.ylabel('Temperature')
plt.show()

rmse = np.sqrt(mean_squared_error(Y,y_poly_pred))
r2 = r2_score(Y,y_poly_pred)
print(rmse)
print(r2)
Please also see attached picture :
   

My question is that my predicted values are completely in line with output(label) but still rmse and r2 are respectively 10.2 & 0.99. Why this rmse and r2 are showing in opposite direction that model is not tuned well? Am I missing something important?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Feature Selection in Machine Learning shiv11 3 1,664 Dec-01-2023, 08:56 AM
Last Post: JiahMehra
  [machine learning] identifying a number 0-9 from a 28x28 picture, not working SheeppOSU 0 1,823 Apr-09-2021, 12:38 AM
Last Post: SheeppOSU
  Getting started in Machine Learning Harshil 5 3,170 Dec-07-2020, 04:06 PM
Last Post: sridhar
  Python Machine Learning: For Data Extraction JaneTan 0 1,803 Nov-24-2020, 06:45 AM
Last Post: JaneTan
  IndexError in Array while trying to do machine learning Mariaoye 0 1,863 Nov-12-2020, 12:35 AM
Last Post: Mariaoye
  Errors with Machine Learning trading bot-- not sure why MattKahn13 0 1,348 Aug-07-2020, 08:19 PM
Last Post: MattKahn13
  How useful is PCA for machine learning? Marvin93 0 1,510 Aug-07-2020, 02:07 PM
Last Post: Marvin93
  How to extract data from paragraph using Machine Learning with python? bccsthilina 2 3,007 Jul-27-2020, 07:02 AM
Last Post: hussainmujtaba
  Machine Learning: Process Enanda 13 4,191 Mar-18-2020, 02:02 AM
Last Post: jefsummers
  Can I evaluate a Chebyshev polynomial using a function player1681 1 1,957 Nov-22-2019, 06:33 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020