# Saving all models when using X-Partitioner

**URL:** <https://forum.knime.com/t/saving-all-models-when-using-x-partitioner/34198>\
**Category:** KNIME Analytics Platform\
**Created:** [June 28, 2021, 4:11pm UTC](https://forum.knime.com/t/saving-all-models-when-using-x-partitioner/34198 "2021-06-28T16:11:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [June 28, 2021, 4:25pm UTC](https://forum.knime.com/t/saving-all-models-when-using-x-partitioner/34198/2 "2021-06-28T16:25:38Z")

</div>

Hi @DataDudes and welcome to the KNIME forum!

One way to save the models within a loop is to convert them at every iteration into an object using the “PMML to Cell” node:

> **[PMML To Cell](https://hub.knime.com/knime/extensions/org.knime.features.ensembles/latest/org.knime.ensembles.pmmlporttocell.PMMLPortToCellNodeFactory)**
>
> Converts the PMML Port to a table containing the PMML cell.

or the “Model to Cell” node:

> **[Model to Cell](https://hub.knime.com/knime/extensions/org.knime.features.ensembles/latest/org.knime.ensembles.modeltotable.ModelToTableNodeFactory)**
>
> Converts a model input into a single table cell.

Once a model is in cell format, you could add it into an extra column which is fed with a new model at every new loop iteration. Once all the iterations are finished, you should have a column with all the models saved. All these models can thus later be saved as a KNIME table using the table writer node:

> **[Table Writer](https://hub.knime.com/knime/extensions/org.knime.features.base/latest/org.knime.base.node.io.table.write.WriteTableNodeFactory)**
>
> This node writes a data table in an internal format to a file or a remote location (denoted by a URL), ready to be read with a Table Read node. Note that if th…

You could at any time, read this table with your stored models using the Table Reader node:

> **[Table Reader – scottF](https://hub.knime.com/knime/spaces/Examples/latest/01_Data_Access/01_Common_Type_Files/06_Table_Reader~ua4RudFCVylfMOzF)**
>
> These two Table Reader nodes read .table formatted files. .table is a KNIME proprietary format optimized for speed and file size. The first Table reader node o…

And at this stage, using a new loop, convert them again into PMML format using the cell to PMML node:

> **[Cell To PMML](https://hub.knime.com/knime/extensions/org.knime.features.ensembles/latest/org.knime.ensembles.tabletopmmlport.TableToPMMLNodeFactory)**
>
> Converts the PMML cell in the first Row to the PMML Port.

or the Cell to Model node:

> **[Cell To Model](https://hub.knime.com/knime/extensions/org.knime.features.ensembles/latest/org.knime.ensembles.tabletomodel.TableToModelNodeFactory)**
>
> Converts a single table cell into a model output.

and finally execute them with their associated predictor. This procedure works for most of the models, regardless of the algorithm you are using to generate the model (here XGBoost Tree Ensemble Learner).

Here below a possible implementation:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/7/8/78fe14bb9f55bb35f79f3b4b879cfe080e997a7d.png)

B.t.w. this is just a possible solution, but there are a few others …

Hope this helps.

Best

Ael

---

_[View the full topic](https://forum.knime.com/t/saving-all-models-when-using-x-partitioner/34198)._
