use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class StatisticCalculatorTest method createRandomTableWithMissingValues.
private static BufferedDataTable createRandomTableWithMissingValues(final int cols, final int rows) {
long currentTimeMillis = System.currentTimeMillis();
System.out.println("Using seed: " + currentTimeMillis);
Random random = new Random(currentTimeMillis);
DataTableSpecCreator creator = new DataTableSpecCreator();
for (int i = 0; i < cols; i++) {
creator.addColumns(new DataColumnSpecCreator("" + i, DoubleCell.TYPE).createSpec());
}
final BufferedDataContainer container = EXEC_CONTEXT.createDataContainer(creator.createSpec());
for (int i = 0; i < rows; i++) {
DataCell[] rowVals = new DataCell[cols];
for (int j = 0; j < cols; j++) {
rowVals[j] = random.nextDouble() > 0.66 ? new DoubleCell(random.nextDouble()) : DataType.getMissingCell();
}
container.addRowToTable(new DefaultRow(Integer.toString(i), rowVals));
if (i % 1000 == 0) {
System.out.println("Added row: " + i);
}
}
container.close();
return container.getTable();
}
use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class LogRegCoordinator method createCoeffStatisticsTableSpec.
static DataTableSpec createCoeffStatisticsTableSpec() {
DataTableSpecCreator tableSpecCreator = new DataTableSpecCreator();
tableSpecCreator.addColumns(new DataColumnSpecCreator("Logit", StringCell.TYPE).createSpec(), new DataColumnSpecCreator("Variable", StringCell.TYPE).createSpec(), new DataColumnSpecCreator("Coeff.", DoubleCell.TYPE).createSpec(), new DataColumnSpecCreator("Std. Err.", DoubleCell.TYPE).createSpec(), new DataColumnSpecCreator("z-score", DoubleCell.TYPE).createSpec(), new DataColumnSpecCreator("P>|z|", DoubleCell.TYPE).createSpec());
tableSpecCreator.setName("Coefficients and Statistics");
return tableSpecCreator.createSpec();
}
use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class SampleDataNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) {
DataColumnSpec[] colSpecs = new DataColumnSpec[m_minValues.length + 1];
int currentDim = 0;
for (int u = 0; u < m_clusterCount.length; u++) {
int dimCountInUniverse = m_uniSize[u];
Hashtable<String, String> annot = new Hashtable<String, String>();
annot.put("universe_name", "Universe_" + u);
for (int i = 0; i < dimCountInUniverse; i++) {
String n = "Universe_" + u + "_" + i;
DataType t = DoubleCell.TYPE;
DataColumnSpecCreator creator = new DataColumnSpecCreator(n, t);
creator.setProperties(new DataColumnProperties(annot));
colSpecs[currentDim++] = creator.createSpec();
}
}
String n = "Cluster Membership";
DataType t = StringCell.TYPE;
DataColumnSpecCreator creator = new DataColumnSpecCreator(n, t);
colSpecs[currentDim] = creator.createSpec();
DataColumnSpec[] centerColSpec = new DataColumnSpec[colSpecs.length - 1];
System.arraycopy(colSpecs, 0, centerColSpec, 0, centerColSpec.length);
return new DataTableSpec[] { new DataTableSpec(colSpecs), new DataTableSpec(centerColSpec) };
}
use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class TimerinfoNodeModel method createSpec.
private DataTableSpec createSpec() {
DataTableSpecCreator dtsc = new DataTableSpecCreator();
DataColumnSpec[] colSpecs = new DataColumnSpec[] { new DataColumnSpecCreator("Name", StringCell.TYPE).createSpec(), new DataColumnSpecCreator("Execution Time", LongCell.TYPE).createSpec(), new DataColumnSpecCreator("Execution Time since last Reset", LongCell.TYPE).createSpec(), new DataColumnSpecCreator("Execution Time since Start", LongCell.TYPE).createSpec(), new DataColumnSpecCreator("Nr of Executions since last Reset", IntCell.TYPE).createSpec(), new DataColumnSpecCreator("Nr of Executions since Start", IntCell.TYPE).createSpec(), new DataColumnSpecCreator("NodeID", StringCell.TYPE).createSpec(), new DataColumnSpecCreator("Classname", StringCell.TYPE).createSpec() };
dtsc.addColumns(colSpecs);
return dtsc.createSpec();
}
use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class SizeManager2NodeModel method appendSizeHandler.
/**
* Appends the given <code>SizeHandler</code> to the given
* <code>DataTableSpec</code> for the given column. If the spec
* already contains a SizeHandler, it will be removed and replaced by
* the new one.
* @param spec to which the SizeHandler is appended
* @param column for this column
* @param sizeHandler SizeHandler
* @return a new spec with SizeHandler
*/
static final DataTableSpec appendSizeHandler(final DataTableSpec spec, final String column, final SizeHandler sizeHandler) {
DataColumnSpec[] cspecs = new DataColumnSpec[spec.getNumColumns()];
for (int i = 0; i < cspecs.length; i++) {
DataColumnSpec cspec = spec.getColumnSpec(i);
DataColumnSpecCreator cr = new DataColumnSpecCreator(cspec);
if (cspec.getName().equals(column)) {
cr.setSizeHandler(sizeHandler);
} else {
// delete other SizeHandler
cr.setSizeHandler(null);
}
cspecs[i] = cr.createSpec();
}
return new DataTableSpec(cspecs);
}
Aggregations