Home > Back-end >  How to print prediction results in a file next to the actual values in Python
How to print prediction results in a file next to the actual values in Python

Time:10-29

I did my prediction for multilabel multiclass

now I want to print the predicted values along the side of the actual test values

y_pred 

y_test

something like this

  0    1    2    3    4    5      |     0    1    2    3    4    5 
---------------------------------------------------------------------
  1    0   0     1    1    0      |     0    1    0    0    0    1
  0    1   0     0    1    1      |     1    1    1    0    0    0
  1    0   0     0    1    0      |     0    1    0    0    1    0

I tried this but it worked for each file separately not for both

pd.DataFrame(y_test).to_csv("j:\\compare.csv")
pd.DataFrame(y_pred).to_csv("j:\\compare.csv")

CodePudding user response:

You can concat them and then save them

y_test = pd.DataFrame(y_test)
y_pred = pd.DataFrame(y_pred)
df = pd.concat([y_test, y_pred], axis=1)
df.to_csv("j:\\compare.csv")
  • Related