List of usage examples for weka.classifiers.functions GaussianProcesses GaussianProcesses
GaussianProcesses
From source file:gr.ntua.ece.cslab.panic.core.models.GaussianCurves.java
License:Apache License
public GaussianCurves() { super(); this.classifier = new GaussianProcesses(); }
From source file:org.datahack.forecast.BayExample.java
public static void main(String[] args) { try {//from ww w. ja v a 2 s . c o m // path to the Australian wine data included with the time series forecasting // package File output = File.createTempFile("tempWineData", "arff"); output.deleteOnExit(); String dataFileName = "sample-data/wine.arff"; URL resource = BayExample.class.getResource("/" + dataFileName); FileUtils.copyURLToFile(resource, output); String pathToWineData = output.getPath(); // load the wine data Instances wine = new Instances(new BufferedReader(new FileReader(pathToWineData))); InstanceQuery q = new InstanceQuery(); // new forecaster WekaForecaster forecaster = new WekaForecaster(); // set the targets we want to forecast. This method calls // setFieldsToLag() on the lag maker object for us forecaster.setFieldsToForecast("Fortified,Dry-white"); // default underlying classifier is SMOreg (SVM) - we'll use // gaussian processes for regression instead forecaster.setBaseForecaster(new GaussianProcesses()); forecaster.getTSLagMaker().setTimeStampField("Date"); // date time stamp forecaster.getTSLagMaker().setMinLag(1); forecaster.getTSLagMaker().setMaxLag(12); // monthly data // add a month 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(wine, System.out); // prime the forecaster with enough recent historical data // to cover up to the maximum lag. In our case, we could just supply // the 12 most recent historical instances, as this covers our maximum // lag period forecaster.primeForecaster(wine); // forecast for 12 units (months) beyond the end of the // training data List<List<NumericPrediction>> forecast = forecaster.forecast(12, System.out); // output the predictions. Outer list is over the steps; inner list is over // the targets for (int i = 0; i < 12; i++) { List<NumericPrediction> predsAtStep = forecast.get(i); for (int j = 0; j < 2; j++) { NumericPrediction predForTarget = predsAtStep.get(j); System.out.print("" + predForTarget.predicted() + " "); } System.out.println(); } // we can continue to use the trained forecaster for further forecasting // by priming with the most recent historical data (as it becomes available). // At some stage it becomes prudent to re-build the model using current // historical data. } catch (Exception ex) { ex.printStackTrace(); } }
From source file:org.datahack.forecast.TimeSeriesExample.java
public static void main(String[] args) { try {/*w w w . java2 s . c om*/ // path to the Australian wine data included with the time series forecasting // package File output = File.createTempFile("tempWineData", "arff"); output.deleteOnExit(); String dataFileName = "sample-data/parking344.arff"; URL resource = TimeSeriesExample.class.getResource("/" + dataFileName); FileUtils.copyURLToFile(resource, output); String pathToWineData = output.getPath(); // load the wine data Instances wine = new Instances(new BufferedReader(new FileReader(pathToWineData))); // new forecaster WekaForecaster forecaster = new WekaForecaster(); // set the targets we want to forecast. This method calls // setFieldsToLag() on the lag maker object for us forecaster.setFieldsToForecast("occupiedSpaces"); // default underlying classifier is SMOreg (SVM) - we'll use // gaussian processes for regression instead forecaster.setBaseForecaster(new GaussianProcesses()); forecaster.getTSLagMaker().setTimeStampField("eventTime"); // date time stamp forecaster.getTSLagMaker().setMinLag(1); forecaster.getTSLagMaker().setMaxLag(12); // monthly data // add a month 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(wine, System.out); // prime the forecaster with enough recent historical data // to cover up to the maximum lag. In our case, we could just supply // the 12 most recent historical instances, as this covers our maximum // lag period forecaster.primeForecaster(wine); // forecast for 12 units (months) beyond the end of the // training data List<List<NumericPrediction>> forecast = forecaster.forecast(12, System.out); // output the predictions. Outer list is over the steps; inner list is over // the targets for (int i = 0; i < 12; i++) { List<NumericPrediction> predsAtStep = forecast.get(i); for (int j = 0; j < 2; j++) { NumericPrediction predForTarget = predsAtStep.get(j); System.out.print("" + predForTarget.predicted() + " "); } System.out.println(); } // we can continue to use the trained forecaster for further forecasting // by priming with the most recent historical data (as it becomes available). // At some stage it becomes prudent to re-build the model using current // historical data. } catch (Exception ex) { ex.printStackTrace(); } }