Python Forum
sklearn Polynomial Features Graphing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sklearn Polynomial Features Graphing
#1
Here is the code I have written so far:
from sklearn.preprocessing import PolynomialFeatures
x=data['True Vertical Depth']
y=data['Cum Oil']
poly.fit_transform(x[:,None])
from sklearn.pipeline import make_pipeline
poly_model = make_pipeline(PolynomialFeatures(2),LinearRegression())
poly_model.fit(x[:, np.newaxis], y)
xfit = x[:, np.newaxis]
yfit = poly_model.predict(xfit)
plt.scatter(x, y,label='data')
plt.plot(xfit, yfit,'r',label='predict')
plt.xlabel('True Vertical Depth')
plt.ylabel('Cumulative Oil Production')
plt.title('Model of True Vertical Depth Influence on Cumulative Oil Production with 2nd Order Trendline')
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
plt.show()
And a picture of the graph:
[Image: n3eddS]

As you can see the trendline is not a trendline really. It is more of a series of swiggles. I also know that this data probably shouldn't have a trendline because there is no trend, but its the assignment. My question is about how to fix the trendline. I've tried everything and they it'll only go to a single line when it the polynomial is 1.

Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using face dataset to group similar facial features based on 3 features into folders Jaydenstrategies 1 1,647 Jun-18-2020, 02:02 AM
Last Post: pyzyx3qwerty
  Polynomial value between a interval RiceGum 3 3,244 Nov-17-2017, 02:59 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

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