package org.ts.ddcs.Tool;

import org.ts.ddcs.log.LogHelper;

import java.util.List;

@SuppressWarnings("all")
public class IForestCheckHelp {

    public final static  int PREDICT_UNKNOW =0;
    public final static  int PREDICT_NORMAL =1;
    public final static  int PREDICT_OUTLIERS=-1;

    public static int IForestPredict(List<Double> datas,double predictValue)  {
        try {
            IForest iForest = new IForest();
            iForest.train(datas);
            int score = iForest.predict(predictValue);
            return score;
        }catch (Exception e){
            LogHelper.error(e);
            return IForestCheckHelp.PREDICT_UNKNOW;
        }
    }


    public static int IForestPredict(List<Double> datas,double predictValue,int trees,int maxSamples,int treeHigh)  {
        try {
            IForest iForest = new IForest(trees,maxSamples,treeHigh);
            iForest.train(datas);
            int score = iForest.predict(predictValue);
            return score;
        }catch (Exception e){
            LogHelper.error(e);
            return IForestCheckHelp.PREDICT_UNKNOW;
        }
    }
}
