throw new Exception("[TSLagMaker] cannot process instance because the "
+ "structure\ndiffers from what we were configured with:\n\n"
+ message);
}
Instance result = source;
if (setAnyPeriodic) {
setPeriodicValues(result);
}
m_lastHistoricInstance = new DenseInstance(result);
m_lastHistoricInstance.setDataset(result.dataset());
if (m_extraneousAttributeRemover != null) {
m_extraneousAttributeRemover.input(result);
result = m_extraneousAttributeRemover.output();
}
if (m_artificialTimeMaker != null) {
m_artificialTimeMaker.input(result);
result = m_artificialTimeMaker.output();
// set the correct value here - it can't be done after the fact because
// of other filters that create the product of time and something else.
if (incrementTime) {
double newTime = m_lastTimeValue + 1;
int timeIndex = result.dataset().attribute(m_timeStampName).index();
result.setValue(timeIndex, newTime);
m_lastTimeValue = newTime;
}
} else {
// if we have a genuine time stamp field then make sure
// that we keep track of the most recent time value
if (m_adjustForTrends) {
int timeIndex = result.dataset().attribute(m_timeStampName).index();
if (incrementTime) {
double newTime = weka.classifiers.timeseries.core.Utils
.advanceSuppliedTimeValue(m_lastTimeValue, m_dateBasedPeriodicity);
// default to add the delta
/*
* double newTime = m_lastTimeValue +
* m_dateBasedPeriodicity.deltaTime();//m_deltaTime; Date d = new
* Date((long)m_lastTimeValue); Calendar c = new GregorianCalendar();
* c.setTime(d); if (m_dateBasedPeriodicity == Periodicity.MONTHLY) {
* c.add(Calendar.MONTH, 1); newTime = (double)c.getTimeInMillis(); }
* else if (m_dateBasedPeriodicity == Periodicity.WEEKLY) {
* c.add(Calendar.WEEK_OF_YEAR, 1); newTime =
* (double)c.getTimeInMillis(); } else if (m_dateBasedPeriodicity ==
* Periodicity.QUARTERLY) { c.add(Calendar.MONTH, 3); newTime =
* (double)c.getTimeInMillis(); } else if (m_dateBasedPeriodicity ==
* Periodicity.DAILY) { c.add(Calendar.DAY_OF_YEAR, 1); newTime =
* (double)c.getTimeInMillis(); }
*/
result.setValue(timeIndex, newTime);
// if (!temporary) {
m_lastTimeValue = newTime;
// }
} else {
// if (!temporary) {
// if we have a value, just store it
if (!result.isMissing(timeIndex)) {
m_lastTimeValue = result.value(timeIndex);
}/*
* else { System.err.println("*****WARNING missing time..."); }
*/
// }
}