当前位置: 首页>>代码示例>>Java>>正文


Java DataTableSpec.getColumnSpec方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:pavloff-de,项目名称:spark4knime,代码行数:17,代码来源:ColumnList.java

示例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]};
	}
 
开发者ID:lindenb,项目名称:knime4bio,代码行数:30,代码来源:CatNodeModel.java

示例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);
}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:48,代码来源:LocalNoveltyScorerNodeModel.java

示例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) };
}
 
开发者ID:knime,项目名称:knime-activelearning,代码行数:51,代码来源:KNFSTLearnerNodeModel.java


注:本文中的org.knime.core.data.DataTableSpec.getColumnSpec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。