i want same row number for the predicted dataset .
for previous rf model its working fine after performing the one hot encoding the model predicts the value but the row numbers are not same as the test data set(new data set)
Without going back and doing an example run, here's what I'd expect.
Determine training error by running the model on the training set should give you the same row numbering, because every Ŷ corresponds to every Y.
Determine prediction error by running the model on the test set can't give you the same row number if the train/test split wasn't 50/50, and it won't give you the sam row number even with an even split because test Ŷ for test Y has no one-to-one correspondence to either for the training set, only to the training set model, which is derived from the parameters of the training set.
Only aggregate measures such as RMSE in linear regression can tell you about model fit.