Multilayer perceptron for classification

classic Classic list List threaded Threaded
2 messages Options
Tom
Reply | Threaded
Open this post in threaded view
|

Multilayer perceptron for classification

Tom

Hi,

I'm using a Multilayer Perceptron (in java code) for classification of a bunch of instances, with a numerical class column.

The training seems to have worked, I get a model without errors.

However, now that I want to use this model on a new set of instances, that lacks the class attribute (as it should), I get an error in distributionForInstance() saying:

java.lang.IllegalArgumentException: Src and Dest differ in # of attributes: 12 != 13
    at weka.core.RelationalLocator.copyRelationalValues(RelationalLocator.java:87)
    at weka.filters.Filter.copyValues(Filter.java:405)
    at weka.filters.Filter.push(Filter.java:326)
    at weka.filters.Filter.push(Filter.java:307)
    at weka.filters.unsupervised.attribute.NominalToBinary.convertInstance(NominalToBinary.java:577)
    at weka.filters.unsupervised.attribute.NominalToBinary.input(NominalToBinary.java:184)
    at weka.classifiers.functions.MultilayerPerceptron.distributionForInstance(MultilayerPerceptron.java:2149)

Apparently the class attribute is needed otherwise stuff crashes? Is this normal?

Best regards,
  Tom


_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Multilayer perceptron for classification

Peter Reutemann
> I'm using a Multilayer Perceptron (in java code) for classification of a bunch of instances, with a numerical class column.
>
> The training seems to have worked, I get a model without errors.
>
> However, now that I want to use this model on a new set of instances, that lacks the class attribute (as it should), I get an error in distributionForInstance() saying:
>
> java.lang.IllegalArgumentException: Src and Dest differ in # of attributes: 12 != 13
>     at weka.core.RelationalLocator.copyRelationalValues(RelationalLocator.java:87)
>     at weka.filters.Filter.copyValues(Filter.java:405)
>     at weka.filters.Filter.push(Filter.java:326)
>     at weka.filters.Filter.push(Filter.java:307)
>     at weka.filters.unsupervised.attribute.NominalToBinary.convertInstance(NominalToBinary.java:577)
>     at weka.filters.unsupervised.attribute.NominalToBinary.input(NominalToBinary.java:184)
>     at weka.classifiers.functions.MultilayerPerceptron.distributionForInstance(MultilayerPerceptron.java:2149)
>
> Apparently the class attribute is needed otherwise stuff crashes? Is this normal?

Yes, that is one of Weka's quirks, in some sense. The dataset
structure has to be exactly the same (including the class attribute
definition), the class value set to missing (that's what the
Evaluation class before obtaining a prediction from a classifier).
In theory, it wouldn't matter for numeric attributes. However, for
nominal attributes, a classifier might query the values and for that
it needs the attribute definition.

You can use the "setClassMissing()" method of an instance to unset the
class attribute value (class index must be set, of course):
https://weka.sourceforge.io/doc.dev/weka/core/Instance.html#setClassMissing--

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html