How to compare expected and predicted values?

0 votes
from sklearn.datasets import load_boston
boston_data = load_boston()
df = pd.DataFrame(boston_data.data , columns = boston_data.feature_names)
df
x = df
y = boston_data.target
x.columns
reg.fit(x,y)
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y)
reg.fit(x_train, y_train)
predicted = reg.predict(x_test)
expected = y_test

How to I compare the predicted and expected values to understand the model?

6 days ago in Python by Rishi
8 views

1 answer to this question.

0 votes

The predict() function returns a plain numpy array you can just represent it in a tabular format with original value to see the difference.

To check the accuracy of your model you can check out the RMS value. You can calculate RMS using the below code. 

import numpy as np
print("RMS: %r " % np.sqrt(np.mean((predicted - expected) ** 2)))
answered 6 days ago by Tina

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,790 points
107 views
0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 56,160 points
601 views
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

answered Sep 12, 2018 in Python by Priyaj
• 56,160 points
58 views
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

answered Sep 24, 2018 in Python by Priyaj
• 56,160 points
26 views
0 votes
1 answer

How to Pivot pandas for removing of some headers and renaming of some indexes?

Solution is add parameter values to pivot, then add reset_index for column ...READ MORE

answered Sep 27, 2018 in Python by Priyaj
• 56,160 points
310 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 128 views
0 votes
0 answers