フィルターのクリア

fitcecoc and fitclinear are suitable for categorical data ?

1 回表示 (過去 30 日間)
Gorkem Akgul
Gorkem Akgul 2021 年 4 月 23 日
コメント済み: Jon Cherrie 2021 年 4 月 23 日
Hi,
I'm a newbie in Machine Learning and i'm trying to create a model on a kaggle dataset below.
The thing is i'd like to use k-fold crossvalidation on my model but i cannot use fifcecoc and fitclinear functions because they only accept numerical values whereas i also have some categorical ones.
Is there a way to use them with categorical data or i need to use cvpartition for k-fold crossvalidation due to the fact that my dataset not completely numerical ?
Also can i use regularization with categorical variables ?
  1 件のコメント
Jon Cherrie
Jon Cherrie 2021 年 4 月 23 日
You should be able to use fitcecoc with categorical predictors and k-fold cross-validation. Here is an example using the "carbig" data and k=5 folds:
load carbig.mat
t = table(Acceleration,Cylinders,Displacement,Horsepower,Mfg,Model_Year,MPG,Origin,Weight);
t.Mfg = categorical(cellstr(t.Mfg));
t.Cylinders = categorical(t.Cylinders);
t.Origin = categorical(cellstr(t.Origin));
m = fitcecoc(t,"Cylinders","KFold",5)
In this cases I get warning about unique class values (which I think means I have more folds than this data will tolerate), but I can see the categorical predictors in the output:
>> m
m =
ClassificationPartitionedECOC
CrossValidatedModel: 'ECOC'
PredictorNames: {'Acceleration' 'Displacement' 'Horsepower' 'Mfg' 'Model_Year' 'MPG' 'Origin' 'Weight'}
CategoricalPredictors: [4 7]
ResponseName: 'Cylinders'
NumObservations: 406
KFold: 5
Partition: [1×1 cvpartition]
ClassNames: [3 4 5 6 8]
ScoreTransform: 'none'
If this example, doesn't work for you, can you share some code and an error message?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSupport Vector Machine Classification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by