-
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.
- Loading branch information
1 parent
b0dbb15
commit 6e63f3b
Showing
12 changed files
with
162 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>de.hpi.mmds.wiki</groupId> | ||
<artifactId>wiki</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>commons</artifactId> | ||
<name>mmds-wiki-commons</name> | ||
<url>http://maven.apache.org</url> | ||
<dependencies> | ||
</dependencies> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>de.hpi.mmds.wiki</groupId> | ||
<artifactId>wiki</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>commons</artifactId> | ||
<name>mmds-wiki-commons</name> | ||
<url>http://maven.apache.org</url> | ||
<dependencies> | ||
</dependencies> | ||
</project> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package de.hpi.mmds.wiki; | ||
|
||
import de.hpi.mmds.wiki.Evaluator.Result; | ||
import org.apache.spark.api.java.JavaSparkContext; | ||
import org.junit.*; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class EvaluatorTest { | ||
|
||
public static final double DOUBLE_TOLERANCE = 0.001; | ||
private static Edits test; | ||
private static Edits training; | ||
private static JavaSparkContext jsc; | ||
private static Recommender recommender; | ||
private File out; | ||
|
||
@BeforeClass | ||
public static void setupClass() { | ||
jsc = SparkUtil.getContext(); | ||
test = new Edits(jsc, Thread.currentThread().getContextClassLoader().getResource("test_data.txt").getPath()); | ||
training = new Edits(jsc, | ||
Thread.currentThread().getContextClassLoader().getResource("training_data.txt").getPath()); | ||
recommender = (userId, articles, howMany) -> Arrays | ||
.asList(new Recommendation(1.0, 10), new Recommendation(1.0, 11)); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDownClass() { | ||
jsc.close(); | ||
} | ||
|
||
@Before | ||
public void setup() { | ||
out = new File("out.txt"); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
out.delete(); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
Evaluator eval = new Evaluator(recommender, test, training, out); | ||
Map<Integer, Result> results = eval.evaluate(3); | ||
assertEquals(3, results.size()); | ||
assertEquals(1.0, results.get(1).precision(), DOUBLE_TOLERANCE); | ||
assertEquals(1.0, results.get(1).recall(), DOUBLE_TOLERANCE); | ||
assertEquals(0.5, results.get(2).precision(), DOUBLE_TOLERANCE); | ||
assertEquals(1.0 / 3, results.get(2).recall(), DOUBLE_TOLERANCE); | ||
assertEquals(0.0, results.get(3).precision(), DOUBLE_TOLERANCE); | ||
assertEquals(0.0, results.get(3).recall(), DOUBLE_TOLERANCE); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
1,1 | ||
1,2 | ||
2,1 | ||
2,3 | ||
2,4 | ||
3,2 | ||
3,5 | ||
1,10 | ||
1,11 | ||
2,10 | ||
2,12 | ||
2,13 | ||
3,13 |
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,7 @@ | ||
1,1 | ||
1,2 | ||
2,1 | ||
2,3 | ||
2,4 | ||
3,2 | ||
3,5 |