def printResults(accuracy, precision, recall, f_measure, name="Unknown"): print '\n' print "Result of " + name + ":" print "Accuracy: ", sum(accuracy) / float(len(accuracy)) print "Precision: ", sum(precision) / float(len(precision)) print "Recall: ", sum(recall) / float(len(recall)) print "F1-measure: ", sum(f_measure) / float(len(f_measure)) print '\n' if __name__ == "__main__": xmlTrainFile = '../DATA/general-tweets-train-tagged.xml' tweets = xml.readXML(xmlTrainFile) results_folder = 'results_5/' if not os.path.exists(results_folder): os.makedirs(results_folder) tokenized_tweets = [] for tweet in tweets: tokenized_tweets.append(ut.tokenize(tweet.content, tweet.polarity)) tweets = [] labels = [] for tweet in tokenized_tweets: tweets.append(tweet['clean']) labels.append(tweet['class'])
import classify_diagnosis as diagnose import itertools def printResults(accuracy, precision, recall, f_measure, name="Unknown"): print "Result of " + name + ":" print "Accuracy: ", sum(accuracy) / float(len(accuracy)) print "Precision: ", sum(precision) / float(len(precision)) print "Recall: ", sum(recall) / float(len(recall)) print "F1-measure: ", sum(f_measure) / float(len(f_measure)) if __name__ == "__main__": xmlTrainFile = '../DATA/general-tweets-train-tagged.xml' tweets = xml.readXML(xmlTrainFile) tokenized_tweets = [] for tweet in tweets: tokenized_tweets.append(ut.tokenize(tweet.content, tweet.polarity)) tweets = [] labels = [] for tweet in tokenized_tweets: tweets.append(tweet['clean']) labels.append(tweet['class']) tweets = np.array(tweets) labels = np.array(labels) train_tweets, test_tweets, train_labels, test_labels = ut.crossValidation2(
def readMD(path): u"""Read the markdown from path and answer the compiled etree.""" xmlPath = markDown2XMLFile(path) return readXML(xmlPath)