Damned Memory Example Table Change

leno
leno New Altair Community Member
edited November 5 in Community Q&A
Hi to all i have done a process that read a model and apply it to the input data that i give from source code.
My code after init():

      // setup your attribute list
        table = new MemoryExampleTable(master.ListaAttrib);
  //My ListaAttrib has 10 attribute

                input = utile.scalavettor(posx, posy, puntioriginali);
                table.addDataRow(new DoubleArrayDataRow(input));
                 
                exSet = table.createExampleSet();
                ioInput = new IOContainer(new IOObject[]{exSet});

                ioResult = master.process.run(ioInput);
                if (ioResult.getElementAt(0) instanceof ExampleSet) {
                    resultSet = (ExampleSet) ioResult.getElementAt(0);
                    e = resultSet.getExample(0);
                    predettoX = e.getPredictedLabel();
                }
The problem is that code is in a loop and at every iteration the MemoryExampleTable has more Attribute, because the apply model add label and confidence.
With a wrong number of attribute my model don't work.
I try removeattribute but seem that nothing change.

I need it for my Master Thesis everyone can help me?

Regards

Nello

Answers

  • Marco_Boeck
    Marco_Boeck New Altair Community Member
    Hi,

    if these attributes are used nowhere else, you can try this line:

    exampleSet.getExampleTable().removeAttribute(existingAttribute);
    However, if this attribute might occur in other exampleSets or other attribute instances might use the same
    ExampleTable's column, you should use this:

    exampleSet.getAttributes().remove(existingAttribute);
    Regards,
    Marco
  • dacamo76
    dacamo76 New Altair Community Member
    Hi leno,

    I don't quite understand your problem.
    Models don't take into account special attributes. When a model adds a label and confidence, they are added as special attributes. You can pass an example set with predictedLabel and confidence attributes to a model and they will be ignored. Are you sure the problem is with the model? Could it be another operator in your process?

    From what I can see in your example code, it looks like you are adding a single data row to an example set and applying a model on that single example.
    If there is no special need for you to apply a single example every time, you could just add all the examples to the example set and apply the model once on all the examples.
    This should alleviate your problem of looping and having an example set with extra attributes.