1

I have a response from a kerras prediction that looks like this (y_pred):

array([[127450.63 ],
       [181983.39 ],
       [150607.72 ],
       ...,
       [460400.   ],
       [ 92920.234],
       [244455.97 ]], dtype=float32)

I need to compare the results to another array that looks like this (t_pred):


[105000. 172000. 189900. ... 131000. 132000. 188000.]

How would I go about converting array 1 to look like array 2 so I can calculate its mean_square_log_error, like this?:

mean_squared_log_error(t_pred, y_pred)
0

1 Answer 1

1

Use ravel() or reshape(-1) or flatten():

mean_squared_log_error(t_pred, y_pred.ravel())

Or

mean_squared_log_error(t_pred, y_pred.reshape(-1))

Or

mean_squared_log_error(t_pred, y_pred.flatten())

Example:

>>> from sklearn.metrics import mean_squared_log_error
>>> y_pred = np.array([[127450.63, 181983.39,181983.39 ]]) 
>>> t_pred = [105000., 172000., 189900.]
>>> mean_squared_log_error(t_pred, y_pred.ravel())
0.01418072635060214
>>> mean_squared_log_error(t_pred, y_pred.reshape(-1))
0.01418072635060214
>>> mean_squared_log_error(t_pred, y_pred.flatten())
0.01418072635060214
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.