# TMVA: More than 200 variables, will not calculate PCA!

**URL:** <https://root-forum.cern.ch/t/tmva-more-than-200-variables-will-not-calculate-pca/56078>\
**Category:** TMVA\
**Created:** [August 19, 2023, 11:29am UTC](https://root-forum.cern.ch/t/tmva-more-than-200-variables-will-not-calculate-pca/56078 "2023-08-19T11:29:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zenith378](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zenith378/32/31705_2.png) [@zenith378](https://root-forum.cern.ch/u/zenith378)\
**Post date:** [August 19, 2023, 11:29am UTC](https://root-forum.cern.ch/t/tmva-more-than-200-variables-will-not-calculate-pca/56078/1 "2023-08-19T11:29:17Z")

</div>

Hello ROOT experts,

I am currently working with TMVA for a regression analysis with a substantial number of variables. I’d like to perform a Principal Component Analysis (PCA) to account for potential correlations among these variables, using the option VarTransform=P.  
Regrettably, I encountered this message:

```auto
Factory : Train method: LD for Regression
                         : 
                         : Preparing the Principle Component (PCA) transformation...
                         : ----------------------------------------------------------------------------
                         : : More than 200 variables, will not calculate PCA!
                         : ----------------------------------------------------------------------------

```

Then the process results in a segmentation violation error.

I read that the transformation is facilitated through the TPrincipal library, which typically manages a significant volume of variables without issue. I am curious if there exists a global configuration option in TMVA that can be adjusted to circumvent this warning and enable the PCA calculation despite the large number of variables.

Many thanks.

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [August 19, 2023, 4:59pm UTC](https://root-forum.cern.ch/t/tmva-more-than-200-variables-will-not-calculate-pca/56078/2 "2023-08-19T16:59:05Z")

</div>

Hi @zenith378; maybe @moneta can help you with this.

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![Eddy\_Offermann](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eddy_offermann/32/25079_2.png) [@Eddy\_Offermann](https://root-forum.cern.ch/u/Eddy_Offermann)\
**Post date:** [August 20, 2023, 2:52pm UTC](https://root-forum.cern.ch/t/tmva-more-than-200-variables-will-not-calculate-pca/56078/3 "2023-08-20T14:52:27Z")

</div>

hi @zenith378,

Looking at the TMVA code I see several references that limit the number of variables to 200.

For instance in tmva/tmva/src hard-coded:

```auto
grep "More than " *

VariableDecorrTransform.cxx: << ": More than 200 variables, will not calculate decorrelation matrix "
VariableGaussTransform.cxx: << ": More than 200 variables, I hope you have enough memory!!!!" << Endl;
VariablePCATransform.cxx: << ": More than 200 variables, will not calculate PCA!" << Endl;

```

But in Config.cxx an attempt is made to parametrize it:

```auto
fVariablePlotting.fMaxNumOfAllowedVariables = 200;

```

So although TPrincipal does not have this limitation, adapting TMVA does not seem trivial.

-Eddy

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [August 23, 2023, 1:16pm UTC](https://root-forum.cern.ch/t/tmva-more-than-200-variables-will-not-calculate-pca/56078/4 "2023-08-23T13:16:50Z")

</div>

Hi,  
As Eddy correctly noticed, 200 is an hard-coded limit inside the `VariablePCATransform.cxx` file. We can probably change this and make it configurable in TMVA, but for the time being the only way is that you edit the file and re-compile ROOT

Lorenzo
