* @param forecaster the forecaster to apply the configuration to
* @throws Exception if a problem occurs
*/
public void applyToForecaster(WekaForecaster forecaster) throws Exception {
if (forecaster != null) {
TSLagMaker lagMaker = forecaster.getTSLagMaker();
// Set variance adjustment
lagMaker.setAdjustForVariance(m_adjustForVarianceCheckBox.isSelected());
int minLag = ((SpinnerNumberModel)m_minLagSpinner.getModel()).
getNumber().intValue();
int maxLag = ((SpinnerNumberModel)m_maxLagSpinner.getModel()).
getNumber().intValue();
if (m_useCustomLags.isSelected()) {
// set lag lengths from spinners
if (maxLag < minLag) {
throw new Exception("Maximum lag value must be greater than or equal to" +
" the minimum lag value");
}
if (m_instances != null && maxLag > m_instances.numInstances()) {
throw new Exception("The maximum lag can't exceed the number instances (" +
m_instances.numInstances() + ") in the data!");
}
lagMaker.setMinLag(minLag); lagMaker.setMaxLag(maxLag);
if (m_fineTuneLagsField.getText() != null &&
m_fineTuneLagsField.getText().length() > 0) {
lagMaker.setLagRange(m_fineTuneLagsField.getText());
}
// set up averaging from spinners
if (m_averageLongLags.isSelected()) {
lagMaker.setAverageConsecutiveLongLags(true);
int avLagsAfter = ((SpinnerNumberModel)m_averageLagsAfter.getModel()).
getNumber().intValue();
int numToAv = ((SpinnerNumberModel)m_numConsecutiveToAverage.getModel()).
getNumber().intValue();
if (avLagsAfter < minLag || avLagsAfter > maxLag) {
throw new Exception("Point at which to start lag averaging must " +
"lie between the minimum and maximum lag value.");
}
lagMaker.setAverageLagsAfter(avLagsAfter);
lagMaker.setNumConsecutiveLongLagsToAverage(numToAv);
} else {
lagMaker.setAverageConsecutiveLongLags(false);
}
} else {
lagMaker.setAverageConsecutiveLongLags(false);
lagMaker.setLagRange("");
}
// date-derived periodic customization
if (getCustomizeDateDerivedPeriodics()) {
// reset all to false
lagMaker.setAddAMIndicator(false); lagMaker.setAddDayOfWeek(false);
lagMaker.setAddMonthOfYear(false); lagMaker.setAddQuarterOfYear(false);
lagMaker.setAddWeekendIndicator(false); lagMaker.setAddDayOfMonth(false);
lagMaker.setAddNumDaysInMonth(false);
int[] selected = m_dateDerivedPeriodicSelector.getSelectedAttributes();
if (m_dateDerivedPeriodicsHeader != null) {
Map<String, ArrayList<CustomPeriodicTest>> custom =
new HashMap<String, ArrayList<CustomPeriodicTest>>();
for (int i = 0; i < selected.length; i++) {
int s = selected[i];
String name = m_dateDerivedPeriodicsHeader.attribute(s).name();
if (s < NUM_PREDEFINED_PERIODICS) {
if (name.equals("AM")) {
lagMaker.setAddAMIndicator(true);
}
if (name.equals("DayOfWeek")) {
lagMaker.setAddDayOfWeek(true);
}
if (name.equals("DayOfMonth")) {
lagMaker.setAddDayOfMonth(true);
}
if (name.equals("NumDaysInMonth")) {
lagMaker.setAddNumDaysInMonth(true);
}
if (name.equals("Weekend")) {
lagMaker.setAddWeekendIndicator(true);
}
if (name.equals("Month")) {
lagMaker.setAddMonthOfYear(true);
}
if (name.equals("Quarter")) {
lagMaker.setAddQuarterOfYear(true);
}
} else {
// remove the "c_"
name = name.replaceFirst("c_", "");
ArrayList<CustomPeriodicTest> selectedP =
m_customPeriodics.get(name);
custom.put(name, selectedP);
}
}
lagMaker.clearCustomPeriodics();
if (custom.size() > 0) {
lagMaker.setCustomPeriodics(custom);
}
}
}
// non-date primary periodic attribute
String ppfn = m_primaryPeriodicCombo.getSelectedItem().toString();
if (!ppfn.equals("<None>")) {
lagMaker.setPrimaryPeriodicFieldName(ppfn);
} else {
lagMaker.setPrimaryPeriodicFieldName("");
}
if (m_useOverlayData.isSelected() && m_overlayHeader != null &&
forecaster instanceof OverlayForecaster) {
int[] selected = m_overlaySelector.getSelectedAttributes();