weka.gui.knowledgeflow.steps.TimeSeriesForecastingStepEditorDialog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timeseriesForecasting Show documentation
Show all versions of timeseriesForecasting Show documentation
Provides a time series forecasting environment for Weka. Includes a wrapper for Weka regression schemes that automates the process of creating lagged variables and date-derived periodic variables and provides the ability to do closed-loop forecasting. New evaluation routines are provided by a special evaluation module and graphing of predictions/forecasts are provided via the JFreeChart library. Includes both command-line and GUI user interfaces. Sample time series data can be found in ${WEKA_HOME}/packages/timeseriesForecasting/sample-data.
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/*
* TimeSeriesForecastingStepEditorDialog.java
* Copyright (C) 2010-2016 University of Waikato, Hamilton, New Zealand
*/
package weka.gui.knowledgeflow.steps;
import weka.classifiers.timeseries.WekaForecaster;
import weka.core.Instances;
import weka.gui.EnvironmentField;
import weka.gui.FileEnvironmentField;
import weka.gui.knowledgeflow.StepEditorDialog;
import weka.knowledgeflow.steps.TimeSeriesForecasting;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.List;
/**
* Editor dialog for the time series forecasting step
*
* @author Mark Hall
* @version $Revision: $
*/
public class TimeSeriesForecastingStepEditorDialog extends StepEditorDialog {
private static final long serialVersionUID = -12022508491905917L;
/** The underlying WekaForecaster */
protected WekaForecaster m_forecastingModel;
/** The header of the data used to train the forecaster */
protected Instances m_header;
/** The text area to display the model in */
protected JTextArea m_modelDisplay = new JTextArea(20, 60);
/** Handles the text field and file browser */
protected FileEnvironmentField m_filenameField = new FileEnvironmentField();
/** Label for the num steps field */
protected JLabel m_numStepsLab;
/** Number of steps to forecast */
protected EnvironmentField m_numStepsToForecast = new EnvironmentField();
/** Label for the artificial time stamp offset fields */
protected JLabel m_artificialLab;
/**
* Number of steps beyond the end of the training data that incoming
* historical priming data is
*/
protected EnvironmentField m_artificialOffset = new EnvironmentField();
/** Rebuild the forecaster ? */
protected JCheckBox m_rebuildForecasterCheck = new JCheckBox();
/** Label for the save forecaster field */
protected JLabel m_saveLab;
/** Text field for the filename to save the forecaster to */
protected FileEnvironmentField m_saveFilenameField =
new FileEnvironmentField();
protected void initialize() {
TimeSeriesForecasting forecaster = (TimeSeriesForecasting) getStepToEdit();
String loadFilename = forecaster.getFilename().toString();
if (!TimeSeriesForecasting.isEmpty(loadFilename)
&& !loadFilename.equals("-NONE-")) {
m_filenameField.setText(loadFilename);
loadModel();
} else {
String encodedForecaster = forecaster.getEncodedForecaster();
if (!TimeSeriesForecasting.isEmpty(encodedForecaster)
&& !encodedForecaster.equals("-NONE-")) {
try {
List