Effacer les filtres
Effacer les filtres

Systems of double class cannot be used with the "predict" command.???

5 vues (au cours des 30 derniers jours)
anumala udayeni
anumala udayeni le 15 Juil 2016
Commenté : anumala udayeni le 19 Juil 2016
hello there... i am new to svm. i got error while using "predict" as..... "Systems of double class cannot be used with the "predict" command. Convert the system to an identified model first, such as by using the "idss" command." i tried "idss" and i am getting error .. "The number of inputs and outputs of the model must match that of the data." What exactly should be done to avoid this issue? kindly help me
Thanks in advance.
  2 commentaires
Walter Roberson
Walter Roberson le 15 Juil 2016
Please show your test code.
anumala udayeni
anumala udayeni le 18 Juil 2016
Modifié(e) : Walter Roberson le 18 Juil 2016
clc;
clear all;
close all;
filename='D:\forensics\csv dataset\dset3o-1.csv';
s=csvread(filename);
labels = s(:, 1); % labels from the 1st column
features =s(:, 2);
features_sparse = sparse(features);
Mi=max(features_sparse);
sf=(features_sparse)/(Mi);
libsvmwrite('D:/featuress.train', labels, sf);
[train_labels, train_features] =libsvmread('D:/featuress.train');
svmstruct=svmtrain(train_labels, train_features,'kernel_function','rbf','RBF_sigma',8,'Boxconstraint',90.5097);
d = 0.02;
[x1Grid,x2Grid] = meshgrid(min(train_features(:,1)):d:max(train_features(:,1)),...
min(train_features(:,1)):d:max(train_features(:,1)));
xGrid = [x1Grid(:),x2Grid(:)];
Mi2=max(features);
sf2=(features)/(Mi);
sys=idss(svmstruct);
[~,scores] = predict(sys,sf2);

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 18 Juil 2016
You are calling svmtrain to create svmstruct . That structure will be an SVMStruct, described by svmtrain() documentation
You are calling idss() passing in a single parameter, svmstruct . According to http://www.mathworks.com/help/ident/ref/idss.html#inputarg_sys0 when you call idss() with only one parameter, that parameter must be:
"Any dynamic system to convert to an idss model:
  • When sys0 is an identified model, its estimated parameter covariance is lost during conversion. If you want to translate the estimated parameter covariance during the conversion, use translatecov.
  • When sys0 is a numeric (non-identified) model, the state-space data of sys0 define the A, B, C, and D matrices of the converted model. The disturbance matrix K is fixed to zero. The NoiseVariance value defaults to eye(Ny), where Ny is the number of outputs of sys."
The description of Dynamic Models at http://www.mathworks.com/help/ident/ug/dynamic-system-models.html lists routines that can produce identified models. All of those routines start with the two characters 'id'. You do not call any routines that start with 'id' so you are not creating any identified model. The routines that produce numeric models are tf, zpk, ss, frd, pid, pidstd, pid2, and pidstd2. You are not calling any of those. We must conclude that svmstruct is not an appropriate input to use for idss if you are passing only one parameter.
  2 commentaires
Walter Roberson
Walter Roberson le 18 Juil 2016
It looks to me as if the root difficulty is that you tried to use predict() on the svm model, instead of using svmpredict() . And then you noticed that predict() required a Control Systems model such as built by idss() so you tried to use idss to convert the svm model to something usable by predict. When what you should have done is skipped idss and used svmpredict
anumala udayeni
anumala udayeni le 19 Juil 2016
thank you
i resolved it.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by