[Python] Printing actual/predicted prices to compare - Are the actual and predicted prices...

Discussão em 'Python' iniciado por Stack, Abril 6, 2025.

  1. Stack

    Stack Membro Participativo

    I am attempting to print actual prices present in the datafile, vs predicted prices the model is outputting. Previous visualisations suggest the model is predicted prices very well, however, when I print the actual prices vs predicted prices, the difference on some on them is quite significant. I understand it would be quite difficult for the out puts to be similar but my concern is their is a mismatch in location of actual vs predicted price. As in, the predicted price showing is for a different predicted price within the datafile.

    Here is my code:

    for i in range(10):
    #obtaining actual price
    actual = y_train.iloc

    #obtaining predicted price the model expects
    predicted = tuned_price_pred[0]

    print(f'Sample {i+1}: Actual Price = {actual}, Predicted Price = {predicted:.2f}')


    And the output:

    Sample 1: Actual Price = 1438, Predicted Price = 68755.84
    Sample 2: Actual Price = 448, Predicted Price = 35248.59
    Sample 3: Actual Price = 14099, Predicted Price = 17495.16
    Sample 4: Actual Price = 8234, Predicted Price = 3129.10
    Sample 5: Actual Price = 6721, Predicted Price = 4754.03
    Sample 6: Actual Price = 107878, Predicted Price = 12064.00
    Sample 7: Actual Price = 9363, Predicted Price = 1937.27
    Sample 8: Actual Price = 4443, Predicted Price = 11906.56
    Sample 9: Actual Price = 31590, Predicted Price = 6055.22
    Sample 10: Actual Price = 27984, Predicted Price = 5048.94


    Is there a way to make sure the location are matching or is this code correct?

    Continue reading...

Compartilhe esta Página