Search in sources :

Example 6 with PMMLPreprocDiscretize

use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize in project knime-core by knime.

the class AutoBinnerApplyNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    return new StreamableOperator() {

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            PMMLPreprocPortObject pmmlPort = (PMMLPreprocPortObject) ((PortObjectInput) inputs[0]).getPortObject();
            validatePMMLPort(pmmlPort);
            PMMLPreprocDiscretize op = (PMMLPreprocDiscretize) pmmlPort.getOperations().get(0);
            AutoBinnerApply applier = new AutoBinnerApply();
            ColumnRearranger core = applier.getRearranger(op, (DataTableSpec) inSpecs[1]);
            StreamableFunction func = core.createStreamableFunction(1, 0);
            func.runFinal(inputs, outputs, exec);
        }
    };
}
Also used : ExecutionContext(org.knime.core.node.ExecutionContext) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) PMMLPreprocPortObject(org.knime.core.node.port.pmml.preproc.PMMLPreprocPortObject) PMMLPreprocDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize) StreamableFunction(org.knime.core.node.streamable.StreamableFunction)

Example 7 with PMMLPreprocDiscretize

use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize in project knime-core by knime.

the class AutoBinner method init.

/**
 * Initialize instance and check if settings are consistent.
 */
private void init(final DataTableSpec inSpec) throws InvalidSettingsException {
    PMMLPreprocDiscretize op = createDisretizeOp(null);
    AutoBinnerApply applier = new AutoBinnerApply();
    m_tableOutSpec = applier.getOutputSpec(op, inSpec);
    m_pmmlOutSpec = new PMMLDiscretizePreprocPortObjectSpec(op);
}
Also used : PMMLDiscretizePreprocPortObjectSpec(org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretizePreprocPortObjectSpec) AutoBinnerApply(org.knime.base.node.preproc.autobinner.apply.AutoBinnerApply) PMMLPreprocDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)

Example 8 with PMMLPreprocDiscretize

use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize 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 9 with PMMLPreprocDiscretize

use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize in project knime-core by knime.

the class AutoBinner method init.

/**
 * Initialize instance and check if settings are consistent.
 */
private void init(final DataTableSpec inSpec) throws InvalidSettingsException {
    PMMLPreprocDiscretize op = createDisretizeOp(null);
    AutoBinnerApply applier = new AutoBinnerApply();
    m_tableOutSpec = applier.getOutputSpec(op, inSpec);
    m_pmmlOutSpec = new PMMLDiscretizePreprocPortObjectSpec(op);
}
Also used : PMMLDiscretizePreprocPortObjectSpec(org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretizePreprocPortObjectSpec) AutoBinnerApply(org.knime.base.node.preproc.autobinner.apply.AutoBinnerApply) PMMLPreprocDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)

Example 10 with PMMLPreprocDiscretize

use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize in project knime-core by knime.

the class AutoBinner method createDisretizeOp.

private PMMLPreprocDiscretize createDisretizeOp(final Map<String, double[]> edgesMap) {
    Map<String, List<PMMLDiscretizeBin>> binMap = createBins(edgesMap);
    List<String> names = new ArrayList<String>();
    Map<String, PMMLDiscretize> discretize = new HashMap<String, PMMLDiscretize>();
    for (String target : m_settings.getTargetColumn()) {
        String binnedCol = m_settings.getReplaceColumn() ? target : target + " [Binned]";
        names.add(binnedCol);
        discretize.put(binnedCol, new PMMLDiscretize(target, binMap.get(target)));
    }
    DisretizeConfiguration config = new DisretizeConfiguration(names, discretize);
    PMMLPreprocDiscretize op = new PMMLPreprocDiscretize(config);
    return op;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DisretizeConfiguration(org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration) ArrayList(java.util.ArrayList) PMMLDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretize) ArrayList(java.util.ArrayList) List(java.util.List) PMMLPreprocDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)

Aggregations

PMMLPreprocDiscretize (org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)13 AutoBinnerApply (org.knime.base.node.preproc.autobinner.apply.AutoBinnerApply)6 PMMLPreprocPortObject (org.knime.core.node.port.pmml.preproc.PMMLPreprocPortObject)5 PMMLDiscretizePreprocPortObjectSpec (org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretizePreprocPortObjectSpec)4 BufferedDataTable (org.knime.core.node.BufferedDataTable)4 PortObject (org.knime.core.node.port.PortObject)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 DisretizeConfiguration (org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration)3 PMMLDiscretize (org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretize)3 PMMLDiscretizePreprocPortObject (org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretizePreprocPortObject)3 DataTableSpec (org.knime.core.data.DataTableSpec)2 SQLException (java.sql.SQLException)1 DBAutoBinner (org.knime.base.node.io.database.binning.DBAutoBinner)1 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)1 ExecutionContext (org.knime.core.node.ExecutionContext)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)1