# FactorAnalysis, KernelPCA in MultivariateStats.jl broken?

**URL:** https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064
**Category:** General Usage
**Tags:** question, package
**Created:** [February 14, 2018, 4:49pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064 "2018-02-14T16:49:27Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![burfel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/burfel/32/3314_2.png) [@burfel](https://discourse.julialang.org/u/burfel)
#### Post date: [February 14, 2018, 4:49pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/1 "2018-02-14T16:49:27Z")

</div>

It seems like some dimensionality reduction methods in _MultivariateStats.jl_ are broken.  
I tried the sample code given in the documentation:

```julia
# train a FactorAnalysis model
M22 = fit(FactorAnalysis, Xtr; maxoutdim=100)

```

> UndefVarError: FactorAnalysis not defined  
> include\_string(::String, ::String) at loading.jl:522  
> include\_string(::String, ::String, ::Int64) at eval.jl:30  
> include\_string(::Module, ::String, ::String, ::Int64, ::Vararg{Int64,N} where N) at eval.jl:34  
> (::Atom.##100#105{String,Int64,String})() at eval.jl:75  
> withpath(::Atom.##100#105{String,Int64,String}, ::String) at utils.jl:30  
> withpath(::Function, ::String) at eval.jl:38  
> hideprompt(::Atom.##99#104{String,Int64,String}) at repl.jl:59  
> macro expansion at eval.jl:73 [inlined]  
> (::Atom.##98#103{Dict{String,Any}})() at task.jl:80

```julia
# train a kernel PCA model
M3 = fit(KernelPCA, data_array; maxoutdim=100, inverse=true)

```

> UndefVarError: KernelPCA not defined  
> include\_string(::String, ::String) at loading.jl:522  
> include\_string(::String, ::String, ::Int64) at eval.jl:30  
> include\_string(::Module, ::String, ::String, ::Int64, ::Vararg{Int64,N} where N) at eval.jl:34  
> (::Atom.##100#105{String,Int64,String})() at eval.jl:75  
> withpath(::Atom.##100#105{String,Int64,String}, ::String) at utils.jl:30  
> withpath(::Function, ::String) at eval.jl:38  
> hideprompt(::Atom.##99#104{String,Int64,String}) at repl.jl:59  
> macro expansion at eval.jl:73 [inlined]  
> (::Atom.##98#103{Dict{String,Any}})() at task.jl:80

Could someone help out? Thanks.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [February 14, 2018, 5:18pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/2 "2018-02-14T17:18:13Z")

</div>

Please

1. quote your code with [backticks,](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530)

2. provide a self-contained minimal working example

---

<div class="post-metadata">

### Author: ![burfel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/burfel/32/3314_2.png) [@burfel](https://discourse.julialang.org/u/burfel)
#### Post date: [February 15, 2018, 11:36am UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/3 "2018-02-15T11:36:57Z")

</div>

1. The code is in backticks. The error messages aren’t.
2. Ok,  
Let’s generate a random array:

```julia
data = rand(100, 200)

```

and try to run (see documentation of package _MultivariateStats.jl_)

```julia
fit(FactorAnalysis, data; maxoutdim=100)

```

same for kernelPCA method

```julia
fit(KernelPCA, data; maxoutdim=100, inverse=true)

```

Both times I get the error messages

```julia
ERROR: UndefVarError: FactorAnalysis not defined

```

and

```julia
ERROR: UndefVarError: KernelPCA not defined

```

resp.

---

<div class="post-metadata">

### Author: ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)
#### Post date: [February 15, 2018, 2:33pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/4 "2018-02-15T14:33:21Z")

</div>

It’s because you are looking the doc of the master branch (“latest”) instead of the tagged release (“stable”) you have on your computer:

[http://multivariatestatsjl.readthedocs.io/en/stable/](http://multivariatestatsjl.readthedocs.io/en/stable/)

You can run `Pkg.checkout("MultivariateStats")` to get the latest version, but maybe there’s a reason why they haven’t released it yet.

---

<div class="post-metadata">

### Author: ![burfel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/burfel/32/3314_2.png) [@burfel](https://discourse.julialang.org/u/burfel)
#### Post date: [February 15, 2018, 2:58pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/5 "2018-02-15T14:58:44Z")

</div>

I have done that to get the latest version from the master, but it still isn’t working for me.

---

<div class="post-metadata">

### Author: ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)
#### Post date: [February 15, 2018, 7:48pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/6 "2018-02-15T19:48:54Z")

</div>

It works for me, make sure to restart your Julia after checking out so you load the new version.

---

<div class="post-metadata">

### Author: ![burfel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/burfel/32/3314_2.png) [@burfel](https://discourse.julialang.org/u/burfel)
#### Post date: [February 19, 2018, 2:52pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/7 "2018-02-19T14:52:45Z")

</div>

I have no clue what you do differently. I do 'Pkg.checkout(“MultivariateStats”) and `Pkg.status("MultivariateStats")` returns _- MultivariateStats 0.4.0+ master_.  
Once I restart Julia still returns the same error message…

---

<div class="post-metadata">

### Author: ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)
#### Post date: [February 19, 2018, 3:57pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/8 "2018-02-19T15:57:43Z")

</div>

I’m not sure what’s wrong, I’ve got 0.4.0+ too, check if you have this [file](https://github.com/JuliaStats/MultivariateStats.jl/blob/5fdf0ff43c2072e7fb68d4b67d8293372cc80577/src/kpca.jl) in you local .julia package folder, or try to force recompilation via `Base.compilecache("MultivariateStats")`. Last resort if renaming your package folder and reinstalling from scratch. Do you use v0.6.2 too ?

---

<div class="post-metadata">

### Author: ![burfel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/burfel/32/3314_2.png) [@burfel](https://discourse.julialang.org/u/burfel)
#### Post date: [February 19, 2018, 7:39pm UTC](https://discourse.julialang.org/t/factoranalysis-kernelpca-in-multivariatestats-jl-broken/9064/9 "2018-02-19T19:39:22Z")

</div>

Thanks @jonathanBieler! ` Base.compilecache("MultivariateStats")` did the job. It’s still not running in atom but only on the command line but at least that.  
I have renamed my package folder and reinstalled it from scratch over and over again for other packages and there are still some conflicts I can’t fix (eg `MultivariateStats.jl` clashes with `DifferentialEquations.jl` and with `RDatasets.jl` but I am currently trying to work around it).
