Example usage for weka.classifiers.functions SMOreg SMOreg

List of usage examples for weka.classifiers.functions SMOreg SMOreg

Introduction

In this page you can find the example usage for weka.classifiers.functions SMOreg SMOreg.

Prototype

SMOreg

Source Link

Usage

From source file:bi_project2.Classify.java

public Classify() {
    saver = new CSVSaver();
    smo = new SMOreg(); // create a new SMO classifier-create
}

From source file:crystalball.quant.QuantWekaSMOreg.java

License:Open Source License

public void forecast(BarData barData, int startBarId, int endBarId) {
    makeDataSet(barData, startBarId, endBarId);
    try {//from w ww . j  av a  2  s.c o m
        if (isLastBarOfHalfHour(barData, endBarId) || forecaster == null) {
            // new forecaster
            forecaster = new WekaForecaster();

            // set the targets we want to forecast. This method calls
            // setFieldsToLag() on the lag maker object for us
            forecaster.setFieldsToForecast("close");

            // set the underlying classifier as SMOreg (SVM)
            forecaster.setBaseForecaster(new SMOreg());

            forecaster.getTSLagMaker().setTimeStampField("id"); // date time stamp
            forecaster.getTSLagMaker().setMinLag(1);
            forecaster.getTSLagMaker().setMaxLag(78);

            // add a month of the year indicator field
            forecaster.getTSLagMaker().setAddMonthOfYear(false);

            // add a quarter of the year indicator field
            forecaster.getTSLagMaker().setAddQuarterOfYear(false);

            // build the model
            forecaster.buildForecaster(instances);
        }

        // prime the forecaster with enough recent historical data
        // to cover up to the maximum lag. 
        forecaster.primeForecaster(instances);

        // forecast for 6 units beyond the end of the training data
        List<List<NumericPrediction>> forecast = forecaster.forecast(predictSteps, System.out);

        // output the predictions. Outer list is over the steps; inner list is over
        // the targets
        for (int i = 0; i < predictSteps; i++) {
            List<NumericPrediction> predsAtStep = forecast.get(i);
            for (int j = 0; j < 1; j++) {
                NumericPrediction predForTarget = predsAtStep.get(j);
                predicted[i] = predForTarget.predicted();
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Prediccion.PrecidePasoNodo.java

License:Open Source License

void GenerarModeloPrediccion() {
    try {/*w w  w  .j a v a 2 s . c o  m*/
        if (pasos == null) {
            try {
                pasos = cargarDatos(0);
            } catch (ParseException ex) {
                Logger.getLogger(PrecidePasoNodo.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        //Defimimos el atributo que queremos predecir
        forecaster.setFieldsToForecast("Total");

        //Definimos el mtodo de prediccin a emplear. En este caso, regresin lineal porque 
        //en el artculo es el que mejor ha funcionado
        forecaster.setBaseForecaster(new SMOreg());

        //Defimimos el atributo que "marca" el tiempo y su peridiocidad
        forecaster.getTSLagMaker().setTimeStampField("Intervalo");
        forecaster.getTSLagMaker().setMinLag(1);
        forecaster.getTSLagMaker().setMaxLag(24);
        forecaster.getTSLagMaker().setPeriodicity(TSLagMaker.Periodicity.HOURLY);

        forecaster.buildForecaster(pasos, System.out);

    } catch (Exception ex) {
        Logger.getLogger(PrecidePasoNodo.class.getName()).log(Level.SEVERE, null, ex);
    }

}