Search in sources :

Example 21 with ModelContent

use of org.knime.core.node.ModelContent in project knime-core by knime.

the class DecisionTreeLearnerNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    ModelContent decisionTreeModel = new ModelContent(SAVE_INTERNALS_FILE_NAME);
    m_decisionTree.saveToPredictorParams(decisionTreeModel, true);
    File internalsFile = new File(nodeInternDir, SAVE_INTERNALS_FILE_NAME);
    BufferedOutputStream out = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(internalsFile)));
    decisionTreeModel.saveToXML(out);
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) ModelContent(org.knime.core.node.ModelContent) FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 22 with ModelContent

use of org.knime.core.node.ModelContent in project knime-core by knime.

the class LinReg2LearnerNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    ModelContent content = new ModelContent(CFG_SETTINGS);
    ModelContentWO specContent = content.addModelContent(CFG_SPEC);
    m_content.getSpec().getDataTableSpec().save(specContent);
    ModelContentWO parContent = content.addModelContent(CFG_LinReg2_CONTENT);
    m_content.save(parContent);
    File outFile = new File(internDir, FILE_SAVE);
    content.saveToXML(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(outFile))));
    File dataFile = new File(internDir, FILE_DATA);
    DataContainer.writeToZip(m_rowContainer, dataFile, exec);
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) ModelContent(org.knime.core.node.ModelContent) ModelContentWO(org.knime.core.node.ModelContentWO) FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 23 with ModelContent

use of org.knime.core.node.ModelContent in project knime-core by knime.

the class DecisionTreeLearnerNodeModel2 method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    ModelContent decisionTreeModel = new ModelContent(SAVE_INTERNALS_FILE_NAME);
    m_decisionTree.saveToPredictorParams(decisionTreeModel, true);
    File internalsFile = new File(nodeInternDir, SAVE_INTERNALS_FILE_NAME);
    BufferedOutputStream out = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(internalsFile)));
    decisionTreeModel.saveToXML(out);
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) ModelContent(org.knime.core.node.ModelContent) FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 24 with ModelContent

use of org.knime.core.node.ModelContent in project knime-core by knime.

the class NaiveBayesLearnerNodeModel2 method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
    final File modelFile = new File(nodeInternDir, CFG_DATA);
    final FileOutputStream modelOut = new FileOutputStream(modelFile);
    final ModelContent myModel = new ModelContent(CFG_DATA_MODEL);
    m_model.savePredictorParams(myModel);
    myModel.saveToXML(modelOut);
}
Also used : ModelContent(org.knime.core.node.ModelContent) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Example 25 with ModelContent

use of org.knime.core.node.ModelContent in project knime-core by knime.

the class AbstractSimplePortObjectSpec method equals.

/**
 * {@inheritDoc}
 */
@Override
public boolean equals(final Object ospec) {
    if (ospec == this) {
        return true;
    }
    if (ospec == null) {
        return false;
    }
    if (!this.getClass().equals(ospec.getClass())) {
        return false;
    }
    ModelContent tcont = new ModelContent("ignored");
    ModelContent ocont = new ModelContent("ignored");
    this.save(tcont);
    ((AbstractSimplePortObjectSpec) ospec).save(ocont);
    return tcont.equals(ocont);
}
Also used : ModelContent(org.knime.core.node.ModelContent)

Aggregations

ModelContent (org.knime.core.node.ModelContent)29 File (java.io.File)15 FileOutputStream (java.io.FileOutputStream)15 BufferedOutputStream (java.io.BufferedOutputStream)12 GZIPOutputStream (java.util.zip.GZIPOutputStream)11 ModelContentWO (org.knime.core.node.ModelContentWO)7 JComponent (javax.swing.JComponent)6 ModelContentOutPortView (org.knime.core.node.workflow.ModelContentOutPortView)6 DataTableSpec (org.knime.core.data.DataTableSpec)3 ZipEntry (java.util.zip.ZipEntry)2 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)2 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 LinkedHashSet (java.util.LinkedHashSet)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)1 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)1