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)
asked Sep 26, 2020 at 14:48
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
answered Sep 26, 2020 at 14:51
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.