how can I do PCA on a table ?

I have a 3000 x 18 table containing 18 variables (one per column) of both numerical and categorical type (6 categorical).
I would liket to do PCA on the whole dataset
but the command
[coeff,score]=pca(mytable) does not work.
any idea on how to proceed ?

 採用された回答

Star Strider
Star Strider 2019 年 5 月 30 日

2 投票

The pca function only accepts single-precision or double-precision numerical arrays. You most likely need to use the table2array (link) function first, to get the numeric data out of your table and into a form that pca can use.

4 件のコメント

LO
LO 2019 年 6 月 7 日
Thanks,
I have tried and I got this error message
Error using pca (line 168)
The value of X must not be an object.
the table is now in string format. this is not suitable for the PCA function.
I tried to convert the matrix to numerical values using str2num but I got the message "Input must be a character vector or string scalar"
Star Strider
Star Strider 2019 年 6 月 7 日
Unless you can extract just the numerical values, you cannot use the pca function.
LO
LO 2019 年 6 月 7 日
Got it, thanks. I thought categorical PCA was also possible with MATLAB.
Perhaps the answer is no. I will try to then exclude the non numerical variables and see if it works !
Star Strider
Star Strider 2019 年 6 月 7 日
It should work in that instance.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

タグ

質問済み:

LO
2019 年 5 月 30 日

コメント済み:

2019 年 6 月 7 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by