cluster analysis - weka is able to use classification via clustering -


i new weka tool. can combine classification , clustering? i.e first cluster data , classify instances cluster wise. requirement steps need follow.

thanks in advance.

yes can. easy classificationviaclustering classifier (class classificationviaclustering).

steps in java pseudocode:
1. create simplekmeans clusterer

simplekmeans skm = new simplekmeans(); skm.setnumclusters(5); // in example clusterer uses 5 clusters 

2. read dataset , set class index

bufferedreader reader = new bufferedreader(new filereader("[path].arff")); // replace [path] path dataset instances data = new instances(reader); data.setclassindex([your class index]); // if first attribute class, insert 0   

3. create classifier

classifierviaclustering cvc = new classificationviaclustering(); cvc.setclusterer(skm); // let classifier use simplekmeans clusterer cvc.buildclassifier(data); 

then, when want classify new instance:

instance instancetoclassify = new instance(data.firstinstance()); instancetoclassify.setdataset(data); // instance classified has have access dataset double class = cvc.classifyinstance(instancetoclassify); // classify instance based cluster belongs 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -