package com.tzld.piaoquan.recommend.server.service.score;

import com.typesafe.config.ConfigObject;
import com.typesafe.config.ConfigValue;
import com.tzld.piaoquan.recommend.server.service.score.model.XGBRegressionModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public abstract class XGBRegressionModelScorer extends AbstractScorer {
    private static Logger LOGGER = LoggerFactory.getLogger(XGBRegressionModelScorer.class);

    public XGBRegressionModelScorer(ScorerConfigInfo scorerConfigInfo) {
        super(scorerConfigInfo);
    }

    @Override
    public void loadModel() {
        doLoadModel(XGBRegressionModel.class);
        XGBRegressionModel model = (XGBRegressionModel) this.getModel();
        ConfigObject paramMap = scorerConfigInfo.getParamMap();
        if (paramMap != null) {
            ConfigValue value = paramMap.get("features");
            List<String> features = (List<String>) value.unwrapped();
            model.setFeatures(features.toArray(new String[features.size()]));
        }
    }
}
