Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.
Traverse trough dataset in reverse order
Dear All, I posted the script below a long time ago, it creates some attributes with values depending on previous data rows.
Is it possible to do the loop: for (Example e : exampleSet) { } in reverse order somehow?
import com.rapidminer.operator.Operator;
import com.rapidminer.Process;
import com.rapidminer.MacroHandler;
import com.rapidminer.tools.Ontology
ExampleSet exampleSet = operator.getInput(ExampleSet.class);
Attribute sum = AttributeFactory.createAttribute("sum", Ontology.REAL);
exampleSet.getExampleTable().addAttribute(sum);
exampleSet.getAttributes().addRegular(sum);
Attribute avg = AttributeFactory
.createAttribute("avg", Ontology.REAL);
exampleSet.getExampleTable().addAttribute(avg);
exampleSet.getAttributes().addRegular(avg);
last = 0;
n = 0;
for (Example e : exampleSet) {
e["sum"] = e["abs"] + last; // iterate over an attribute using the name of the attribute
last = e["sum"];
n++;
e["avg"] = last / n;
}
return exampleSet
Is it possible to do the loop: for (Example e : exampleSet) { } in reverse order somehow?
import com.rapidminer.operator.Operator;
import com.rapidminer.Process;
import com.rapidminer.MacroHandler;
import com.rapidminer.tools.Ontology
ExampleSet exampleSet = operator.getInput(ExampleSet.class);
Attribute sum = AttributeFactory.createAttribute("sum", Ontology.REAL);
exampleSet.getExampleTable().addAttribute(sum);
exampleSet.getAttributes().addRegular(sum);
Attribute avg = AttributeFactory
.createAttribute("avg", Ontology.REAL);
exampleSet.getExampleTable().addAttribute(avg);
exampleSet.getAttributes().addRegular(avg);
last = 0;
n = 0;
for (Example e : exampleSet) {
e["sum"] = e["abs"] + last; // iterate over an attribute using the name of the attribute
last = e["sum"];
n++;
e["avg"] = last / n;
}
return exampleSet
0