Python regression code question.

Asked 2 years ago, Updated 2 years ago, 60 views

from sklearn.datasets import load_boston
boston = load_boston()

from matplotlib import pyplot as plt
plt.scatter(boston.data[:,5], boston.target, color='r')

import numpy as np
x = boston.data[:,5]
x = np.array([[v,1] for v in x])
y = boston.target
(slope, bias),total_error,_,_ = np.linalg.lstsq(x,y)
rmse = np.sqrt(total_error[0] / len(x))

It's a question that shows Boston housing data on a graph during example study, but if you enter the code above,

'rcond' parameter will change to the default of machine precision times ''max(m,n)'' where m and n are the input matrix dimensions.
To use the future default and silence this warning we advise to pass 'rcond=None', to keep using the old, explicitly pass 'rcond=-1'. 

That's what it says. Next, (slope, bias), total_error,_,_ = np.linalg.lstsq(x,y) Only this is printed

I don't understand what you're saying and why doesn't it show up as a graph?

python regression matplotlib

2022-09-22 18:05

2 Answers

No problem code.

The message is a warning that appears because of the version difference between the numpy version and the scikit learn. There is no problem with learning.


2022-09-22 18:05

Try it as below.

from sklearn.datasets import load_boston
boston = load_boston()

from matplotlib import pyplot as plt
plt.scatter(boston.data[:,5], boston.target, color='r')

plt.show()


2022-09-22 18:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.