Testing trained classifier model with new data

3 views (last 30 days)
Hi everyone,
I've trained a classifier model based on some audio data, using the simple tree algorithm. I extracted 19 features in total from the audio data. The predicted accuracy is 100%, which seems to mainly rely on one extracted feature-peak2rms. After I have exported the trained model, I would like to test it with a set of some new data- I would assume that the features I need to extract from the new data are only those that were used in the final model (most of them were removed while experimenting with the classifier, after realising they don't have any significant effect on the accuracy). However, I have written the below to extract the relevant features from the new data:
sample=miraudio(audio);
T=table(mirgetdata(mirrms(sample)),mirgetdata(mirrolloff(sample)),mirgetdata(mirkey(sample)),mirgetdata(mircentroid(sample)),mirgetdata(mirregularity(sample)),mirgetdata(mirtempo(sample)),mirgetdata(mireventdensity(sample)),mirgetdata(mirkurtosis(sample)),mirgetdata(mirspread(sample)),peak2rms(sample));
a=table2array(T);
decision=trainedModel.predictFcn(a);
I keep getting the following error:
Undefined function 'abs' for input arguments of type 'miraudio'.
Error in peak2rms (line 28)
num = max(abs(x));
Error in testing (line 2)
T=table(mirgetdata(mirrms(sample)),mirgetdata(mirrolloff(sample)),mirgetdata(mirkey(sample)),mirgetdata(mircentroid(sample)),mirgetdata(mirregularity(sample)),mirgetdata(mirtempo(sample)),mirgetdata(mireventdensity(sample)),mirgetdata(mirkurtosis(sample)),mirgetdata(mirspread(sample)),peak2rms(sample));
>>
I can't seem to figure out the problem with the feature, as I am successfully able to extract this feature separately from any audio data.
Any ideas why I'm running into this problem? Any help would be much appreciated!

Answers (1)

Mrutyunjaya Hiremath
Mrutyunjaya Hiremath on 12 Apr 2020
sample=miraudio(audio);
will give 'miraudio object'. its NOT an array.
'peak2rms' builtin function of matlab will give an error. It expects an array.
Use:
peak2rms(mirgetdata(sample));

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!