use of org.knime.base.node.preproc.correlation.pmcc.PMCCPortObjectAndSpec in project knime-core by knime.
the class RankCorrelationComputeNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec in = (DataTableSpec) inSpecs[0];
final String[] includes;
if (m_columnFilterModel == null) {
m_columnFilterModel = createColumnFilterModel();
// auto-configure, no previous configuration
m_columnFilterModel.loadDefaults(in);
includes = m_columnFilterModel.applyTo(in).getIncludes();
setWarningMessage("Auto configuration: Using all suitable columns (in total " + includes.length + ")");
} else {
FilterResult applyTo = m_columnFilterModel.applyTo(in);
includes = applyTo.getIncludes();
}
if (includes.length == 0) {
throw new InvalidSettingsException("No columns selected");
}
return new PortObjectSpec[] { PMCCPortObjectAndSpec.createOutSpec(includes), new PMCCPortObjectAndSpec(includes), null };
}
use of org.knime.base.node.preproc.correlation.pmcc.PMCCPortObjectAndSpec in project knime-core by knime.
the class StandCronbachNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
PMCCPortObjectAndSpec model = (PMCCPortObjectAndSpec) inData[0];
HalfDoubleMatrix mat = model.getCorrelationMatrix();
double sum = 0;
double count = 0;
for (int i = 0; i < mat.getRowCount(); i++) {
for (int j = i + 1; j < mat.getRowCount(); j++) {
if (Double.isNaN(mat.get(i, j))) {
throw new IOException("No NAN values supported for the calculation, " + "try using an alternative correlation meassure");
}
sum += mat.get(i, j);
count++;
}
}
double mean = sum / count;
double cronbach = (mat.getRowCount() * mean) / (1 + (mat.getRowCount() - 1) * mean);
BufferedDataContainer out = exec.createDataContainer(getDataTableSpec());
RowKey k = new RowKey("Cronbach");
DataRow r = new DefaultRow(k, new DoubleCell(cronbach));
out.addRowToTable(r);
out.close();
return new BufferedDataTable[] { out.getTable() };
}
use of org.knime.base.node.preproc.correlation.pmcc.PMCCPortObjectAndSpec in project knime-core by knime.
the class CorrelationComputeNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
final BufferedDataTable in = (BufferedDataTable) inData[0];
final DataTableSpec inSpec = in.getDataTableSpec();
ColumnRearranger filteredTableRearranger = new ColumnRearranger(inSpec);
String[] includeNames = m_columnFilterModel.applyTo(inSpec).getIncludes();
filteredTableRearranger.keepOnly(includeNames);
final BufferedDataTable filteredTable = exec.createColumnRearrangeTable(in, filteredTableRearranger, exec.createSilentSubExecutionContext(0.0));
final DataTableSpec filteredTableSpec = filteredTable.getDataTableSpec();
double progStep1 = 0.48;
double progStep2 = 0.48;
double progFinish = 1.0 - progStep1 - progStep2;
CorrelationComputer calculator = new CorrelationComputer(filteredTableSpec, m_maxPossValueCountModel.getIntValue());
exec.setMessage("Calculating table statistics");
ExecutionContext execStep1 = exec.createSubExecutionContext(progStep1);
calculator.calculateStatistics(filteredTable, execStep1);
execStep1.setProgress(1.0);
exec.setMessage("Calculating correlation values");
ExecutionMonitor execStep2 = exec.createSubExecutionContext(progStep2);
HalfDoubleMatrix correlationMatrix = calculator.calculateOutput(filteredTable, execStep2);
execStep2.setProgress(1.0);
exec.setMessage("Assembling output");
ExecutionContext execFinish = exec.createSubExecutionContext(progFinish);
PMCCPortObjectAndSpec pmccModel = new PMCCPortObjectAndSpec(includeNames, correlationMatrix);
BufferedDataTable out = pmccModel.createCorrelationMatrix(execFinish);
m_correlationTable = out;
String missValueString = calculator.getNumericMissingValueWarning(4);
StringBuilder warning = null;
if (missValueString != null) {
LOGGER.debug(calculator.getNumericMissingValueWarning(1000));
warning = new StringBuilder(missValueString);
}
String constantColString = calculator.getNumericConstantColumnPairs(4);
if (constantColString != null) {
LOGGER.debug(calculator.getNumericConstantColumnPairs(1000));
if (warning == null) {
warning = new StringBuilder(constantColString);
} else {
warning.append("\n");
warning.append(constantColString);
}
}
if (warning != null) {
setWarningMessage(warning.toString());
}
return new PortObject[] { out, pmccModel };
}
use of org.knime.base.node.preproc.correlation.pmcc.PMCCPortObjectAndSpec in project knime-core by knime.
the class CorrelationFilterNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
PMCCPortObjectAndSpec model = (PMCCPortObjectAndSpec) inData[0];
BufferedDataTable in = (BufferedDataTable) inData[1];
ColumnRearranger arranger = createColumnRearranger(in.getSpec(), model);
BufferedDataTable out = exec.createColumnRearrangeTable(in, arranger, exec);
return new BufferedDataTable[] { out };
}
use of org.knime.base.node.preproc.correlation.pmcc.PMCCPortObjectAndSpec in project knime-core by knime.
the class CorrelationFilterNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
PMCCPortObjectAndSpec modelS = (PMCCPortObjectAndSpec) inSpecs[0];
DataTableSpec dataS = (DataTableSpec) inSpecs[1];
if (m_threshold < 0.0 || m_threshold > 1.0) {
throw new IllegalArgumentException("No valid threshold: " + m_threshold);
}
ColumnRearranger arranger = createColumnRearranger(dataS, modelS);
if (arranger == null) {
return null;
}
return new DataTableSpec[] { arranger.createSpec() };
}
Aggregations