-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated initialization of tabular data sets #13
- Loading branch information
B96
committed
Jun 21, 2019
1 parent
a1549dd
commit 413a59c
Showing
6 changed files
with
189 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
AutoTuning/src/test/java/Initializer/FileInitializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package Initializer; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class FileInitializerTest { | ||
|
||
@Test(expected = RuntimeException.class) | ||
public void testEmptyPath() { | ||
|
||
// Given | ||
String path = ""; | ||
|
||
// When | ||
FileInitializer fi = new FileInitializer(path); | ||
} | ||
|
||
@Test | ||
public void testNotExistingFile() { | ||
|
||
// Given | ||
String path = "test"; | ||
|
||
// When | ||
FileInitializer fi = new FileInitializer(path); | ||
fi.setExtension(); | ||
String extension = fi.getExtension(); | ||
|
||
// Then | ||
Assert.assertFalse(extension == null); | ||
} | ||
|
||
@Test | ||
public void testExcelFile() { | ||
|
||
// Given | ||
String path = "src/test/resources/train.csv"; | ||
|
||
// When | ||
FileInitializer fi = new FileInitializer(path); | ||
fi.setExtension(); | ||
String extension = fi.getExtension(); | ||
|
||
// Then | ||
Assert.assertTrue(extension.equals("csv")); | ||
|
||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
AutoTuning/src/test/java/Initializer/TabularInitializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package Initializer; | ||
|
||
import de.viadee.xai.anchor.adapter.tabular.util.CSVReader; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
public class TabularInitializerTest { | ||
|
||
@Test | ||
public void createTabularTrainingDefinition() { | ||
|
||
// Given | ||
String path = "train.csv"; | ||
|
||
// Then | ||
TabularInitializer.createTabularDefinition(path, 0, true); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetColumnDatatype() { | ||
|
||
// Given | ||
String path = "train.csv"; | ||
InputStream trainingDataStream = ClassLoader.getSystemResourceAsStream(path); | ||
Collection<String[]> strings = null; | ||
try { | ||
strings = CSVReader.readCSV(trainingDataStream, false); | ||
} catch (IOException e) { | ||
|
||
} | ||
|
||
// When | ||
int[] result = TabularInitializer.getColumnDataTypes(strings); | ||
|
||
} | ||
|
||
@Test | ||
public void testEmptyRowDatatypes() { | ||
// Given | ||
String[] row = {}; | ||
Collection<String[]> dataframe = new ArrayList<>(); | ||
dataframe.add(row); | ||
|
||
// When | ||
int[] result = TabularInitializer.getColumnDataTypes(dataframe); | ||
|
||
// Then | ||
Assert.assertTrue(result.length == 0); | ||
} | ||
|
||
@Test | ||
public void testIntRowDatatypes() { | ||
// Given | ||
String[] row = {"1", "2", "3", "4"}; | ||
Collection<String[]> dataframe = new ArrayList<>(); | ||
dataframe.add(row); | ||
|
||
// When | ||
int[] result = TabularInitializer.getColumnDataTypes(dataframe); | ||
int[] test ={0, 0, 0, 0}; | ||
|
||
// Then | ||
Assert.assertTrue(Arrays.equals(result,test)); | ||
} | ||
|
||
@Test | ||
public void testAllDatatypes() { | ||
// Given | ||
String[] row = new String[]{"1", "Hallo", "Test123.3", "3.12"}; | ||
Collection<String[]> dataframe = new ArrayList<>(); | ||
dataframe.add(row); | ||
|
||
// When | ||
int[] result = TabularInitializer.getColumnDataTypes(dataframe); | ||
int[] test ={0, 2, 2, 1}; | ||
|
||
// Then | ||
Assert.assertTrue(Arrays.equals(result,test)); | ||
} | ||
} |