本文整理汇总了Java中org.knime.core.data.DataTableSpec.getColumnSpec方法的典型用法代码示例。如果您正苦于以下问题:Java DataTableSpec.getColumnSpec方法的具体用法?Java DataTableSpec.getColumnSpec怎么用?Java DataTableSpec.getColumnSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.knime.core.data.DataTableSpec
的用法示例。
在下文中一共展示了DataTableSpec.getColumnSpec方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSpec
import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
* Set the input spec.
* @param spec the data table spec of the input
*/
public void setSpec(final DataTableSpec spec) {
DefaultListModel listModel = (DefaultListModel)getModel();
listModel.removeAllElements();
listModel.addElement(JavaSnippet.ROWID);
listModel.addElement(JavaSnippet.ROWINDEX);
listModel.addElement(JavaSnippet.ROWCOUNT);
for (int i = 0; i < spec.getNumColumns(); i++) {
DataColumnSpec colSpec = spec.getColumnSpec(i);
listModel.addElement(colSpec);
}
}
示例2: configure
import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
@Override
protected DataTableSpec[] configure(DataTableSpec[] inSpecs)
throws InvalidSettingsException
{
if(inSpecs==null || inSpecs.length!=2)
{
throw new InvalidSettingsException("expected two tables");
}
DataTableSpec spec1=inSpecs[0];
DataTableSpec spec2=inSpecs[1];
if(spec1.getNumColumns()!=spec2.getNumColumns())
{
throw new InvalidSettingsException("not the same number of columns:"+
"top:"+spec1.getNumColumns()+" bottom:"+spec2.getNumColumns()
);
}
for(int i=0;i< spec1.getNumColumns();++i)
{
DataColumnSpec col1=spec1.getColumnSpec(i);
int j=spec2.findColumnIndex(col1.getName());
if(j==-1) throw new InvalidSettingsException("Cannot find column "+col1.getName()+" in 2nd table");
DataColumnSpec col2=spec2.getColumnSpec(j);
if(!col1.getType().equals(col2.getType()))
{
throw new InvalidSettingsException("not the same type for columns "+col2.getName());
}
}
return new DataTableSpec[]{inSpecs[0]};
}
示例3: configure
import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs)
throws InvalidSettingsException {
final DataTableSpec trainingTableSpec = inSpecs[0];
final DataTableSpec testTableSpec = inSpecs[1];
// Check for class column
final DataColumnSpec classColSpec =
trainingTableSpec.getColumnSpec(m_classColumn.getStringValue());
if (classColSpec == null
|| !classColSpec.getType().isCompatible(NominalValue.class)) {
for (int i = trainingTableSpec.getNumColumns() - 1; i >= 0; i--) {
if (trainingTableSpec.getColumnSpec(i).getType()
.isCompatible(NominalValue.class)) {
m_classColumn.setStringValue(
trainingTableSpec.getColumnSpec(i).getName());
break;
} else if (i == 0) {
throw new InvalidSettingsException(
"Table contains no nominal attribute for classification.");
}
}
}
// Check if selected columns from the training table are also in the
// test table
// Also check compatibility of selected columns
final List<String> includedCols = m_columnSelection.getIncludeList();
for (final String col : includedCols) {
if (!trainingTableSpec.getColumnSpec(col).getType()
.isCompatible(DoubleValue.class)) {
throw new InvalidSettingsException(
"Selected columns must be compatible with DoubleValue!");
}
if (!testTableSpec.containsName(col)) {
throw new InvalidSettingsException(
"Selected columns need also be contained in the Test Table");
}
}
return createOutSpec(testTableSpec);
}
示例4: configure
import org.knime.core.data.DataTableSpec; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs)
throws InvalidSettingsException {
final DataTableSpec dataSpec = (DataTableSpec) inSpecs[DATA_INPORT];
// Check class
final DataColumnSpec colSpec =
dataSpec.getColumnSpec(m_classColumn.getStringValue());
if (colSpec == null
|| !colSpec.getType().isCompatible(NominalValue.class)) {
for (int i = dataSpec.getNumColumns() - 1; i >= 0; i--) {
if (dataSpec.getColumnSpec(i).getType()
.isCompatible(NominalValue.class)) {
m_classColumn.setStringValue(
dataSpec.getColumnSpec(i).getName());
break;
} else if (i == 0) {
throw new InvalidSettingsException(
"Table contains no nominal"
+ " attribute for classification.");
}
}
}
/*
* // Check input columns later used for training for (int i = 0; i <
* dataSpec.getNumColumns(); i++) { if
* (!(dataSpec.getColumnSpec(i).getType().isCompatible(DoubleValue.
* class) ||
* dataSpec.getColumnSpec(i).getType().isCompatible(IntValue.class) ||
* dataSpec.getColumnSpec(i).getType() .isCompatible(LongValue.class)))
* { throw new InvalidSettingsException(
* "The features used for training need to be numeric"); } }
*/
final List<String> featureNameList = m_columnSelection.getIncludeList();
final List<String> compatibleFeatures = new LinkedList<String>();
for (final String feature : featureNameList) {
final DataColumnSpec featureSpec = dataSpec.getColumnSpec(feature);
if (featureSpec.getType().isCompatible(DoubleValue.class)) {
compatibleFeatures.add(feature);
}
}
return new PortObjectSpec[] { null,
new KNFSTPortObjectSpec(compatibleFeatures) };
}