public static void main (String[] args) throws IOException { InstanceList training = InstanceList.load (new File(args[0])); int numTopics = args.length > 1 ? Integer.parseInt(args[1]) : 200; InstanceList testing = args.length > 2 ? InstanceList.load (new File(args[2])) : null; LDAHyper lda = new LDAHyper (numTopics, 50.0, 0.01); lda.printLogLikelihood = true; lda.setTopicDisplay(50,7); lda.addInstances(training); lda.estimate(); }
public static void main (String[] args) throws IOException { InstanceList training = InstanceList.load (new File(args[0])); int numTopics = args.length > 1 ? Integer.parseInt(args[1]) : 200; InstanceList testing = args.length > 2 ? InstanceList.load (new File(args[2])) : null; LDAHyper lda = new LDAHyper (numTopics, 50.0, 0.01); lda.printLogLikelihood = true; lda.setTopicDisplay(50,7); lda.addInstances(training); lda.estimate(); }
public static void main (String[] args) throws IOException { InstanceList training = InstanceList.load (new File(args[0])); int numTopics = args.length > 1 ? Integer.parseInt(args[1]) : 200; InstanceList testing = args.length > 2 ? InstanceList.load (new File(args[2])) : null; LDAHyper lda = new LDAHyper (numTopics, 50.0, 0.01); lda.printLogLikelihood = true; lda.setTopicDisplay(50,7); lda.addInstances(training); lda.estimate(); }
public void addInstances (InstanceList training) { initializeForTypes (training.getDataAlphabet()); ArrayList<LabelSequence> topicSequences = new ArrayList<LabelSequence>(); for (Instance instance : training) { LabelSequence topicSequence = new LabelSequence(topicAlphabet, new int[instanceLength(instance)]); if (false) // This method not yet obeying its last "false" argument, and must be for this to work sampleTopicsForOneDoc((FeatureSequence)instance.getData(), topicSequence, false, false); else { Randoms r = new Randoms(); int[] topics = topicSequence.getFeatures(); for (int i = 0; i < topics.length; i++) topics[i] = r.nextInt(numTopics); } topicSequences.add (topicSequence); } addInstances (training, topicSequences); }
public void addInstances (InstanceList training) { initializeForTypes (training.getDataAlphabet()); ArrayList<LabelSequence> topicSequences = new ArrayList<LabelSequence>(); for (Instance instance : training) { LabelSequence topicSequence = new LabelSequence(topicAlphabet, new int[instanceLength(instance)]); if (false) // This method not yet obeying its last "false" argument, and must be for this to work sampleTopicsForOneDoc((FeatureSequence)instance.getData(), topicSequence, false, false); else { Randoms r = new Randoms(); int[] topics = topicSequence.getFeatures(); for (int i = 0; i < topics.length; i++) topics[i] = r.nextInt(numTopics); } topicSequences.add (topicSequence); } addInstances (training, topicSequences); }
public void addInstances (InstanceList training) { initializeForTypes (training.getDataAlphabet()); ArrayList<LabelSequence> topicSequences = new ArrayList<LabelSequence>(); for (Instance instance : training) { LabelSequence topicSequence = new LabelSequence(topicAlphabet, new int[instanceLength(instance)]); if (false) // This method not yet obeying its last "false" argument, and must be for this to work sampleTopicsForOneDoc((FeatureSequence)instance.getData(), topicSequence, false, false); else { Randoms r = new Randoms(); int[] topics = topicSequence.getFeatures(); for (int i = 0; i < topics.length; i++) topics[i] = r.nextInt(numTopics); } topicSequences.add (topicSequence); } addInstances (training, topicSequences); }