Search in sources :

Example 46 with PMMLPortObject

use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.

the class PMMLImport method init.

/**
 * @param pmmlDoc
 */
private void init(final PMMLDocument pmmlDoc) {
    PMMLDataDictionaryTranslator dictTrans = new PMMLDataDictionaryTranslator();
    dictTrans.initializeFrom(pmmlDoc);
    DataTableSpec tableSpec = dictTrans.getDataTableSpec();
    List<String> activeDerivedFields = dictTrans.getActiveDerivedFields();
    PMMLPortObjectSpecCreator specCreator = new PMMLPortObjectSpecCreator(tableSpec);
    PMMLMiningSchemaTranslator miningTrans = new PMMLMiningSchemaTranslator();
    miningTrans.initializeFrom(pmmlDoc);
    Set<String> activeFields = new LinkedHashSet<String>();
    List<String> miningFields = miningTrans.getActiveFields();
    /* If we have a model all active fields of the data dictionary
         * are passed through the mining schema. */
    activeFields.addAll(miningFields);
    activeFields.addAll(activeDerivedFields);
    specCreator.setLearningColsNames(new LinkedList<String>(activeFields));
    specCreator.addPreprocColNames(activeDerivedFields);
    specCreator.setTargetColsNames(miningTrans.getTargetFields());
    PMMLPortObjectSpec portObjectSpec = specCreator.createSpec();
    m_portObject = new PMMLPortObject(portObjectSpec, pmmlDoc);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PMMLMiningSchemaTranslator(org.knime.core.node.port.pmml.PMMLMiningSchemaTranslator) DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PMMLDataDictionaryTranslator(org.knime.core.node.port.pmml.PMMLDataDictionaryTranslator) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Example 47 with PMMLPortObject

use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.

the class PMMLReaderNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
    PMMLPortObject inPort = m_hasPMMLIn ? (PMMLPortObject) inData[0] : null;
    if (inPort != null) {
        TransformationDictionary dict = TransformationDictionary.Factory.newInstance();
        dict.setDerivedFieldArray(inPort.getDerivedFields());
        m_pmmlPort.addGlobalTransformations(dict);
        m_pmmlPort.moveGlobalTransformationsToModel();
    }
    return new PortObject[] { m_pmmlPort };
}
Also used : PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) TransformationDictionary(org.dmg.pmml.TransformationDictionaryDocument.TransformationDictionary) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject)

Example 48 with PMMLPortObject

use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.

the class DBAutoBinnerNodeModel method createPMMLPortObject.

private PMMLPortObject createPMMLPortObject(final DatabasePortObjectSpec inSpec, final DatabaseQueryConnectionSettings connectionSettings, final ExecutionMonitor exec) throws InvalidSettingsException {
    DataTableSpec dataTableSpec = inSpec.getDataTableSpec();
    DBAutoBinner autoBinner = new DBAutoBinner(m_settings, dataTableSpec);
    PMMLPreprocDiscretize pMMLPrepocDiscretize;
    try {
        pMMLPrepocDiscretize = autoBinner.createPMMLPrepocDiscretize(getCredentialsProvider(), connectionSettings, dataTableSpec);
        PMMLPortObject pmmlPortObject = DBAutoBinner.translate(pMMLPrepocDiscretize, dataTableSpec);
        return pmmlPortObject;
    } catch (SQLException e) {
        throw new InvalidSettingsException("Could not retrieve boundaries from database. Exception: " + e.getMessage(), e);
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) SQLException(java.sql.SQLException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DBAutoBinner(org.knime.base.node.io.database.binning.DBAutoBinner) PMMLPreprocDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)

Example 49 with PMMLPortObject

use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.

the class DBAutoBinnerNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    final DatabasePortObjectSpec dbSpec = (DatabasePortObjectSpec) inSpecs[0];
    DatabaseQueryConnectionSettings connectionSettings = dbSpec.getConnectionSettings(getCredentialsProvider());
    boolean suppCase = connectionSettings.getUtility().supportsCase();
    if (!suppCase) {
        if (m_settings.getFilterConfiguration().applyTo(dbSpec.getDataTableSpec()).getIncludes().length > 1) {
            throw new InvalidSettingsException("Database does not support \"CASE\". Please choose only one column.");
        }
    }
    if (connectionSettings.getRetrieveMetadataInConfigure()) {
        PMMLPortObject pmmlPortObject = createPMMLPortObject(dbSpec, connectionSettings, new ExecutionMonitor());
        DatabasePortObject databasePortObject = createDatabasePortObject(dbSpec, connectionSettings, pmmlPortObject);
        return new PortObjectSpec[] { databasePortObject.getSpec(), pmmlPortObject.getSpec() };
    }
    return new PortObjectSpec[] { null, null };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) ExecutionMonitor(org.knime.core.node.ExecutionMonitor)

Example 50 with PMMLPortObject

use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.

the class DBAutoBinnerNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    exec.setMessage("Retrieving metadata from database");
    final DatabasePortObject dbObject = (DatabasePortObject) inData[0];
    final DatabasePortObjectSpec inSpec = dbObject.getSpec();
    DatabaseQueryConnectionSettings connectionSettings = inSpec.getConnectionSettings(getCredentialsProvider());
    PMMLPortObject pmmlPortObject = createPMMLPortObject(inSpec, connectionSettings, exec);
    DatabasePortObject databasePortObject = createDatabasePortObject(inSpec, connectionSettings, pmmlPortObject);
    return new PortObject[] { databasePortObject, pmmlPortObject };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject)

Aggregations

PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)90 BufferedDataTable (org.knime.core.node.BufferedDataTable)53 DataTableSpec (org.knime.core.data.DataTableSpec)50 PortObject (org.knime.core.node.port.PortObject)47 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)35 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)25 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)21 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)18 ExecutionContext (org.knime.core.node.ExecutionContext)13 DataColumnSpec (org.knime.core.data.DataColumnSpec)12 DataRow (org.knime.core.data.DataRow)12 DerivedFieldMapper (org.knime.core.node.port.pmml.preproc.DerivedFieldMapper)11 StreamableOperator (org.knime.core.node.streamable.StreamableOperator)11 Node (org.w3c.dom.Node)10 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)9 IOException (java.io.IOException)8 DataCell (org.knime.core.data.DataCell)8 PMMLDocument (org.dmg.pmml.PMMLDocument)7 PMMLGeneralRegressionTranslator (org.knime.base.node.mine.regression.pmmlgreg.PMMLGeneralRegressionTranslator)7 StreamableFunction (org.knime.core.node.streamable.StreamableFunction)7