🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Save values with AbstractAttribute.setValue

User: "viktorious"
New Altair Community Member
Updated by Jocelyn
Hey I need again some help,

i have some difficulties to understand the documentation.
i want simply to save some values in a column.
I the doc there is an example with "for (Example example : exampleSet) {...."
But i want (of course) to set some single values.
I have tried with for AbstractAttribute.setValue..without success. Can help anyone?
Thx in advance!
-Vik

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "Marco_Boeck"
    New Altair Community Member
    Hi,

    you need the example and the attribute you want to change the value of.
    Attribute attribute = exampleSet.getAttributes().get("nameOfAttribute")
    to get the attribute
    example.setValue(attribute, 85.0d);
    or
    example.setValue(attribute, "hello world!");
    to change the value.

    An alternative would be to create an ExampleSet yourself from scratch, however that's probably not what you need ;)
    MemoryExampleTable table = new MemoryExampleTable(listOfAttributes); // a list with Attributes
    // example of how to fill the double array
    doubleArray = new double[listOfAttributes.size()];
    // nominal attribute
    Attribute attNominal = listOfAttributes.get(0);
    doubleArray[0] = attNominal.getMapping().mapString("hello world!");
    // numerical attribute
    Attribute attNumerical = listOfAttributes.get(1);
    doubleArray[1] = 85.0d;
    table.addDataRow(new DoubleArrayDataRow(doubleArray)); // doubleArray is a double array with as many entries as the table has attributes
    ExampleSet exampleSet = table.createExampleSet();
    Regards,
    Marco