# UndefVarError: transform not defined

**URL:** <https://discourse.julialang.org/t/undefvarerror-transform-not-defined/90259>\
**Category:** General Usage\
**Created:** [November 14, 2022, 9:02pm UTC](https://discourse.julialang.org/t/undefvarerror-transform-not-defined/90259 "2022-11-14T21:02:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosieG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josieg/32/36221_2.png) [@JosieG](https://discourse.julialang.org/u/JosieG)\
**Post date:** [November 14, 2022, 9:02pm UTC](https://discourse.julialang.org/t/undefvarerror-transform-not-defined/90259/1 "2022-11-14T21:02:41Z")

</div>

I got this error and my code is

```julia
using MultivariateStats, RDatasets, Plots

# load iris dataset
iris = dataset("datasets", "iris")

# take half of the dataset
X = Matrix(iris[1:2:end,1:4])'
X_labels = Vector(iris[1:2:end,5])
M = fit(PCA, X; maxoutdim=2)
X_transform = transform(M,X)
PC1 = X_transform[1,:]
PC2 = X_transform[2,:]

```

Which package has transform function?

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [November 14, 2022, 9:27pm UTC](https://discourse.julialang.org/t/undefvarerror-transform-not-defined/90259/2 "2022-11-14T21:27:50Z")

</div>

It seems to be in MultivariateStats. But deprecated in favor of `predict`.  
So try `predict(M,X)`.
