use of org.knime.base.node.preproc.correlation.pmcc.PMCCPortObjectAndSpec in project knime-core by knime.
the class CorrelationComputeNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec in = (DataTableSpec) inSpecs[0];
if (!in.containsCompatibleType(DoubleValue.class) && !in.containsCompatibleType(NominalValue.class)) {
throw new InvalidSettingsException("No double or nominal compatible columns in input");
}
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) };
}
use of org.knime.base.node.preproc.correlation.pmcc.PMCCPortObjectAndSpec in project knime-core by knime.
the class RankCorrelationComputeNodeModel 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 BufferedDataTable noMissTable = filterMissings(filteredTable, exec);
if (noMissTable.getRowCount() < filteredTable.getRowCount()) {
setWarningMessage("Rows containing missing values are filtered. Please resolve them" + " with the Missing Value node.");
}
double progStep1 = 0.48;
double progStep2 = 0.48;
double progFinish = 1.0 - progStep1 - progStep2;
SortedCorrelationComputer calculator = new SortedCorrelationComputer();
exec.setMessage("Generate ranking");
ExecutionContext execStep1 = exec.createSubExecutionContext(progStep1);
calculator.generateRank(noMissTable, execStep1);
execStep1.setProgress(1.0);
exec.setMessage("Calculating correlation values");
ExecutionContext execStep2 = exec.createSubExecutionContext(progStep2);
HalfDoubleMatrix correlationMatrix;
if (m_corrType.getStringValue().equals(CFG_SPEARMAN)) {
correlationMatrix = calculator.calculateSpearman(execStep2);
} else {
correlationMatrix = calculator.calculateKendallInMemory(m_corrType.getStringValue(), 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;
if (in.getRowCount() == 0) {
setWarningMessage("Empty input table! Generating missing values as correlation values.");
}
return new PortObject[] { out, pmccModel, calculator.getRankTable() };
}
Aggregations