valor de temperatura próximo año Pronóstico semanal usando Weka

Chathurika Madhubhashini:

Soy nuevo en Weka. Tengo conjunto de datos semanales de las temperaturas en los últimos 10 años. El uso de ese conjunto de datos que voy a predecir la temperatura semanal withing próximo año. A continuación he adjuntado el código.

import java.io.*;

import java.util.List;
import weka.core.Instances;
import weka.filters.supervised.attribute.TSLagMaker;
import weka.classifiers.functions.GaussianProcesses;
import weka.classifiers.evaluation.NumericPrediction;
import weka.classifiers.timeseries.WekaForecaster;
import org.joda.time.*;

public class TimeSeriesExample {

public static void main(String[] args) {
    try {
        // path to data set

        Instances temp = new Instances(new BufferedReader(new FileReader("sample-data/weeklyMaxTemp.arff")));

        // new forecaster
        WekaForecaster forecaster = new WekaForecaster();

        // set the targets to forecast
        forecaster.setFieldsToForecast("BMxT");

        forecaster.setBaseForecaster(new GaussianProcesses());

        forecaster.getTSLagMaker().setTimeStampField("Date");

        // if there are not enough values in the recent history, return a
        // negative value indicating the steps to wait
        if (forecaster.getTSLagMaker().getMaxLag() > temp.size()) {
            System.out.println("Not enough recent values to make predictions.");
        }

        // add a week of the year indicator field
        forecaster.getTSLagMaker().setAddMonthOfYear(true);

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

        // build the model
        forecaster.buildForecaster(temp, System.out);
        forecaster.primeForecaster(temp);

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

        DateTime currentDt = getCurrentDateTime(forecaster.getTSLagMaker());

        // output the predictions
        for (int i = 0; i < 52; ++i) {
            List<NumericPrediction> predsAtStep = forecast.get(i);

            for (int j = 0; j < 1; ++j) {
                NumericPrediction predForTarget = predsAtStep.get(j);
                System.out.print(currentDt + " ->> " + predForTarget.predicted() + " ");
            }
            System.out.println();
            currentDt = advanceTime(forecaster.getTSLagMaker(), currentDt);
        }

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

private static DateTime getCurrentDateTime(TSLagMaker lm) throws Exception {
    return new DateTime((long) lm.getCurrentTimeStampValue());
}

private static DateTime advanceTime(TSLagMaker lm, DateTime dt) {
    return new DateTime((long) lm.advanceSuppliedTimeValue(dt.getMillis()));
}

}

52 medios número de semanas del año.

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

Cuando ejecuto el código que dan 52 valores semanales. Pero resultado es a partir de la semana 52th de los últimos datos del conjunto de datos de entrenamiento.

Esto significa que el último día de mi conjunto de datos de entrenamiento es 30.12.2015. Siguiente valor predicho debe estar en 01/06/2016. Pero conjunto de datos dado es a partir de las 52 semanas después.

¿Cómo puedo solucionar el problema.

Chathurika Madhubhashini:

Cambiado de la siguiente manera. Debemos aprovechar la corriente de fecha y hora por primera vez. resuelto

        DateTime currentDt = getCurrentDateTime(forecaster.getTSLagMaker());

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

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=330148&siteId=1
Recomendado
Clasificación