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?

Jul 13, 2019 in Python by Rishi
38 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 Jul 13, 2019 by Tina

Related Questions In Python

0 votes
1 answer

How to have values from a List1 into Columns Names and List 2 Values as Index for an Empty DataFrame

Try like this, it will give you ...READ MORE

answered Jul 10, 2019 in Python by Cherukuri
• 32,420 points
61 views
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,810 points
211 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
• 57,450 points
2,932 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
• 57,450 points
90 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
• 57,450 points
61 views
0 votes
1 answer
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 518 views
0 votes
0 answers
0 votes
0 answers