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);
}
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 };
}
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);
}
}
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 };
}
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 };
}
Aggregations