-1

I have this two lists:

Predict = 
 [50.47426986694336, 50.587158203125, 50.58975601196289, 50.911197662353516]

Target =
 [[51.339996337890625, 51.79999923706055, 51.09000015258789, 64.86000061035156]]

How can I reshape one of them to be the same shape to the other so that I can plot the two lists please?

2 Answers2

0

Assuming, that the doubled colon in Target is a typo, you could do:

   import numpy as np

   np.reshape(Predict, (1, 4))

This results in:

 [[50.47426987, 50.5871582 , 50.58975601, 50.91119766]]
André Zmuda
  • 116
  • 1
0

Here is my code tested on my side for this question.

import numpy as np
import matplotlib.pyplot as plt

Predict = [50.47426986694336, 50.587158203125, 50.58975601196289, 50.911197662353516]
Target = [[51.339996337890625, 51.79999923706055, 51.09000015258789, 64.86000061035156]]

# Convert Predict to a NumPy array and transpose it
predict_array = np.array(Predict).T

# Reshape Predict to have the same shape as Target
predict_reshaped = predict_array.reshape(Target.shape)

# Plot both lists
plt.plot(predict_reshaped.flatten(), label='Predict')
plt.plot(Target.flatten(), label='Target')
plt.legend()
plt.show()