Skip to content

Commit

Permalink
Final cleanup in files
Browse files Browse the repository at this point in the history
Went trough the files once more time to remove remaining one-line comments
Didn't removed the comment from the benchmark on line 107 I think it is useful.
  • Loading branch information
acsolle66 committed Oct 11, 2023
1 parent 34daf51 commit f1e8ce8
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion example/src/main/java/de/example/benchmark/Benchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ private void run() {
});


//Sort and print results with numeration begin with best average accuracy
System.out.println("Classifier performances (sorted by average accuracy):");
results.entrySet().stream()
.map(entry -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public double[][] getTestLabels() {
}

private double[][] featuresOf(List<Penguin> data) {
double[][] features = new double[data.size()][4]; // 4 numerische Eigenschaften
double[][] features = new double[data.size()][4];

for (int i = 0; i < data.size(); i++) {
Penguin p = data.get(i);
Expand All @@ -159,7 +159,7 @@ private double[][] featuresOf(List<Penguin> data) {
}

private double[][] labelsOf(List<Penguin> data) {
double[][] labels = new double[data.size()][3]; // 3 Pinguinarten
double[][] labels = new double[data.size()][3];

for (int i = 0; i < data.size(); i++) {
Penguin p = data.get(i);
Expand Down
2 changes: 1 addition & 1 deletion example/src/main/java/de/example/knn/KnnIrisExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void main(String[] args) {
irisDataProcessor.split(data, TRAIN_TEST_SPLIT_RATIO);

Classifier knn = new KnnClassifier(2);
//Train and evaluate

knn.train(irisDataProcessor.getTrainFeatures(), irisDataProcessor.getTrainLabels());
knn.evaluate(irisDataProcessor.getTestFeatures(), irisDataProcessor.getTestLabels());
}
Expand Down
4 changes: 2 additions & 2 deletions example/src/main/java/de/example/knn/KnnSeabornExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public class KnnSeabornExample {
private static final File CSV_FILE = new File("example" + File.separator + "datasets" + File.separator + "seaborn-penguins" + File.separator + "penguins.csv");

public static void main(String[] args) {
//Load Data, shuffle, normalize, filter incomplete records out.
var seabornDataProcessor = new SeabornDataProcessor();
List<Penguin> data = seabornDataProcessor.loadDataSetFromCSV(CSV_FILE, ',', SHUFFLE, NORMALIZE, FILTER_INCOMPLETE_RECORDS);
//Split dataset into train and test

Dataset<Penguin> dataset = seabornDataProcessor.split(data, TRAIN_TEST_SPLIT_RATIO);
var seabornProvider = new SeabornProvider(data, dataset.trainData(), dataset.testData());
seabornProvider.printStatistics();

Classifier knn = new KnnClassifier(2);
knn.train(seabornProvider.getTrainFeatures(), seabornProvider.getTrainLabels());
knn.evaluate(seabornProvider.getTestFeatures(), seabornProvider.getTestLabels());
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/de/edux/data/reader/CSVIDataReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class CSVIDataReader implements IDataReader {

public List<String[]> readFile(File file, char separator) {
CSVParser customCSVParser = new CSVParserBuilder().withSeparator(separator).build(); // custom separator
CSVParser customCSVParser = new CSVParserBuilder().withSeparator(separator).build();
List<String[]> result;
try(CSVReader reader = new CSVReaderBuilder(
new FileReader(file))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public double[] predict(double[] feature) {
for (Future<double[]> future : futures) {
try {
double[] prediction = future.get();
/* voteMap.merge(prediction, 1L, Long::sum);*/
double label = getIndexOfHighestValue(prediction);
voteMap.merge(label, 1L, Long::sum);
} catch (InterruptedException | ExecutionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ private DataProcessor<String> getDummyDataUtil() {

@Override
public void normalize(List<String> dataset) {
// Mock normalize for the sake of testing
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public double[][] getTestLabels() {
}

private double[][] featuresOf(List<Penguin> data) {
double[][] features = new double[data.size()][4]; // 4 numerische Eigenschaften
double[][] features = new double[data.size()][4];

for (int i = 0; i < data.size(); i++) {
Penguin p = data.get(i);
Expand All @@ -157,7 +157,7 @@ private double[][] featuresOf(List<Penguin> data) {
}

private double[][] labelsOf(List<Penguin> data) {
double[][] labels = new double[data.size()][3]; // 3 Pinguinarten
double[][] labels = new double[data.size()][3];

for (int i = 0; i < data.size(); i++) {
Penguin p = data.get(i);
Expand Down

0 comments on commit f1e8ce8

Please sign in to comment.