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
Previous revision
med:lab_5 [2018/05/12 23:19]
pszwed [Kod]
— (current)
Line 1: Line 1:
-====== Metody Eksploracji Danych: Laboratorium 5 ====== 
  
-Podczas zajęć będziemy korzystali z funkcji biblioteki Weka wołanych programowo z kodu Java. 
- 
-{{:med:med-lab05.pdf|Opis zadań (PDF)}} 
- 
-Zapoznaj się z treścią  
-  *{{:med:med-w05.pdf|Wykładu 4: ogólny opis zagadnienia klasyfikacji oraz regresja logistyczna}}   
-  *{{:med:med-w05.pdf|Wykładu 5: naiwny mode Bayesa i drzewa decyzyjne}}  
-  *{{:med:med-w06.pdf|Wykładu 6: Support Vector Machines i k-NN}} 
- 
-===== Zbiory danych ===== 
- 
-[[http://home.agh.edu.pl/~pszwed/wiki/doku.php?id=med:datasets#laboratorium_5_klasyfikacja_proste_dwuwymiarowe_obserwacje|Zbiory danych]] - dwuwymiarowym obserwacjom X1 i X2 przypisana jest etykieta klasy (atrybut nominalny Y) 
- 
-===== Weka ===== 
- 
- 
-Brak specjalnych wymagań 
- 
-===== IDE ===== 
- 
-  * W ''usr/local/bin'' jest dostępne Eclipse Neon 
-  * Utwórz projekt 
-  * Wybierz: //Project -> Properties -> Java Build Path.// Następnie zakładkę //Libraries// i opcję //Add External JARs//. Dodaj bibliotekę ''weka.jar '' 
-===== Kod ===== 
- 
-Fragmenty kodu: 
- 
- 
-<code java> 
-DataSource source = new DataSource("c-001.arff"); 
-Instances data = source.getDataSet(); 
- 
-if (data.classIndex() == -1) 
- data.setClassIndex(data.numAttributes() - 1); 
- 
-</code> 
- 
- 
-Utworznenie i uczenie klasyfikatora 
- 
-<code java> 
-Classifier cls = new NaiveBayes(); 
-cls.buildClassifier(data); 
-</code> 
- 
-Instancja do sklasyfikowania  
- 
-<code java> 
-Instance inst = new DenseInstance (3); 
-inst.setDataset (data); 
-inst.setValue(0, 1.1); // wartośc dla X1 
-inst.setValue(1, 2.2); // wartość dla X2  
-</code> 
- 
- 
-<code java> 
-double[] distrib = cls.distributionForInstance(inst); 
-System.out.printf(Locale.US,"%d->%f %d->%f\n",0,distrib[0],1,distrib[1]); 
-</code> 
- 
- 
-<code java> 
-List<Attribute> atts = Arrays.asList( 
-    new Attribute("X1"), 
-    new Attribute("X2"), 
-    new Attribute("Y",Arrays.asList("tak","nie"))); 
-             
-Instances result = new Instances("some-relation", new ArrayList<> (atts),0); 
-result.setClassIndex(result.numAttributes()-1); 
- 
-</code> 
- 
-<code java> 
-for(double x1=-10;x1<=10;x1+=0.1){ 
- for(double x2=-10;x2<=10;x2+=0.1){ 
-  Instance inst = new DenseInstance(3); 
-  inst.setValue(0, x1); 
-  inst.setValue(1, x2); 
- 
-  inst.setDataset(result); 
-  double y = cls.classifyInstance(inst); 
-  inst.setClassValue(y); 
-  result.add(inst); 
- } 
-} 
- 
-</code> 
med/lab_5.1526159987.txt.gz · Last modified: 2018/05/12 23:19 by pszwed
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0