Can not use model loaded into workspace

NAW123 16 Reputation points
2024-11-24T17:10:48.26+00:00

Hi,

I load a trained model into the workspace using R, and when I use xgboost to predict, it always says:

         feature names stored in object and newdata are different

I checked the data for training and test, column names and order are the same, but test data has an extra column as a response/depending variable used for predicted results or compare prediction with it.

Without it, how do you know what to predict?

#modelclk$feature_names

test <- as.matrix(test2)

test$feature_names   ***(it says atomic vectors)***

dtest<- xgb.DMatrix(test2, missing=NaN)

pred<- predict(loadedmodel, dtest)

What is wrong?

A.

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,208 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vahid Ghafarpour 22,785 Reputation points
    2024-11-25T03:59:43.21+00:00

    Ensure that the response/dependent variable column is not included in the matrix you pass to xgb.DMatrix. The matrix should only contain the feature columns.

    0 comments No comments

  2. NAW123 16 Reputation points
    2024-11-30T00:46:23.17+00:00

    Thanks, it works!

    For old xxx.model, it always says error use model <- xxx.model. Is there anyway to load it?

    Thanks,

    N.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.