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

import com.google.common.reflect.TypeToken;
import com.typesafe.config.ConfigObject;
import com.typesafe.config.ConfigValue;
import com.tzld.piaoquan.recommend.server.service.score.model.XGBoostModel;
import com.tzld.piaoquan.recommend.server.util.JSONUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;


public abstract class BaseXGBoostModelScorer extends AbstractScorer {

    private static Logger LOGGER = LoggerFactory.getLogger(BaseXGBoostModelScorer.class);

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

    @Override
    public void loadModel() {
        doLoadModel(XGBoostModel.class);
        XGBoostModel model = (XGBoostModel) 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()]));
        }
    }
}
