resolves Issue: Einlesen der Datenpunkte in CSV-Datei
This commit is contained in:
35
Online-IDE-files/Labor.java
Normal file
35
Online-IDE-files/Labor.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Portierung des Perzeptron-Labors von Christoph Grässl für die Online-IDE.
|
||||
*
|
||||
* @author: Jan Bertram ( jbsoc@mailbox.org )
|
||||
*/
|
||||
public class Labor {
|
||||
ArrayList<DataPoint> trainingset;
|
||||
|
||||
public Labor() {
|
||||
trainingset = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void ladeTrainingsdaten(String workspaceFilename) {
|
||||
String fileAsString = Files.read(workspaceFilename);
|
||||
String[] lines = fileAsString.split("\n");
|
||||
for (String line : lines) {
|
||||
String[] items = line.split(";");
|
||||
// 0 Beschriftung, 1 Klasse, 2 x1, 3 x2
|
||||
if(items[0] != "Beschriftung") { // Zeile mit Beschriftung aussparen
|
||||
double x1 = Double.valueOf(items[2]);
|
||||
double x2 = Double.valueOf(items[3]);
|
||||
int klasse = Integer.valueOf(items[1]);
|
||||
String name = items[0];
|
||||
DataPoint dp = new DataPoint(x1, x2, klasse, name);
|
||||
this.trainingset.add(dp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void zeigeTrainingsdaten() {
|
||||
for (DataPoint dp : this.trainingset) {
|
||||
println(dp);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user