modify reddit classifier
This commit is contained in:
		
							parent
							
								
									df215fc026
								
							
						
					
					
						commit
						d752fe77ec
					
				| @ -1,13 +1,17 @@ | |||||||
| package org.baeldung.reddit.classifier; | package org.baeldung.reddit.classifier; | ||||||
| 
 | 
 | ||||||
| import java.io.BufferedReader; | import java.io.File; | ||||||
| import java.io.FileReader; |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.Charset; | ||||||
|  | import java.util.ArrayList; | ||||||
| import java.util.Calendar; | import java.util.Calendar; | ||||||
|  | import java.util.List; | ||||||
| import java.util.TimeZone; | import java.util.TimeZone; | ||||||
| 
 | 
 | ||||||
|  | import org.apache.mahout.classifier.sgd.AdaptiveLogisticRegression; | ||||||
|  | import org.apache.mahout.classifier.sgd.CrossFoldLearner; | ||||||
| import org.apache.mahout.classifier.sgd.L2; | import org.apache.mahout.classifier.sgd.L2; | ||||||
| import org.apache.mahout.classifier.sgd.OnlineLogisticRegression; | import org.apache.mahout.math.NamedVector; | ||||||
| import org.apache.mahout.math.RandomAccessSparseVector; | import org.apache.mahout.math.RandomAccessSparseVector; | ||||||
| import org.apache.mahout.math.Vector; | import org.apache.mahout.math.Vector; | ||||||
| import org.apache.mahout.vectorizer.encoders.AdaptiveWordValueEncoder; | import org.apache.mahout.vectorizer.encoders.AdaptiveWordValueEncoder; | ||||||
| @ -15,22 +19,25 @@ import org.apache.mahout.vectorizer.encoders.FeatureVectorEncoder; | |||||||
| import org.apache.mahout.vectorizer.encoders.StaticWordValueEncoder; | import org.apache.mahout.vectorizer.encoders.StaticWordValueEncoder; | ||||||
| 
 | 
 | ||||||
| import com.google.common.base.Splitter; | import com.google.common.base.Splitter; | ||||||
|  | import com.google.common.io.Files; | ||||||
| 
 | 
 | ||||||
| public class RedditClassifier { | public class RedditClassifier { | ||||||
| 
 | 
 | ||||||
|     public static int GOOD = 0; |     public static int GOOD = 0; | ||||||
|     public static int BAD = 1; |     public static int BAD = 1; | ||||||
|     public static int MIN_SCORE = 5; |     public static int MIN_SCORE = 10; | ||||||
|     private final OnlineLogisticRegression classifier; |     private final AdaptiveLogisticRegression classifier; | ||||||
|     private final FeatureVectorEncoder titleEncoder; |     private final FeatureVectorEncoder titleEncoder; | ||||||
|     private final FeatureVectorEncoder domainEncoder; |     private final FeatureVectorEncoder domainEncoder; | ||||||
|  |     private CrossFoldLearner learner; | ||||||
| 
 | 
 | ||||||
|     private final int[] trainCount = { 0, 0 }; |     private final int[] trainCount = { 0, 0 }; | ||||||
| 
 | 
 | ||||||
|     private final int[] evalCount = { 0, 0 }; |     private final int[] evalCount = { 0, 0 }; | ||||||
| 
 | 
 | ||||||
|     public RedditClassifier() { |     public RedditClassifier() { | ||||||
|         classifier = new OnlineLogisticRegression(2, 4, new L2(1)); |         classifier = new AdaptiveLogisticRegression(2, 4, new L2()); | ||||||
|  |         classifier.setPoolSize(25); | ||||||
|         titleEncoder = new AdaptiveWordValueEncoder("title"); |         titleEncoder = new AdaptiveWordValueEncoder("title"); | ||||||
|         titleEncoder.setProbes(1); |         titleEncoder.setProbes(1); | ||||||
|         domainEncoder = new StaticWordValueEncoder("domain"); |         domainEncoder = new StaticWordValueEncoder("domain"); | ||||||
| @ -38,27 +45,35 @@ public class RedditClassifier { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void trainClassifier(String fileName) throws IOException { |     public void trainClassifier(String fileName) throws IOException { | ||||||
|         final BufferedReader reader = new BufferedReader(new FileReader(fileName)); |         final List<NamedVector> vectors = extractVectors(readDataFile(fileName)); | ||||||
|         int category; |         int category; | ||||||
|         Vector features; |         for (final NamedVector vector : vectors) { | ||||||
|         String line = reader.readLine(); |             category = (vector.getName() == "GOOD") ? GOOD : BAD; | ||||||
|         if (line == null) { |             classifier.train(category, vector); | ||||||
|             new RedditDataCollector().collectData(); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         while ((line != null) && (line != "")) { |  | ||||||
|             category = extractCategory(line); |  | ||||||
|             trainCount[category]++; |             trainCount[category]++; | ||||||
|             features = convertLineToVector(line); |  | ||||||
|             classifier.train(category, features); |  | ||||||
|             line = reader.readLine(); |  | ||||||
|         } |         } | ||||||
|         reader.close(); |  | ||||||
|         System.out.println("Training count ========= " + trainCount[0] + "___" + trainCount[1]); |         System.out.println("Training count ========= " + trainCount[0] + "___" + trainCount[1]); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public int classify(Vector features) { |     public double evaluateClassifier() throws IOException { | ||||||
|         return classifier.classifyFull(features).maxValueIndex(); |         final List<NamedVector> vectors = extractVectors(readDataFile(RedditDataCollector.TEST_FILE)); | ||||||
|  |         int category, result; | ||||||
|  |         int correct = 0; | ||||||
|  |         int wrong = 0; | ||||||
|  |         for (final NamedVector vector : vectors) { | ||||||
|  |             category = (vector.getName() == "GOOD") ? GOOD : BAD; | ||||||
|  |             result = classify(vector); | ||||||
|  | 
 | ||||||
|  |             evalCount[category]++; | ||||||
|  |             if (category == result) { | ||||||
|  |                 correct++; | ||||||
|  |             } else { | ||||||
|  |                 wrong++; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         System.out.println(correct + " ----- " + wrong); | ||||||
|  |         System.out.println("Eval count ========= " + evalCount[0] + "___" + evalCount[1]); | ||||||
|  |         return correct / (wrong + correct + 0.0); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Vector convertPost(String title, String domain, int hour) { |     public Vector convertPost(String title, String domain, int hour) { | ||||||
| @ -71,49 +86,50 @@ public class RedditClassifier { | |||||||
|         return features; |         return features; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public double evaluateClassifier() throws IOException { |     public int classify(Vector features) { | ||||||
|         final BufferedReader reader = new BufferedReader(new FileReader(RedditDataCollector.TEST_FILE)); |         if (learner == null) { | ||||||
|         int category, result; |             learner = classifier.getBest().getPayload().getLearner(); | ||||||
|         int correct = 0; |  | ||||||
|         int wrong = 0; |  | ||||||
|         Vector features; |  | ||||||
|         String line = reader.readLine(); |  | ||||||
|         while ((line != null) && (line != "")) { |  | ||||||
|             category = extractCategory(line); |  | ||||||
|             evalCount[category]++; |  | ||||||
|             features = convertLineToVector(line); |  | ||||||
|             result = classify(features); |  | ||||||
|             if (category == result) { |  | ||||||
|                 correct++; |  | ||||||
|             } else { |  | ||||||
|                 wrong++; |  | ||||||
|             } |  | ||||||
|             line = reader.readLine(); |  | ||||||
|         } |         } | ||||||
|         reader.close(); |         return learner.classifyFull(features).maxValueIndex(); | ||||||
|         System.out.println(correct + " ----- " + wrong); |  | ||||||
|         System.out.println("Eval count ========= " + evalCount[0] + "___" + evalCount[1]); |  | ||||||
|         return correct / (wrong + correct + 0.0); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // ==== private |     // ==== Private methods | ||||||
|     private int extractCategory(String line) { | 
 | ||||||
|         final int score = Integer.parseInt(line.substring(0, line.indexOf(';'))); |     private List<String> readDataFile(String fileName) throws IOException { | ||||||
|         return (score < MIN_SCORE) ? BAD : GOOD; |         List<String> lines = Files.readLines(new File(fileName), Charset.forName("utf-8")); | ||||||
|  |         if ((lines == null) || (lines.size() == 0)) { | ||||||
|  |             new RedditDataCollector().collectData(); | ||||||
|  |             lines = Files.readLines(new File(fileName), Charset.forName("utf-8")); | ||||||
|  |         } | ||||||
|  |         lines.remove(0); | ||||||
|  |         return lines; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private Vector convertLineToVector(String line) { |     private List<NamedVector> extractVectors(List<String> lines) { | ||||||
|         final Vector features = new RandomAccessSparseVector(4); |         final List<NamedVector> vectors = new ArrayList<NamedVector>(lines.size()); | ||||||
|         final String[] items = line.split(";"); |         for (final String line : lines) { | ||||||
|  |             vectors.add(extractVector(line)); | ||||||
|  |         } | ||||||
|  |         return vectors; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private NamedVector extractVector(String line) { | ||||||
|  |         final String[] items = line.split(","); | ||||||
|  |         final String category = extractCategory(Integer.parseInt(items[0])); | ||||||
|  |         final NamedVector vector = new NamedVector(new RandomAccessSparseVector(4), category); | ||||||
|         final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); |         final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); | ||||||
|         cal.setTimeInMillis(Long.parseLong(items[1]) * 1000); |         cal.setTimeInMillis(Long.parseLong(items[1]) * 1000); | ||||||
|         final int hour = cal.get(Calendar.HOUR_OF_DAY); |  | ||||||
| 
 | 
 | ||||||
|         titleEncoder.addToVector(items[3], features); |         titleEncoder.addToVector(items[3], vector); | ||||||
|         domainEncoder.addToVector(items[4], features); |         domainEncoder.addToVector(items[4], vector); | ||||||
|         features.set(2, hour); // hour of day |         vector.set(2, cal.get(Calendar.HOUR_OF_DAY)); // hour of day | ||||||
|         features.set(3, Integer.parseInt(items[2])); // number of words in the title |         vector.set(3, Integer.parseInt(items[2])); // number of words in the title | ||||||
|         return features; | 
 | ||||||
|  |         return vector; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private String extractCategory(int score) { | ||||||
|  |         return (score < MIN_SCORE) ? "BAD" : "GOOD"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -47,12 +47,14 @@ public class RedditDataCollector { | |||||||
|         timestamp = System.currentTimeMillis() / 1000; |         timestamp = System.currentTimeMillis() / 1000; | ||||||
|         try { |         try { | ||||||
|             final FileWriter writer = new FileWriter(TRAINING_FILE); |             final FileWriter writer = new FileWriter(TRAINING_FILE); | ||||||
|  |             writer.write("Score, Timestamp in utc, Number of wrods in title, Title, Domain \n"); | ||||||
|             for (int i = 0; i < noOfRounds; i++) { |             for (int i = 0; i < noOfRounds; i++) { | ||||||
|                 getPosts(writer); |                 getPosts(writer); | ||||||
|             } |             } | ||||||
|             writer.close(); |             writer.close(); | ||||||
| 
 | 
 | ||||||
|             final FileWriter testWriter = new FileWriter(TEST_FILE); |             final FileWriter testWriter = new FileWriter(TEST_FILE); | ||||||
|  |             testWriter.write("Score, Timestamp in utc, Number of wrods in title, Title, Domain \n"); | ||||||
|             getPosts(testWriter); |             getPosts(testWriter); | ||||||
|             testWriter.close(); |             testWriter.close(); | ||||||
|         } catch (final Exception e) { |         } catch (final Exception e) { | ||||||
| @ -83,9 +85,9 @@ public class RedditDataCollector { | |||||||
|             words = Splitter.onPattern("\\W").omitEmptyStrings().splitToList(child.get("data").get("title").asText()); |             words = Splitter.onPattern("\\W").omitEmptyStrings().splitToList(child.get("data").get("title").asText()); | ||||||
|             timestamp = child.get("data").get("created_utc").asLong(); |             timestamp = child.get("data").get("created_utc").asLong(); | ||||||
| 
 | 
 | ||||||
|             line = score + ";"; |             line = score + ","; | ||||||
|             line += timestamp + ";"; |             line += timestamp + ","; | ||||||
|             line += words.size() + ";" + Joiner.on(' ').join(words) + ";"; |             line += words.size() + "," + Joiner.on(' ').join(words) + ","; | ||||||
|             line += child.get("data").get("domain").asText() + "\n"; |             line += child.get("data").get("domain").asText() + "\n"; | ||||||
|             writer.write(line); |             writer.write(line); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,100 +1,101 @@ | |||||||
| 3;1357021066;7;Good Examples of Component dragging and dropping;self.java | Score, Timestamp in utc, Number of wrods in title, Title, Domain  | ||||||
| 0;1357017936;10;Game only works on mac need help porting to windows;self.java | 3,1357021066,7,Good Examples of Component dragging and dropping,self.java | ||||||
| 2;1357008210;4;eclipse or keyboard issues;self.java | 0,1357017936,10,Game only works on mac need help porting to windows,self.java | ||||||
| 37;1356977564;6;The Long Strange Trip to Java;blinkenlights.com | 2,1357008210,4,eclipse or keyboard issues,self.java | ||||||
| 5;1356970069;9;How to Send Email with Embedded Images Using Java;blog.smartbear.com | 37,1356977564,6,The Long Strange Trip to Java,blinkenlights.com | ||||||
| 0;1356956937;4;What makes you architect;programming.freeblog.hu | 5,1356970069,9,How to Send Email with Embedded Images Using Java,blog.smartbear.com | ||||||
| 0;1356900338;4;Apache Maven I of;javaxperiments.blogspot.com | 0,1356956937,4,What makes you architect,programming.freeblog.hu | ||||||
| 0;1356896219;5;Custom functions per class instance;self.java | 0,1356900338,4,Apache Maven I of,javaxperiments.blogspot.com | ||||||
| 0;1356891056;5;JMeter Performance and Tuning Tips;ubik-ingenierie.com | 0,1356896219,5,Custom functions per class instance,self.java | ||||||
| 12;1356888358;19;First fully functional GUI program about making acronyms easier to remember Was wondering if you guys had any tips;github.com | 0,1356891056,5,JMeter Performance and Tuning Tips,ubik-ingenierie.com | ||||||
| 2;1356881034;12;Social Tech 101 Why do I love Java Developer Edition Part 1;socialtech101.blogspot.com | 12,1356888358,19,First fully functional GUI program about making acronyms easier to remember Was wondering if you guys had any tips,github.com | ||||||
| 5;1356826782;7;Configurable deployment descriptors proposal for Java EE;java.net | 2,1356881034,12,Social Tech 101 Why do I love Java Developer Edition Part 1,socialtech101.blogspot.com | ||||||
| 31;1356793800;16;Finished my very first game in java Snake clone It s not much but it works;self.java | 5,1356826782,7,Configurable deployment descriptors proposal for Java EE,java.net | ||||||
| 18;1356766107;10;la4j Linear Alebra for Java 0 3 0 is out;la4j.org | 31,1356793800,16,Finished my very first game in java Snake clone It s not much but it works,self.java | ||||||
| 1;1356747219;6;RubyFlux a Ruby to Java compiler;github.com | 18,1356766107,10,la4j Linear Alebra for Java 0 3 0 is out,la4j.org | ||||||
| 15;1356735585;10;Simple JMS 2 0 Sample JMSDestinationDefinition and Synchronous Message Receive;blogs.oracle.com | 1,1356747219,6,RubyFlux a Ruby to Java compiler,github.com | ||||||
| 9;1356717174;3;Java Use WebCam;self.java | 15,1356735585,10,Simple JMS 2 0 Sample JMSDestinationDefinition and Synchronous Message Receive,blogs.oracle.com | ||||||
| 4;1356711735;5;Compiler Optimisation for saving memory;self.java | 9,1356717174,3,Java Use WebCam,self.java | ||||||
| 4;1356662279;22;I m interested in your opinion about Java for Python Programmers by Brad Miller or a better alternative for a Java newbie;self.java | 4,1356711735,5,Compiler Optimisation for saving memory,self.java | ||||||
| 0;1356633508;4;A good android game;self.java | 4,1356662279,22,I m interested in your opinion about Java for Python Programmers by Brad Miller or a better alternative for a Java newbie,self.java | ||||||
| 4;1356631759;12;a java library i saw mentioned here can t find pls help;self.java | 0,1356633508,4,A good android game,self.java | ||||||
| 1;1356627923;5;About learning Java a question;self.java | 4,1356631759,12,a java library i saw mentioned here can t find pls help,self.java | ||||||
| 0;1356623761;3;Objects and java2d;self.java | 1,1356627923,5,About learning Java a question,self.java | ||||||
| 0;1356593886;2;AffineTransform halp;self.java | 0,1356623761,3,Objects and java2d,self.java | ||||||
| 43;1356584047;7;Java Was Strongly Influenced by Objective C;cs.gmu.edu | 0,1356593886,2,AffineTransform halp,self.java | ||||||
| 1;1356580543;7;Having trouble Setting Up Android Development Environment;self.java | 43,1356584047,7,Java Was Strongly Influenced by Objective C,cs.gmu.edu | ||||||
| 0;1356560732;13;How can I fetch the first X links of reddit into a list;self.java | 1,1356580543,7,Having trouble Setting Up Android Development Environment,self.java | ||||||
| 0;1356551788;4;JDK Download page error;self.java | 0,1356560732,13,How can I fetch the first X links of reddit into a list,self.java | ||||||
| 9;1356536557;12;looking for a good book website to learn intermediate core java spring;self.java | 0,1356551788,4,JDK Download page error,self.java | ||||||
| 7;1356487079;11;A popup menu like Filemaker s Any library have an implementation;self.java | 9,1356536557,12,looking for a good book website to learn intermediate core java spring,self.java | ||||||
| 1;1356455255;6;Just a Few Helpful Solr Functions;ignatyev-dev.blogspot.ru | 7,1356487079,11,A popup menu like Filemaker s Any library have an implementation,self.java | ||||||
| 13;1356433373;7;Bart s Blog Xtend the better compromise;bartnaudts.blogspot.de | 1,1356455255,6,Just a Few Helpful Solr Functions,ignatyev-dev.blogspot.ru | ||||||
| 4;1356410180;3;Beginner Question Here;self.java | 13,1356433373,7,Bart s Blog Xtend the better compromise,bartnaudts.blogspot.de | ||||||
| 19;1356283667;5;Nashorn JavaScript for the JVM;blogs.oracle.com | 4,1356410180,3,Beginner Question Here,self.java | ||||||
| 0;1356234086;5;Problem with Java memory use;self.java | 19,1356283667,5,Nashorn JavaScript for the JVM,blogs.oracle.com | ||||||
| 0;1356195953;5;Learning Java in two weeks;self.java | 0,1356234086,5,Problem with Java memory use,self.java | ||||||
| 0;1356127053;10;Twitter4J Download a Twitter Users Tweets to a Text File;github.com | 0,1356195953,5,Learning Java in two weeks,self.java | ||||||
| 20;1356118151;15;Using Apache Commons Functor functional interfaces with Java 8 lambdas cross post from r functionalprogramming;kinoshita.eti.br | 0,1356127053,10,Twitter4J Download a Twitter Users Tweets to a Text File,github.com | ||||||
| 13;1356102153;7;Date and Time in Java 8 Timezones;insightfullogic.com | 20,1356118151,15,Using Apache Commons Functor functional interfaces with Java 8 lambdas cross post from r functionalprogramming,kinoshita.eti.br | ||||||
| 10;1356088959;8;Implementing a collapsible ui repeat rows in JSF;kahimyang.info | 13,1356102153,7,Date and Time in Java 8 Timezones,insightfullogic.com | ||||||
| 8;1356034544;5;OmniFaces 1 3 is released;balusc.blogspot.com | 10,1356088959,8,Implementing a collapsible ui repeat rows in JSF,kahimyang.info | ||||||
| 1;1356027563;11;How to Configure a JNDI DataSource in the OpenShift Tomcat Cartridge;openshift.redhat.com | 8,1356034544,5,OmniFaces 1 3 is released,balusc.blogspot.com | ||||||
| 82;1356020780;7;Doomsday Sale IntelliJ 75 off today only;jetbrains.com | 1,1356027563,11,How to Configure a JNDI DataSource in the OpenShift Tomcat Cartridge,openshift.redhat.com | ||||||
| 3;1355976320;3;IntelliJ Working Directory;self.java | 82,1356020780,7,Doomsday Sale IntelliJ 75 off today only,jetbrains.com | ||||||
| 0;1355966433;5;Help with java problem please;self.java | 3,1355976320,3,IntelliJ Working Directory,self.java | ||||||
| 17;1355928745;12;What s new in Servlet 3 1 Java EE 7 moving forward;blogs.oracle.com | 0,1355966433,5,Help with java problem please,self.java | ||||||
| 11;1355864485;5;Quick poll for research project;self.java | 17,1355928745,12,What s new in Servlet 3 1 Java EE 7 moving forward,blogs.oracle.com | ||||||
| 0;1355851994;5;Eclipse Text Problem Need Help;self.java | 11,1355864485,5,Quick poll for research project,self.java | ||||||
| 29;1355823193;4;Java 8 vs Xtend;blog.efftinge.de | 0,1355851994,5,Eclipse Text Problem Need Help,self.java | ||||||
| 2;1355805047;4;Learning Java between semesters;self.java | 29,1355823193,4,Java 8 vs Xtend,blog.efftinge.de | ||||||
| 6;1355798488;11;I m a beginner programmer any tips on where to start;self.java | 2,1355805047,4,Learning Java between semesters,self.java | ||||||
| 7;1355784039;9;Java Advent Calendar far sight look at JDK 8;javaadvent.com | 6,1355798488,11,I m a beginner programmer any tips on where to start,self.java | ||||||
| 2;1355782111;9;Technical Interview coming up Suggestions Pointers Words of Wisdom;self.java | 7,1355784039,9,Java Advent Calendar far sight look at JDK 8,javaadvent.com | ||||||
| 0;1355775350;6;someone may help me out here;stackoverflow.com | 2,1355782111,9,Technical Interview coming up Suggestions Pointers Words of Wisdom,self.java | ||||||
| 2;1355765235;14;THC and a bit of Thunking Creative ways to deal with multiple return types;kingsfleet.blogspot.it | 0,1355775350,6,someone may help me out here,stackoverflow.com | ||||||
| 0;1355749586;12;Newbie here can you explain to me what class private stack is;self.java | 2,1355765235,14,THC and a bit of Thunking Creative ways to deal with multiple return types,kingsfleet.blogspot.it | ||||||
| 0;1355748318;4;When StackOverflow Goes Bad;blogs.windward.net | 0,1355749586,12,Newbie here can you explain to me what class private stack is,self.java | ||||||
| 0;1355721981;4;Java Graphics Projectile HELP;self.java | 0,1355748318,4,When StackOverflow Goes Bad,blogs.windward.net | ||||||
| 0;1355719622;12;Which one of the following statements about object oriented programming is false;self.java | 0,1355721981,4,Java Graphics Projectile HELP,self.java | ||||||
| 16;1355707814;8;What s the skinny on JavaFX these days;self.java | 0,1355719622,12,Which one of the following statements about object oriented programming is false,self.java | ||||||
| 2;1355685929;20;Can someone explain exactly what Apache Ant is How does it differ from just creating a jar file in blueJ;self.java | 16,1355707814,8,What s the skinny on JavaFX these days,self.java | ||||||
| 4;1355621071;7;Looking to add test code in Github;self.java | 2,1355685929,20,Can someone explain exactly what Apache Ant is How does it differ from just creating a jar file in blueJ,self.java | ||||||
| 7;1355613608;6;Java Version of Jarvis Must Haves;self.java | 4,1355621071,7,Looking to add test code in Github,self.java | ||||||
| 5;1355599765;6;Java Advent Calendar Functional Java Collections;javaadvent.com | 7,1355613608,6,Java Version of Jarvis Must Haves,self.java | ||||||
| 7;1355597483;13;I m working on a text based RPG and I have some questions;self.java | 5,1355599765,6,Java Advent Calendar Functional Java Collections,javaadvent.com | ||||||
| 2;1355574445;6;Java EE 7 Community Survey Results;blog.eisele.net | 7,1355597483,13,I m working on a text based RPG and I have some questions,self.java | ||||||
| 0;1355576629;4;Evolution of Java Technology;compilr.org | 2,1355574445,6,Java EE 7 Community Survey Results,blog.eisele.net | ||||||
| 18;1355574828;10;Are your Garbage Collection Logs speaking to you Censum does;blog.eisele.net | 0,1355576629,4,Evolution of Java Technology,compilr.org | ||||||
| 10;1355559380;13;What is the best GUI tool for creating a 2d platformer in Java;self.java | 18,1355574828,10,Are your Garbage Collection Logs speaking to you Censum does,blog.eisele.net | ||||||
| 0;1355555357;7;Hit me with your best arrays tutorial;self.java | 10,1355559380,13,What is the best GUI tool for creating a 2d platformer in Java,self.java | ||||||
| 10;1355542403;11;Does any one know of clean 2d graphics library for java;self.java | 0,1355555357,7,Hit me with your best arrays tutorial,self.java | ||||||
| 23;1355511507;9;Dark Juno A Dark UI Theme for Eclipse 4;rogerdudler.github.com | 10,1355542403,11,Does any one know of clean 2d graphics library for java,self.java | ||||||
| 0;1355504132;10;Java devs that work remote I have a few questions;self.java | 23,1355511507,9,Dark Juno A Dark UI Theme for Eclipse 4,rogerdudler.github.com | ||||||
| 0;1355501999;9;How do you make use of your Java knowledge;self.java | 0,1355504132,10,Java devs that work remote I have a few questions,self.java | ||||||
| 1;1355492027;5;How ClassLoader works in Java;javarevisited.blogspot.com.au | 0,1355501999,9,How do you make use of your Java knowledge,self.java | ||||||
| 0;1355489352;9;Main difference between Abstract Class and Interface Compilr org;compilr.org | 1,1355492027,5,How ClassLoader works in Java,javarevisited.blogspot.com.au | ||||||
| 48;1355487006;8;Date and Time in Java 8 Part 1;insightfullogic.com | 0,1355489352,9,Main difference between Abstract Class and Interface Compilr org,compilr.org | ||||||
| 0;1355485766;3;Java JSON problem;self.java | 48,1355487006,8,Date and Time in Java 8 Part 1,insightfullogic.com | ||||||
| 10;1355448875;16;Open source applications large small worth looking at in Java I want to understand application structure;self.java | 0,1355485766,3,Java JSON problem,self.java | ||||||
| 1;1355444452;4;lo mexor pz xxx;heavy-r.com | 10,1355448875,16,Open source applications large small worth looking at in Java I want to understand application structure,self.java | ||||||
| 0;1355402889;11;JRebel Remoting to Push Changes to Your Toaster in The Cloud;zeroturnaround.com | 1,1355444452,4,lo mexor pz xxx,heavy-r.com | ||||||
| 0;1355402734;6;Are bugs part of technical debt;swreflections.blogspot.ca | 0,1355402889,11,JRebel Remoting to Push Changes to Your Toaster in The Cloud,zeroturnaround.com | ||||||
| 2;1355400483;9;Compile and Run Java programs with Sublime Text 2;compilr.org | 0,1355402734,6,Are bugs part of technical debt,swreflections.blogspot.ca | ||||||
| 0;1355391115;4;console input like craftbukkit;self.java | 2,1355400483,9,Compile and Run Java programs with Sublime Text 2,compilr.org | ||||||
| 7;1355390023;8;Hosting suggestions needed for a java web app;self.java | 0,1355391115,4,console input like craftbukkit,self.java | ||||||
| 6;1355359227;17;Java novice here Have noticed funny performance differences across laptop and desktop Nvidia optimus related Details inside;self.java | 7,1355390023,8,Hosting suggestions needed for a java web app,self.java | ||||||
| 1;1355327090;18;Please advice which java server technology should I choose for this new web app in my new work;self.java | 6,1355359227,17,Java novice here Have noticed funny performance differences across laptop and desktop Nvidia optimus related Details inside,self.java | ||||||
| 0;1355326137;6;code to convert digits into words;compilr.org | 1,1355327090,18,Please advice which java server technology should I choose for this new web app in my new work,self.java | ||||||
| 34;1355319442;7;I want to learn REAL WORLD Java;self.java | 0,1355326137,6,code to convert digits into words,compilr.org | ||||||
| 5;1355285442;3;Hiring Java Developers;self.java | 34,1355319442,7,I want to learn REAL WORLD Java,self.java | ||||||
| 0;1355282335;14;Help How can I count the amount of a specific integer in an ArrayList;self.java | 5,1355285442,3,Hiring Java Developers,self.java | ||||||
| 1;1355272303;24;I m taking a Java 1 final tomorrow I m fairly confident but I would appreciate any tips on things to look out for;self.java | 0,1355282335,14,Help How can I count the amount of a specific integer in an ArrayList,self.java | ||||||
| 38;1355267143;6;Will Java become the next COBOL;self.java | 1,1355272303,24,I m taking a Java 1 final tomorrow I m fairly confident but I would appreciate any tips on things to look out for,self.java | ||||||
| 0;1355263047;2;Understanding recursion;imgur.com | 38,1355267143,6,Will Java become the next COBOL,self.java | ||||||
| 1;1355257558;15;How can I clear the command prompt terminal with java and make it cross platform;self.java | 0,1355263047,2,Understanding recursion,imgur.com | ||||||
| 2;1355253849;18;Is there a strategy for reducing code clutter when you are printing to the terminal alot Beginner Programmer;self.java | 1,1355257558,15,How can I clear the command prompt terminal with java and make it cross platform,self.java | ||||||
| 1;1355253049;5;BlockingQueues and multiple producer threads;self.java | 2,1355253849,18,Is there a strategy for reducing code clutter when you are printing to the terminal alot Beginner Programmer,self.java | ||||||
| 1;1355241441;6;Beginner Struggling with classes Need help;self.java | 1,1355253049,5,BlockingQueues and multiple producer threads,self.java | ||||||
| 0;1355238089;8;Simple Steps to Merge PDF files using Java;compilr.org | 1,1355241441,6,Beginner Struggling with classes Need help,self.java | ||||||
| 23;1355236940;8;Java and vs Python within a business context;self.java | 0,1355238089,8,Simple Steps to Merge PDF files using Java,compilr.org | ||||||
|  | 23,1355236940,8,Java and vs Python within a business context,self.java | ||||||
|  | |||||||
| 
 | 
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -7,10 +7,9 @@ import java.io.IOException; | |||||||
| import org.baeldung.reddit.classifier.RedditClassifier; | import org.baeldung.reddit.classifier.RedditClassifier; | ||||||
| import org.baeldung.reddit.classifier.RedditDataCollector; | import org.baeldung.reddit.classifier.RedditDataCollector; | ||||||
| import org.junit.Before; | import org.junit.Before; | ||||||
| import org.junit.Ignore; |  | ||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| 
 | 
 | ||||||
| @Ignore | //@Ignore | ||||||
| public class RedditClassifierTest { | public class RedditClassifierTest { | ||||||
| 
 | 
 | ||||||
|     private RedditClassifier classifier; |     private RedditClassifier classifier; | ||||||
| @ -27,4 +26,5 @@ public class RedditClassifierTest { | |||||||
|         System.out.println("Accuracy = " + result); |         System.out.println("Accuracy = " + result); | ||||||
|         assertTrue(result > 0.8); |         assertTrue(result > 0.8); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user