Examples of FullAlchemyClassification


Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

    double cosineSum = 0.0;
    int cosineCount = 0;
    double squareSum = 0.0;
    for(Long uid : uids) {
      if(topicType.equals("alchemy")) {
        FullAlchemyClassification baseline = new FullAlchemyClassification(uid);
        FullLLDAClassification inferred = new FullLLDAClassification(topicType,alpha,fewerProfiles,reduction,uid);
        if(inferred.getCategorySet().isEmpty()) continue;
        double sim = cosineKSimilarity(baseline,inferred,k);
        cosineSum += sim;
        squareSum += sim*sim;
 
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

    double cosineSum = 0.0;
    int cosineCount = 0;
    double squareSum = 0.0;
    for(Long uid : Tools.getCSVUserIDs()) {
      if(topicType.equals("alchemy")) {
        FullAlchemyClassification fac = new FullAlchemyClassification(uid);
        FullSVMClassification fsm = new FullSVMClassification(topicType,uid);
        double sim = fsm.cosineSimilarity(fac);
        cosineSum += sim;
        squareSum += sim*sim;
        cosineCount++;
 
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

    double cosineSum = 0.0;
    int cosineCount = 0;
    double squareSum = 0.0;
    for(Long uid : Tools.getCSVUserIDs()) {
      if(topicType.equals("alchemy")) {
        FullAlchemyClassification fac = new FullAlchemyClassification(uid);
        FullSVMClassification fsm = new FullSVMClassification(topicType,uid);
        double sim = cosineKSimilarity(fac,fsm,k);
        cosineSum += sim;
        squareSum += sim*sim;
        cosineCount++;
 
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

    //firstly create the baseline profile sets
    //IMPORTANT: profiles with no classifications aren't included in sets!
    for(Long uid : uids) {
      String topTopic = "";
      if(topicType.equals("alchemy")) {
        FullAlchemyClassification c = new FullAlchemyClassification(uid);
        if(c.getCategorySet().size()==0) continue;
        topTopic = c.getCategorySet().toArray(new String[0])[0];
      } else if(topicType.equals("calais")) {
        FullCalaisClassification c = new FullCalaisClassification(uid);
        if(c.getCategorySet().size()==0) continue;
        topTopic = c.getCategorySet().toArray(new String[0])[0];
      } else if(topicType.equals("textwiseproper")) {
        FullTextwiseClassification c = new FullTextwiseClassification(uid,true);
        if(c.getCategorySet().size()==0) continue;
        topTopic = c.getCategorySet().toArray(new String[0])[0];
      }
      if(profileSets.containsKey(topTopic)) {
        profileSets.get(topTopic).add(uid);
      } else {
        Set<Long> newSet = new HashSet<Long>();
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

          FileOutputStream fileOut = new FileOutputStream("cosinesims/"+topicType+"-"+alpha+".csv");
          PrintWriter writeOut = new PrintWriter(fileOut);
          writeOut.println("\"uid\",\"similarity\"");
          if(topicType.equals("alchemy")) {
            for(long uid : uids) {
              FullAlchemyClassification baseline = new FullAlchemyClassification(uid);
              FullLLDAClassification llda = new FullLLDAClassification(topicType,alpha,uid);
              writeOut.println(uid+","+llda.cosineSimilarity(baseline));
            }
          } else if(topicType.equals("calais")) {
            for(long uid : uids) {
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

    double squareSum = 0.0;
    int cosineCount = 0;
    for(Long uid : uids) {
      //System.out.println(cosineCount);
      if(topicType.equals("alchemy")) {
        FullAlchemyClassification baseline = new FullAlchemyClassification(uid);
        FullLLDAClassification inferred = new FullLLDAClassification(topicType,alpha,uid);
        double sim = inferred.jsDivergence(baseline);
        cosineSum += sim;
        squareSum += sim*sim;
        cosineCount++;
 
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

    }
    Set<Long> noClassifications = new HashSet<Long>();
    for(Long uid : Tools.getCSVUserIDs()) {
      String topTopic = "";
      if(topicType.equals("alchemy")) {
        FullAlchemyClassification c = new FullAlchemyClassification(uid);
        if(c.getCategorySet().size()==0) {
          noClassifications.add(uid);
          continue;
        }
        topTopic = c.getCategorySet().toArray(new String[1])[0];
      } else if(topicType.equals("calais")) {
        FullCalaisClassification c = new FullCalaisClassification(uid);
        if(c.getCategorySet().size()==0) {
          noClassifications.add(uid);
          continue;
        }
        topTopic = c.getCategorySet().toArray(new String[1])[0];
        if(topTopic.equals("Other") && c.getCategorySet().size() < 2) {
          noClassifications.add(uid);
          continue;
        } else if(topTopic.equals("Other")) {
          topTopic = c.getCategorySet().toArray(new String[1])[1];
        }
      } else if(topicType.equals("textwise")) {
        FullTextwiseClassification c = new FullTextwiseClassification(uid,true);
        if(c.getCategorySet().size()==0) {
          noClassifications.add(uid);
          continue;
        }
        topTopic = c.getCategorySet().toArray(new String[1])[0];
      }
      if(svm) {
        FullSVMClassification svmClassification = new FullSVMClassification(topicType,uid);
        String topSVMTopic = svmClassification.getCategorySet().toArray(new String[1])[0];
        gtTopicSets.get(topTopic).add(uid);
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

    //need a mapping between documents and toptopics
    topTopics = new ArrayList<String>();
    for(int i=0; i<numDocs; i++) {
      String topTopic = "";
      if(topicType.equals("alchemy")) {
        FullAlchemyClassification cl = new FullAlchemyClassification(docIDLookup.get(i).getId());
        if(cl.getCategorySet().size()==0) topTopic="NO_TOP_TOPIC";
        else topTopic = cl.getCategorySet().toArray(new String[0])[0];
      } else if(topicType.equals("calais")) {
        FullCalaisClassification cl = new FullCalaisClassification(docIDLookup.get(i).getId());
        if(cl.getCategorySet().size()==0) topTopic="NO_TOP_TOPIC";
        else topTopic = cl.getCategorySet().toArray(new String[0])[0];
        //Required because of Calais' stupid classification system
        if(topTopic.equals("Other")) {
          if(cl.getCategorySet().size()==1) topTopic="NO_TOP_TOPIC";
          else topTopic = cl.getCategorySet().toArray(new String[0])[1];
        }
      } else if(topicType.equals("textwise")) {
        FullTextwiseClassification cl = new FullTextwiseClassification(docIDLookup.get(i).getId(),true);
        if(cl.getCategorySet().size()==0) topTopic="NO_TOP_TOPIC";
        else topTopic = cl.getCategorySet().toArray(new String[0])[0];
      }
      if(verbose) System.out.println("Document "+i+" found to have top topic "+topTopic+", id "+topicIDs.get(topTopic));
      topTopics.add(topTopic);
     
      //add this id to the topTopics map
View Full Code Here

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

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

Examples of uk.ac.cam.ha293.tweetlabel.classify.FullAlchemyClassification

  public void fillAlchemyJS() {
    //get clasifications
    System.out.println("Filling from Alchemy classifications");
    FullAlchemyClassification[] classifications = new FullAlchemyClassification[d];
    for(long id : Tools.getCSVUserIDs()) {
      classifications[indexLookup.get(id)] = new FullAlchemyClassification(id);
    }
   
    //cosine similarities!
    for(int m=0; m<d; m++) {
      System.out.println("On row "+m);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.