As the traceback mentions, the error originates from print("Actual value of the house: ", y_test[0])
.
y_test[0]
will only work when randomly 20% of the data also has the 0
th index in it after train_test_split
. That's why it works for some values of random_state
and not for most.
Generally you want to use either:
y_test.to_list()[0]y_test.iloc[0]
TLDR: Replace y_test[0]
in your print stament