# How do you train a machine on several datasets

**URL:** https://discourse.julialang.org/t/how-do-you-train-a-machine-on-several-datasets/85952
**Category:** Machine Learning
**Tags:** question
**Created:** [August 18, 2022, 8:35pm UTC](https://discourse.julialang.org/t/how-do-you-train-a-machine-on-several-datasets/85952 "2022-08-18T20:35:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hpaldan](https://avatars.discourse-cdn.com/v4/letter/h/8c91f0/32.png) [@hpaldan](https://discourse.julialang.org/u/hpaldan)
#### Post date: [August 18, 2022, 8:35pm UTC](https://discourse.julialang.org/t/how-do-you-train-a-machine-on-several-datasets/85952/1 "2022-08-18T20:35:09Z")

</div>

Hello!  
I’m new to the MLJ package but I gather that a fundamental aspect is that when you create a machine object you also define the data for the object. I’m in a situation where I have several very large dataframes that I would like to use to train a model and then I have separate datasets that I want to transform with the machine object to analyze them (It is about using unsupervised learning for anomaly detection).

So, can you add more training data to a machine object after it has been created and fit to the new data as well and it is possible to transform new data after fitting it?

---

<div class="post-metadata">

### Author: ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)
#### Post date: [August 21, 2022, 9:24pm UTC](https://discourse.julialang.org/t/how-do-you-train-a-machine-on-several-datasets/85952/2 "2022-08-21T21:24:49Z")

</div>

Thanks @hpaldan for your query and for giving MLJ a try.

To paraphrase your questions as I understand them:

1. Does MLJ support incremental learning (updating learned parameters based new data)?

2. Can a machine bound to an unsupervised model, trained on data `X`, be used to transform new data `Xnew`?

Do I understand correctly?

The answer to 1. is currently no. You can add _iterations_ to a model bound to an iterative model (eg, EvoTreesClassifier) but not new data.

The answer to 2. is yes and there are many examples around in the MLJ [learning resources](https://alan-turing-institute.github.io/MLJ.jl/dev/learning_mlj/). Here’s another:

```julia
using MLJ

PCA = @iload PCA pkg=MultivariateStats

X, y = @load_iris # a table and a vector

model = PCA(maxoutdim=2)
mach = machine(model, X) |> fit!

Xnew = (sepal_length = [6.4, 7.2, 7.4],
        sepal_width = [2.8, 3.0, 2.8],
        petal_length = [5.6, 5.8, 6.1],
        petal_width = [2.1, 1.6, 1.9],)

# training data transformed:
transform(mach, X)

# new data transformed:
transform(mach, Xnew)

```

If you are transitioning from another ML platform (eg, sk-learn or R) you may find this useful: [MLJ for Data Scientists in Two Hours](https://juliaai.github.io/DataScienceTutorials.jl/end-to-end/telco/)

---

<div class="post-metadata">

### Author: ![hpaldan](https://avatars.discourse-cdn.com/v4/letter/h/8c91f0/32.png) [@hpaldan](https://discourse.julialang.org/u/hpaldan)
#### Post date: [August 22, 2022, 6:18am UTC](https://discourse.julialang.org/t/how-do-you-train-a-machine-on-several-datasets/85952/3 "2022-08-22T06:18:09Z")

</div>

Yes! Thats exactly my questions thank you! Somehow I must have missed the examples with tranforming new data,I only saw examples where partition is used. I will look through the tutorial, thanks again!
