0
$\begingroup$

I am doing a prediction using RandomForestRegressor.

Below is the code for test data:

    X = test_set.drop(['C_Nxt10DMx'], axis=1) # drop labels for training set
    Y = test_set['C_Nxt10DMx'].copy()                 
    test_prepared     = full_pipeline.transform(X)
    final_predictions = forest_reg.predict(test_prepared)
    final_mse = mean_squared_error(Y, final_predictions)
    final_rmse = np.sqrt(final_mse)
    (forest_rmse*100)/Y.mean()

I am printing Y.isnull().sum() and it is returning a 0 value. However, when I trying to bind the value in a data frame, it is returning an incorrect figure.

df =  pd.DataFrame() 
df['pred'] = final_predictions
df['Label'] = Y
print(Y.isnull().sum())
print(df['Label'].isnull().sum())

# 7646

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Possibly it's an index issue? What is Y.index? $\endgroup$ – Ben Reiniger Dec 26 '20 at 2:43
  • $\begingroup$ df and Y have different indices (they don't match). That's why you have missing values in df['label']. $\endgroup$ – Mykola Zotko Dec 26 '20 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.