use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class DataColumnSpecListCellRenderer method createInvalidSpec.
/**
* @param colName the name of the invalid column
* @param type Type of the column
* @return the invalid {@link DataColumnSpec} for the given name and type
* @since 2.9
*/
public static DataColumnSpec createInvalidSpec(final String colName, final DataType type) {
DataColumnSpecCreator creator = new DataColumnSpecCreator(colName, type);
creator.setProperties(new DataColumnProperties(creaeteInvalidPropertiesMap()));
return creator.createSpec();
}
use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class TreeEnsembleLearner method getColumnStatisticTableSpec.
public static synchronized DataTableSpec getColumnStatisticTableSpec() {
if (COLUMN_STAT_TABLE_SPEC == null) {
DataColumnSpec[] cols = new DataColumnSpec[2 * REPORT_LEVEL];
for (int level = 0; level < REPORT_LEVEL; level++) {
String splitName = "#splits (level " + level + ")";
String candidateName = "#candidates (level " + level + ")";
cols[level] = new DataColumnSpecCreator(splitName, IntCell.TYPE).createSpec();
cols[REPORT_LEVEL + level] = new DataColumnSpecCreator(candidateName, IntCell.TYPE).createSpec();
}
COLUMN_STAT_TABLE_SPEC = new DataTableSpec("Tree Ensemble Column Statistic", cols);
}
return COLUMN_STAT_TABLE_SPEC;
}
use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class TreeNominalColumnDataTest method createPCATestData.
private static Pair<TreeNominalColumnData, TreeTargetNominalColumnData> createPCATestData(final TreeEnsembleLearnerConfiguration config) {
DataColumnSpec colSpec = new DataColumnSpecCreator("test-col", StringCell.TYPE).createSpec();
final String[] attVals = new String[] { "A", "B", "C", "D", "E" };
final String[] classes = new String[] { "T1", "T2", "T3" };
TreeNominalColumnDataCreator colCreator = new TreeNominalColumnDataCreator(colSpec);
DataColumnSpecCreator specCreator = new DataColumnSpecCreator("target-col", StringCell.TYPE);
specCreator.setDomain(new DataColumnDomainCreator(Arrays.stream(classes).distinct().map(s -> new StringCell(s)).toArray(i -> new StringCell[i])).createDomain());
DataColumnSpec targetSpec = specCreator.createSpec();
TreeTargetColumnDataCreator targetCreator = new TreeTargetNominalColumnDataCreator(targetSpec);
long rowKeyCounter = 0;
final int[][] classDistributions = new int[][] { { 40, 10, 10 }, { 10, 40, 10 }, { 20, 30, 10 }, { 20, 15, 25 }, { 10, 5, 45 } };
for (int i = 0; i < attVals.length; i++) {
for (int j = 0; j < classes.length; j++) {
for (int k = 0; k < classDistributions[i][j]; k++) {
RowKey key = RowKey.createRowKey(rowKeyCounter++);
colCreator.add(key, new StringCell(attVals[i]));
targetCreator.add(key, new StringCell(classes[j]));
}
}
}
final TreeNominalColumnData testColData = colCreator.createColumnData(0, config);
testColData.getMetaData().setAttributeIndex(0);
return Pair.create(testColData, (TreeTargetNominalColumnData) targetCreator.createColumnData());
}
use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class BlobsInSetCellWorkflowTest method createBDT.
/**
* {@inheritDoc}
*/
@Override
protected BufferedDataTable createBDT(final ExecutionContext exec) {
DataType t = ListCell.getCollectionType(DataType.getType(DataCell.class));
BufferedDataContainer c = exec.createDataContainer(new DataTableSpec(new DataColumnSpecCreator("Sequence", t).createSpec()));
for (int i = 0; i < ROW_COUNT; i++) {
String s = "someName_" + i;
// every other a ordinary string cell
Collection<DataCell> cells = new ArrayList<DataCell>();
for (int j = 0; j < LIST_SIZE * 2; j++) {
String val = "Row_" + i + "; Cell index " + j;
if (j % 2 == 0) {
cells.add(new LargeBlobCell(val, LargeBlobCell.SIZE_OF_CELL));
} else {
cells.add(new StringCell(val));
}
}
ListCell cell = CollectionCellFactory.createListCell(cells);
c.addRowToTable(new DefaultRow(s, cell));
}
c.close();
return c.getTable();
}
use of org.knime.core.data.DataColumnSpecCreator in project knime-core by knime.
the class RegressionTreeModel method getLearnAttributeSpec.
/**
* Get a table spec representing the learn attributes (not the target!). For ordinary data it is just a subset of
* the input columns, for bit vector data it's an expanded table spec with each bit represented by a StringCell
* column ("0" or "1"), whose name is "Bit x".
*
* @param learnSpec The original learn spec (which is also the return value for ordinary data)
* @return Such a learn attribute spec.
*/
public DataTableSpec getLearnAttributeSpec(final DataTableSpec learnSpec) {
final TreeType type = getType();
switch(type) {
case Ordinary:
return learnSpec;
case BitVector:
int nrAttributes = getMetaData().getNrAttributes();
DataColumnSpec[] colSpecs = new DataColumnSpec[nrAttributes];
for (int i = 0; i < nrAttributes; i++) {
colSpecs[i] = new DataColumnSpecCreator(TreeBitColumnMetaData.getAttributeName(i), StringCell.TYPE).createSpec();
}
return new DataTableSpec(colSpecs);
case ByteVector:
int nrAttr = getMetaData().getNrAttributes();
DataColumnSpec[] bvColSpecs = new DataColumnSpec[nrAttr];
for (int i = 0; i < nrAttr; i++) {
bvColSpecs[i] = new DataColumnSpecCreator(TreeNumericColumnMetaData.getAttributeName(i), IntCell.TYPE).createSpec();
}
return new DataTableSpec(bvColSpecs);
default:
throw new IllegalStateException("Type unknown (not implemented): " + type);
}
}
Aggregations