Package uk.ac.cam.ha293.tweetlabel.util

Examples of uk.ac.cam.ha293.tweetlabel.util.Tools


 
  public void fillLLDA(String topicType, double alpha, boolean fewerProfiles, int reduction) {
    //System.out.println("Filling from LLDA-inferred "+topicType+" classifications");
    FullLLDAClassification[] classifications = new FullLLDAClassification[d];
    for(long id : Tools.getCSVUserIDs()) {
      classifications[indexLookup.get(id)] = new FullLLDAClassification(topicType,alpha,fewerProfiles,reduction,id);
    }
   
    //cosine similarities!
    for(int m=0; m<d; m++) {
      //System.out.println("On row "+m);
View Full Code Here


 
  public void fillKLLDA(String topicType, double alpha, int k) {
    //System.out.println("Filling from LLDA-inferred "+topicType+" classifications");
    FullLLDAClassification[] classifications = new FullLLDAClassification[d];
    for(long id : Tools.getCSVUserIDs()) {
      classifications[indexLookup.get(id)] = new FullLLDAClassification(topicType,alpha,id);
    }
   
    //cosine similarities!
    for(int m=0; m<d; m++) {
      //System.out.println("On row "+m);
View Full Code Here

 
  public void fillLLDAJS(String topicType, double alpha) {
    System.out.println("Filling from LLDA-inferred "+topicType+" classifications");
    FullLLDAClassification[] classifications = new FullLLDAClassification[d];
    for(long id : Tools.getCSVUserIDs()) {
      classifications[indexLookup.get(id)] = new FullLLDAClassification(topicType,alpha,id);
    }
   
    //cosine similarities!
    for(int m=0; m<d; m++) {
      System.out.println("On row "+m);
View Full Code Here

          classifications.add(classification);
        }
      }
    } else {
      for(long id : Tools.getCSVUserIDs()) {
        FullLLDAClassification c = new FullLLDAClassification(topicType,alpha,id);
        Map<String,Double> classification = new HashMap<String,Double>();
        int topicCount = 0;
        for(String topic : c.getCategorySet()) {
          if(topicCount == topTopics) break;
          if(topic.equals("Other")) continue;
          classification.put(topic, c.getScore(topic));
          topicCount++;
        }
        classifications.add(classification);
      }
    }
View Full Code Here

      FullLDAClassification c = new FullLDAClassification(uid,1000,100,0,alpha);
      for(String cat : c.getCategorySet()) {
        valueSet.add(c.getScore(cat));
      }
    } else if(topicType.equals("alchemy")) {
      FullLLDAClassification c = new FullLLDAClassification("alchemy",alpha,uid);
      for(String cat : c.getCategorySet()) {
        valueSet.add(c.getScore(cat));
      }
    } else if(topicType.equals("calais")) {
      FullLLDAClassification c = new FullLLDAClassification("calais",alpha,uid);
      for(String cat : c.getCategorySet()) {
        valueSet.add(c.getScore(cat));
      }
    } else if(topicType.equals("textwise")) {
      FullLLDAClassification c = new FullLLDAClassification("textwise",alpha,uid);
      for(String cat : c.getCategorySet()) {
        valueSet.add(c.getScore(cat));
      }
    }
    return valueSet;
  }
View Full Code Here

          double cosineSum = 0.0;
          int cosineCount = 0;
          for(Long uid : uids) {
            if(topicType.equals("alchemy")) {
              FullAlchemyClassification baseline = new FullAlchemyClassification(uid);
              FullLLDAClassification llda = new FullLLDAClassification(topicType,alpha,false,reduction,uid);
              double sim = llda.cosineSimilarity(baseline);
              cosineSum += sim;
              cosineCount++;
            } else if(topicType.equals("calais")) {
              FullCalaisClassification baseline = new FullCalaisClassification(uid);
              FullLLDAClassification llda = new FullLLDAClassification(topicType,alpha,false,reduction,uid);
              double sim = llda.cosineSimilarity(baseline);
              cosineSum += sim;
              cosineCount++;
            } else if(topicType.equals("textwiseproper")) {
              FullTextwiseClassification baseline = new FullTextwiseClassification(uid,true);
              FullLLDAClassification llda = new FullLLDAClassification(topicType,alpha,false,reduction,uid);
              double sim = llda.cosineSimilarity(baseline);
              cosineSum += sim;
              cosineCount++;
            }
          }
          double avgCosine = cosineSum/cosineCount;
View Full Code Here

        totalCount++;
        Set<String> lldaTopicSet = new HashSet<String>();
        Set<String> baselineTopicSet = new HashSet<String>();
        String modTopic = topicType;
        if(modTopic.equals("textwise")) modTopic = "textwiseproper";
        FullLLDAClassification llda = new FullLLDAClassification(modTopic,alpha,uid);
        int kCount=0;
        for(String topic : llda.getCategorySet()) {
          if(kCount == k) break;
          kCount++;
          lldaTopicSet.add(topic);
        }
        if(topicType.equals("alchemy")) {
View Full Code Here

    Map<String,Double> proportions = new HashMap<String,Double>();
    for(String topic : Tools.getTopics(topicType)) {
      proportions.put(topic, 0.0);
    }
    for(Long uid : Tools.getCSVUserIDs()) {
      FullLLDAClassification c = new FullLLDAClassification(topicType,alpha,uid);
      if(c.getCategorySet().size()==0) continue;
      String topTopic = c.getCategorySet().toArray(new String[1])[0];
      proportions.put(topTopic,proportions.get(topTopic)+1.0);
    }
    double sum = 0.0;
    for(String topic : proportions.keySet()) {
      sum += proportions.get(topic);
View Full Code Here

      //System.out.println(totalCount);
      Set<String> lldaTopicSet = new HashSet<String>();
      Set<String> baselineTopicSet = new HashSet<String>();
      String modTopic = topicType;
      if(modTopic.equals("textwise")) modTopic = "textwiseproper";
      FullLLDAClassification llda = new FullLLDAClassification(modTopic,alpha,fewerProfiles,reduction,uid);
      if(llda.getCategorySet().isEmpty()) continue;
      totalCount++;
      int kCount=0;
      for(String topic : llda.getCategorySet()) {
        if(kCount == k) break;
        kCount++;
        lldaTopicSet.add(topic);
      }
      if(topicType.equals("alchemy")) {
View Full Code Here

 
  public void fillSVM(String topicType) {
    System.out.println("Filling from SVM "+topicType+" classifications");
    FullSVMClassification[] classifications = new FullSVMClassification[d];
    for(long id : Tools.getCSVUserIDs()) {
      classifications[indexLookup.get(id)] = new FullSVMClassification(topicType,id);
    }
   
    //cosine similarities!
    for(int m=0; m<d; m++) {
      System.out.println("On row "+m);
View Full Code Here

TOP

Related Classes of uk.ac.cam.ha293.tweetlabel.util.Tools

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.