You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your implementation looks promising, but I am not sure how to use it.
Suppose we have age, gender and height(in cm) and we need to predict the weight (in kg) of people.
So we have for training set the following csv:
age,gender,height,weight
18,m,180,80
40,m,175,85
25,f,165,50
You cannot use xgboost-predictor to build a model but you can use to predict.
xgboost-predictor provides only prediction functions.
If you want to build a model on JVM, you should use XGBoost4J.
To predict weight using xgboost-predictor, you should:
Load XGBoost model using Predictor class.
Represent a feature vector using FVec interface.
Predictorpredictor = newPredictor(
newjava.io.FileInputStream("/path/to/xgboost-model-file"));
for (float[] f : testFeatures) {
FVecfv = FVec.Transformer.fromArray(f, false/* do not treat zero element as N/A */);
double[] prediction = predictor.predict(fv);
doublepredictedWeight = prediction[0];
}
@komiya-atsushi hi, I'm interested in this api. Why this library use for loop to predict each feature instead of just predicting once with a matrix? Will this be faster? If true, will it keep faster if the size of testFeatures is very big?
I'm new about this library, just for interesting, thank you
Hi,
Your implementation looks promising, but I am not sure how to use it.
Suppose we have age, gender and height(in cm) and we need to predict the weight (in kg) of people.
So we have for training set the following csv:
age,gender,height,weight
18,m,180,80
40,m,175,85
25,f,165,50
and we load it into a feature matrix:
and into a vector of target values:
float[] targets = new float[] { 80, 85, 50 }
and we also have a test set for which we need to predict the target values:
22,m,175
30,f,160
which we load into a feature matrix:
Can you please give an example of how the xgboost-predictor can be applied to such data to train on the first set and predict on the second set?
Thank you
Doron
The text was updated successfully, but these errors were encountered: