Ok actually I've figured it out, and I think it's worth putting the answer here because it is a little bizarre. If you don't add double quotes ("") around your matlab strings, you will get this error. So, by changing my feature names from things like 'C1V1' in Matlab to '"C1V1"' I was able to solve the problem.
Matlab Weka Interface Java Exception
4 views (last 30 days)
Show older comments
Hi,
Not sure if this is where I should post this question, since it is on something I downloaded from the FileExchange. If that's the case, please let me know where I should put this.
I'm trying to use the matlab weka interface that I downloaded from here: http://www.mathworks.com/matlabcentral/fileexchange/21204-matlab-weka-interface
Here is my code:
classifier = trainWekaClassifier(matlab2weka('comp', featurelabels, feature, w), 'functions.Logistic', {'-R 100'});
featurelabels is a 1x211 cell array containing strings naming my features. Ex: 'C1V1'
feature is a 172x211 cell array containing feature values in the first 210 columns, and then labels in the 211th, which are either 'C' or 'N'. w is 211.
It is throwing the following error:
??? Java exception occurred:
java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String
at weka.core.Attribute.<init>(Attribute.java:339)
at weka.core.Attribute.<init>(Attribute.java:298)
Error in ==> matlab2weka at 37
vec.addElement(Attribute(featureNames{i},values));
Error in ==> wekacomptrain at 33
classifier = trainWekaClassifier(matlab2weka('comp', featurelabels, feature, w),
'functions.Logistic', {'-R 100'});
I'm not sure what I'm doing incorrectly - any help would be appreciated. Thanks!
0 Comments
Accepted Answer
More Answers (2)
parmin
on 23 Jul 2013
Hi, I have a problem like you. but I can not understand your answer! can you explain more than it? what is your mean of this sentences : "by changing my feature names from things like 'C1V1' in Matlab to '"C1V1"' I was able to solve the problem. "
your featurename is like age or name column in dataset or it is contents of age or name?
I think problem is for values in this lines: vec.addElement(Attribute(featureNames{i},values));
I'm waiting for your answers. thanks
0 Comments
parmin
on 24 Jul 2013
I understand why this error appear. when I want to send a single character such as f/m for attribute sex this errors caused. but for more than 1 character such as male or no there is no problem! if I put the characters in "" such as you have done, it is would be like this in arff format ' " \ y \ " '.so this state would not be work in weka!
would you mind help me to solve this problem?
3 Comments
See Also
Categories
Find more on Statistics and Machine Learning Toolbox 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!