Graph line and scatter plot in python

I am currently teaching a Machine Learning course from Coursera ( https://www.coursera.org/learn/ml-foundations/lecture/6wD6H/visualizing-predictions-of-simple-model-with-matplotlib ). The course uses the Graphlab Create framework for the course and assignments. I do not want to use Graphlab, instead I use pandas, numpyfor appointments.

During the course, the instructor created a regression model, and then he shows the forecast using matplotlib:

Assembly Regression Model

sqft_model = graphlab.linear_regression.create(train_data, target='price', features=['sqft_living'],validation_set=None)

and then the prediction code is as follows:

plt.plot(test_data['sqft_living'],test_data['price'],'.',
        test_data['sqft_living'],sqft_model.predict(test_data),'-')

Result:

prediction image

- , - . python. , pandas scikit. , Ipython:

from pandas.stats.api import ols
sqft_model = ols(y=train_data['price'], x=train_data['sqft_living'])

:

ValueError: . a.empty, a.bool(), a.item(), a.any() a.all()

, , (.. , ). - ?

PLS :

https://onedrive.live.com/redir?resid=EDAAD532F68FDF49!1091&authkey=!AKs341lbRnuCt9w&ithint=folder%2cipynb

+4
1

, , Pandas OLS GraphLab SArray. SFrames train_data test_data Pandas - :

df_train = train_data.to_dataframe()
model = old(y=df_train['price'], x=df_train['sqft_living'])
+1

Source: https://habr.com/ru/post/1619865/


All Articles