"How using NumericalMatrix in groovy"

sja
sja New Altair Community Member
edited November 2024 in Community Q&A
Hello,

I've written a groovy script to calculate a new matix from an exampleSet.

import com.rapidminer.operator.visualization.dependencies.NumericalMatrix;
import Jama.Matrix;

ExampleSet exampleSet = operator.getInput(ExampleSet.class);

double[][] data = new double[exampleSet.size()][exampleSet.getAttributes().size()];
int r = 0;
numberOfColumns = exampleSet.getAttributes().size();

String[] columnNames = new String[numberOfColumns];
operator.logNote("nb col"+numberOfColumns);

for (Example example : exampleSet) {
int c = 0;
for (Attribute attribute : exampleSet.getAttributes()) {
columnNames = attribute.getName();
data = example.getValue(attribute);
c++;
}
r++;
}
double[][] cooccMatrixEntries = new double[numberOfColumns][numberOfColumns];

for (int i = 0; i < cooccMatrixEntries.length; i++) {
for (int j = i; j < cooccMatrixEntries.length; j++) {
double cooc = getCooc(data, i, j);
cooccMatrixEntries = cooc;
cooccMatrixEntries = cooc;
}
}

Matrix mcooc = new Matrix(cooccMatrixEntries);
NumericalMatrix nummat = NumericalMatrix("Cooc matrix",columnNames, mcooc, false);

return nummat;
and I've got the following error :
Process failed: The scripting engine Groovy reported an error in the script: groovy.lang.MissingMethodException: No signature of method: Script1.NumericalMatrix() is applicable for argument types: (java.lang.String, [Ljava.lang.String;, Jama.Matrix, java.lang.Boolean).

I don't understand why because I've included
import com.rapidminer.operator.visualization.dependencies.NumericalMatrix;

Thanks for your help.

Steph

Tagged:

Answers

  • steffen
    steffen New Altair Community Member
    Hello Steph

    Finally a meaningful precise problem description  ;D

    My attempt to run the script failed because the method getCooc(...) was not available. So here is only a guess regarding your error:
    The word "new" is missing in the third-last line, hence the interpreter "thinks" that NumericalMatrix is the name of a method instead of a constructor.

    hope this was helpful,

    steffen
  • sja
    sja New Altair Community Member
    Hello,

    thanks for your help,

    It works now and it was a very stupid error.

    Steph.

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.