Ejemplo n.º 1
0
  tweets = buckets.buckets[0]

  tweetTexts = []
  tweetIds = []

  for tweet in tweets:
    tweetTexts.append(tweet.txt)
    tweetIds.append(tweet)

  classifierSettings = {'classes': modelBuilder.totalClassCounts, 'useMentions': 1, 'useLinks': 1}

  classifier = Classifier(classifierSettings)

  classifier.setStopwords(stopwords)
  classifier.setGrams(grams)

  guesses = classifier.classifyEntries(tweetTexts, tweetIds)

  correctGuesses = 0
  
  locationGuesses = {}
  correctLocationGuesses = {}

  for theClass in modelBuilder.totalClassCounts:
    locationGuesses[theClass] = 0
    correctLocationGuesses[theClass] = 0

  for guess in guesses:
    writer.writerow({'id': guess['descriptor'].id, 'user': guess['descriptor'].user, 'txt': guess['descriptor'].txt, 'guessedLocation': guess['class'], 'realLocation': guess['descriptor'].location, 'certainty': guess['likelihood'], 'correct': guess['class'] == guess['descriptor'].location})
    print guess['class'] + ' =? ' + guess['descriptor'].location