필터 지우기
필터 지우기

Why is fitcdiscr function much slower than classify?

조회 수: 1 (최근 30일)
Axel Forsberg
Axel Forsberg 2018년 3월 22일
댓글: Axel Forsberg 2018년 3월 26일
I am classifying some data and I am using fitcdiscr fucntion to train the classifier and its predict method to classify test data. I then found the function classify which does the exact same thing but it trains and predicts the data at the same time. It produces the same results but classify is much faster than fitcdiscr. I have no idea why this is the case...
For the same data I get from tic-toc 'Elapsed time is 5.529583 seconds.' with fitcdiscr and 'Elapsed time is 0.395027 seconds.' with classify.

답변 (1개)

Bernhard Suhm
Bernhard Suhm 2018년 3월 25일
It depends on what parameters you pass to either... fitcdiscr supports cross-validation and hyperparameter optimization, and either of those could extend the runtime significantly. Also it does not require you to fit the classifier every time you make a new prediction or you change prior probabilities because it creates a model object.
  댓글 수: 1
Axel Forsberg
Axel Forsberg 2018년 3월 26일
Yes, but I don't pass any of those parameters. I just pass the data like this:
model = fitdiscr(tr_data, tr_labels); class = model.predict(test_data);
or
class = classify(test_data, tr_data, tr_labels);
I'm doing "external" crossvalidation with crossvalind to enable for training feature reduction methods also. I also compare classification accuracy for diffferent features. This means I have repeated calls to the funcion and that is why I want it to be fast.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by