本文整理汇总了Java中org.knime.core.data.container.ColumnRearranger类的典型用法代码示例。如果您正苦于以下问题:Java ColumnRearranger类的具体用法?Java ColumnRearranger怎么用?Java ColumnRearranger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnRearranger类属于org.knime.core.data.container包,在下文中一共展示了ColumnRearranger类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData,
final ExecutionContext exec) throws Exception {
if (m_columnFilterModel.applyTo(inData[0].getDataTableSpec())
.getIncludes().length == 0) {
throw new InvalidSettingsException("No Columns selected!");
}
final ColumnRearranger c =
createResRearranger(inData[0].getDataTableSpec());
final BufferedDataTable out =
exec.createColumnRearrangeTable(inData[0], c, exec);
return new BufferedDataTable[] { out };
}
示例2: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* {@inheritDoc} Variance based score.
*/
@Override
protected ColumnRearranger createResRearranger(final DataTableSpec inSpec)
throws InvalidSettingsException {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
final DataColumnSpec newColSpec =
new DataColumnSpecCreator("Variance Score", DoubleCell.TYPE)
.createSpec();
// utility object that performs the calculation
rearranger.append(new SingleCellFactory(newColSpec) {
final List<Integer> m_selectedIndicies =
NodeTools.getIndicesFromFilter(inSpec, m_columnFilterModel,
DoubleValue.class, VarianceScorerNodeModel.class);
@Override
public DataCell getCell(final DataRow row) {
return new DoubleCell(MathUtils.variance(
NodeTools.toDoubleArray(row, m_selectedIndicies)));
}
});
return rearranger;
}
示例3: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
private ColumnRearranger createResRearranger(final DataTableSpec inSpec) {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
rearranger.append(new CellFactory() {
@Override
public void setProgress(final int curRowNr, final int rowCount,
final RowKey lastKey, final ExecutionMonitor exec) {
exec.setProgress((double) curRowNr / rowCount);
}
@Override
public DataColumnSpec[] getColumnSpecs() {
return new DataColumnSpec[] {
new DataColumnSpecCreator("Graph Density Score",
DoubleCell.TYPE).createSpec() };
}
@Override
public DataCell[] getCells(final DataRow row) {
return new DataCell[] { new DoubleCell(
m_dataPoints.get(row.getKey()).getDensity()) };
}
});
return rearranger;
}
示例4: execute
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* Execute the snippet.
*
* @param table
* the data table at the inport
* @param flowVariableRepository
* the flow variables at the inport
* @param exec
* the execution context to report progress
* @return the table for the output
* @throws InvalidSettingsException
* when settings are inconsistent with the table or the flow
* variables at the input
* @throws CanceledExecutionException
* when execution is canceled by the user
*/
public BufferedDataTable execute(final BufferedDataTable table,
final FlowVariableRepository flowVariableRepository,
final ExecutionContext exec) throws CanceledExecutionException,
InvalidSettingsException {
OutColList outFields = m_fields.getOutColFields();
if (outFields.size() > 0) {
ColumnRearranger rearranger = createRearranger(
table.getDataTableSpec(), flowVariableRepository,
table.getRowCount());
return exec.createColumnRearrangeTable(table, rearranger, exec);
} else {
CellFactory factory = new JavaSnippetCellFactory(this,
table.getDataTableSpec(), flowVariableRepository,
table.getRowCount());
for (DataRow row : table) {
factory.getCells(row);
}
return table;
}
}
示例5: createColumnRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* Creates the createColumnRearranger for the output tables.
*
* @param inSpec
* the tableSpec
* @param columnName
* the name of the class column.
* @return the createColumnRearranger with the appended
*/
private ColumnRearranger createColumnRearranger(final DataTableSpec inSpec,
final String columnName) {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
// append the
if (m_appendClassCollumnModel.getBooleanValue()) {
rearranger.append(createCellFactory(
m_customClassCollumnNameModel.getStringValue()));
} else {
final int classLabelColIdx = inSpec.findColumnIndex(columnName);
rearranger.replace(createCellFactory(columnName), classLabelColIdx);
}
return rearranger;
}
示例6: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
private ColumnRearranger createResRearranger(final DataTableSpec inSpec) {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
rearranger.append(new CellFactory() {
@Override
public void setProgress(final int curRowNr, final int rowCount,
final RowKey lastKey, final ExecutionMonitor exec) {
exec.setProgress((double) curRowNr / rowCount);
}
@Override
public DataColumnSpec[] getColumnSpecs() {
return new DataColumnSpec[] {
new DataColumnSpecCreator("Potential", DoubleCell.TYPE)
.createSpec(),
new DataColumnSpecCreator("Entropy", DoubleCell.TYPE)
.createSpec(),
new DataColumnSpecCreator("Score", DoubleCell.TYPE)
.createSpec() };
}
@Override
public DataCell[] getCells(final DataRow row) {
return new DataCell[] {
new DoubleCell(
m_dataPoints.get(row.getKey()).getPotential()),
new DoubleCell(
m_dataPoints.get(row.getKey()).getEntropy()),
new DoubleCell(
m_dataPoints.get(row.getKey()).getScore()) };
}
});
return rearranger;
}
示例7: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected ColumnRearranger createResRearranger(final DataTableSpec inSpec)
throws InvalidSettingsException {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
final DataColumnSpec newColSpec =
new DataColumnSpecCreator("Least Confident Score",
DoubleCell.TYPE).createSpec();
final List<Integer> selectedColumns =
NodeTools.getIndicesFromFilter(inSpec, m_columnFilterModel,
DoubleValue.class, EntropyScorerNodeModel.class);
if (selectedColumns.size() < 2) {
throw new InvalidSettingsException(
"Need at least 2 DoubleType columns!");
}
// utility object that calculates the difference between top scoring
// class predictions
rearranger.append(new SingleCellFactory(newColSpec) {
@Override
public DataCell getCell(final DataRow row) {
final double[] values =
NodeTools.toDoubleArray(row, selectedColumns);
Arrays.sort(values);
// make sure the distribution is valid,
if (!MathUtils.checkDistribution(values)) {
AbstractUncertaintyNodeModel
.handleInvalidDistribution(row.getKey());
}
// to make this node compatible with the other uncertainty
// scorers we invert the value.
return new DoubleCell(1 - (values[values.length - 1]));
}
});
return rearranger;
}
示例8: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
@Override
protected ColumnRearranger createResRearranger(final DataTableSpec inSpec)
throws InvalidSettingsException {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
final DataColumnSpec newColSpec =
new DataColumnSpecCreator("Margin Score", DoubleCell.TYPE)
.createSpec();
final List<Integer> legalColumns =
NodeTools.getIndicesFromFilter(inSpec, m_columnFilterModel,
DoubleValue.class, EntropyScorerNodeModel.class);
if (legalColumns.size() < 2) {
throw new InvalidSettingsException(
"Need at least 2 DoubleType columns!");
}
// utility object that calculates the difference between top scoring
// class predictions
rearranger.append(new SingleCellFactory(newColSpec) {
@Override
public DataCell getCell(final DataRow row) {
final double[] values =
NodeTools.toDoubleArray(row, legalColumns);
Arrays.sort(values);
// make sure the distribution is valid,
if (!MathUtils.checkDistribution(values)) {
AbstractUncertaintyNodeModel
.handleInvalidDistribution(row.getKey());
}
// invert the value to ensure compatibility with the other
// scorers.
return new DoubleCell(1 - (values[values.length - 1]
- values[values.length - 2]));
}
});
return rearranger;
}
示例9: execute
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData,
final ExecutionContext exec) throws Exception {
final ColumnRearranger c =
createResRearranger(inData[0].getDataTableSpec());
final BufferedDataTable out =
exec.createColumnRearrangeTable(inData[0], c, exec);
return new BufferedDataTable[] { out };
}
示例10: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* {@inheritDoc} Entropy based uncertainty scoring.
*/
@Override
protected ColumnRearranger createResRearranger(final DataTableSpec inSpec)
throws InvalidSettingsException {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
final DataColumnSpec newColSpec =
new DataColumnSpecCreator("Uncertainty Distribution Score",
DoubleCell.TYPE).createSpec();
// utility object that performs the calculation
rearranger.append(new SingleCellFactory(newColSpec) {
private final int m_explorationIndex = inSpec
.findColumnIndex(m_explorationColumnModel.getStringValue());
private final int m_exploitationIndex = inSpec.findColumnIndex(
m_exploitationColumnModel.getStringValue());
private final double m_exFactor =
m_exploitationFactorModel.getDoubleValue();
@Override
// Get the scores weighted by the exploration factor
public DataCell getCell(final DataRow row) {
final double explorationScore;
final double exploitationScore;
try {
explorationScore = m_exFactor
* ((DoubleValue) row.getCell(m_explorationIndex))
.getDoubleValue();
exploitationScore = (1 - m_exFactor)
* ((DoubleValue) row.getCell(m_exploitationIndex))
.getDoubleValue();
} catch (final ClassCastException e) {
throw new IllegalArgumentException(
"Encountered missing value at row: "
+ row.getKey());
}
return new DoubleCell(exploitationScore + explorationScore);
}
});
return rearranger;
}
示例11: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
private ColumnRearranger createResRearranger(final DataTableSpec inSpec) {
final ColumnRearranger rearranger = new ColumnRearranger(inSpec);
rearranger.append(new CellFactory() {
@Override
public void setProgress(final int curRowNr, final int rowCount,
final RowKey lastKey, final ExecutionMonitor exec) {
exec.setProgress((double) curRowNr / rowCount);
}
@Override
public DataColumnSpec[] getColumnSpecs() {
return new DataColumnSpec[] {
new DataColumnSpecCreator("Node Potential Score",
DoubleCell.TYPE).createSpec() };
}
@Override
public DataCell[] getCells(final DataRow row) {
return new DataCell[] { new DoubleCell(
m_dataPoints.get(row.getKey()).getPotential()) };
}
});
return rearranger;
}
示例12: createRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/** The rearranger is the working horse for creating the ouput table. */
private ColumnRearranger createRearranger(final DataTableSpec spec,
final FlowVariableRepository flowVariableRepository,
final int rowCount) throws InvalidSettingsException {
int offset = spec.getNumColumns();
CellFactory factory = new JavaSnippetCellFactory(this, spec,
flowVariableRepository, rowCount);
ColumnRearranger c = new ColumnRearranger(spec);
// add factory to the column rearranger
c.append(factory);
// define which new columns do replace others
OutColList outFields = m_fields.getOutColFields();
for (int i = outFields.size() - 1; i >= 0; i--) {
OutCol field = outFields.get(i);
int index = spec.findColumnIndex(field.getKnimeName());
if (index >= 0) {
if (field.getReplaceExisting()) {
c.remove(index);
c.move(offset + i - 1, index);
} else {
throw new InvalidSettingsException("Field \""
+ field.getJavaName() + "\" is configured to "
+ "replace no existing columns.");
}
}
}
return c;
}
示例13: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* Creates the column rearranger that performs the calculation.
*
* @param inPutSpec
* the input spec of the node
* @return A column rearranger that implements the exploitation strategy
* @throws InvalidSettingsException
* if invalid settings are detected.
*/
protected abstract ColumnRearranger createResRearranger(
final DataTableSpec inPutSpec) throws InvalidSettingsException;
示例14: createResRearranger
import org.knime.core.data.container.ColumnRearranger; //导入依赖的package包/类
/**
* Creates the column rearranger that performs the calculation.
*
* @param inPutSpec
* the input spec of the node
* @return A column rearranger that implements the combination strategy
* @throws InvalidSettingsException
* in case of invalid settings
*/
protected abstract ColumnRearranger createResRearranger(
final DataTableSpec inPutSpec) throws InvalidSettingsException;