sklearn simple linear regression

 

Import Datasets sklearn from 
from sklearn.model_selection Import train_test_split
from sklearn.linear_model Import LinearRegression
from sklearn.metrics Import mean_squared_error

# load data rates Boston
Boston datasets.load_boston = ()
X, Y = boston.data, boston.target

# training set is divided and test set
x_train, x_test, y_train, android.permission.FACTOR. = train_test_split (the X-, the y-, test_size = 0.25, random_state = 10010)

# training set to train the model
REG = LinearRegression ()
reg.fit (x_train, y_train)

# using the model to predict
y_predict reg.predict = (x_test)

# between the predicted value and the true value of the mean square error calculation model the MSE
Print (mean_squared_error (android.permission.FACTOR., y_predict))

 

Guess you like

Origin www.cnblogs.com/timlong/p/11108797.html