Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
med:lab_6 [2017/01/15 19:04]
pszwed [Weka]
med:lab_6 [2017/01/15 21:32]
pszwed [Kod]
Line 57: Line 57:
             Add filter = new Add();             Add filter = new Add();
             filter.setAttributeIndex("last");             filter.setAttributeIndex("last");
-            int num  = cls.getNumClusters();+            int num  = cls.numberOfClusters();
             String labels = "cluster0";             String labels = "cluster0";
             for(int i=1;i<num;i++){             for(int i=1;i<num;i++){
Line 73: Line 73:
  
 <code java> <code java>
-            int[] clusters = cls.getAssignments(); 
             int idx = newData.numAttributes()-1;             int idx = newData.numAttributes()-1;
-            for(int i=0;i<clusters.length;i++){ +            for(int i=0;i<newData.numInstances();i++){ 
-                newData.get(i).setValue(idx, clusters[i]);+                newData.get(i).setValue(idx, cls.clusterInstance(data.get(i)));
             }             }
 </code> </code>
Line 103: Line 102:
 </code> </code>
  
 +Wyniki dla k-means
  
 <code java> <code java>
Line 117: Line 117:
         System.out.printf(Locale.US, "Error: %f",cls.getSquaredError());         System.out.printf(Locale.US, "Error: %f",cls.getSquaredError());
 </code> </code>
 +
 +Wyniki dla EM
 +
 +<code java>
 +        System.out.println(cls);
 +</code>
 +
 +  *Aby obliczyć log-likehood: należy iterować po instancjach i zsumować ''cls.logDensityForInstance(data.get(i));''
 +
  
med/lab_6.txt · Last modified: 2020/05/12 00:51 by pszwed
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0