import sys sys.path.append('..') from ABClassifier.ABClassifier import ABClassifier import numpy as np ab = ABClassifier() ab.download_cursors(limit_unlabeled = 1000, limit_labeled = 1000) ab.run_lsa(k=100) ab.compute_context_vectors() pos_labeled_pws = ab.pairwise_similarity(ab.pos_labeled_cv_list) neg_labeled_pws = ab.pairwise_similarity(ab.neg_labeled_cv_list) unlabeled_pws = ab.pairwise_similarity(ab.unlabeled_cv_list) print "done getting pws" x = np.array(pos_labeled_pws.values()) a = np.asarray(x) np.savetxt('pos_labeled.csv', a, delimiter=",") y = np.array(neg_labeled_pws.values()) b = np.asarray(y) np.savetxt('neg_labeled.csv', b, delimiter=",") z = np.array(unlabeled_pws.values()) c = np.asarray(z) np.savetxt('unlabeled.csv', c, delimiter=",")
import sys sys.path.append('../..') from ABClassifier.ABClassifier import ABClassifier import numpy as np from sklearn.metrics.pairwise import cosine_similarity save_location = '../../experiment_data/experiment_2' k_list = [5, 10, 25, 50, 100, 150, 250, 500] for k in k_list: ab = ABClassifier() ab.download_cursors(limit_unlabeled=1000, limit_labeled=1000) ab.run_lsa(k=k) ab.compute_context_vectors(save_location=save_location) print "Performing pairwise similarity measures..." pos_labeled_pws = cosine_similarity(ab.pos_labeled_cv_list).flatten() neg_labeled_pws = cosine_similarity(ab.neg_labeled_cv_list).flatten() unlabeled_pws = cosine_similarity(ab.unlabeled_cv_list).flatten() print "Done." print "Saving..." np.savetxt(save_location + '/pw_pos_' + str(k) + '.csv', pos_labeled_pws, delimiter=",") np.savetxt(save_location + '/pw_neg_' + str(k) + '.csv',
import sys sys.path.append('..') from ABClassifier.ABClassifier import ABClassifier import numpy as np ab = ABClassifier() ab.download_cursors(limit_unlabeled=10000, limit_labeled=10000) ab.run_lsa(k=100) ab.compute_context_vectors() pos_labeled_pws = ab.pairwise_similarity(ab.pos_labeled_cv_list) neg_labeled_pws = ab.pairwise_similarity(ab.neg_labeled_cv_list) unlabeled_pws = ab.pairwise_similarity(ab.unlabeled_cv_list) print "done getting pws" x = np.array(pos_labeled_pws.values()) a = np.asarray(x) np.savetxt('pos_labeled.csv', a, delimiter=",") y = np.array(neg_labeled_pws.values()) b = np.asarray(y) np.savetxt('neg_labeled.csv', b, delimiter=",") z = np.array(unlabeled_pws.values()) c = np.asarray(z) np.savetxt('unlabeled.csv', c, delimiter=",")
-Vary the number of input tweets to the Co-Occurrence Matrix """ import sys sys.path.append('../..') from ABClassifier.ABClassifier import ABClassifier import numpy as np from sklearn.metrics.pairwise import cosine_similarity save_location = '../../experiment_data/experiment_1b' ab = ABClassifier() ab.download_cursors(limit_unlabeled = 2500, limit_labeled = 2500) ab.run_lsa(k=100) ab.compute_context_vectors(save_location = save_location) print "Performing pairwise similarity measures..." pos_labeled_pws = ab.pairwise_similarity(ab.pos_labeled_cv_list) neg_labeled_pws = ab.pairwise_similarity(ab.neg_labeled_cv_list) unlabeled_pws = ab.pairwise_similarity(ab.unlabeled_cv_list) #pos_neg_pws = cosine_similarity(ab.pos_labeled_cv_list, ab.neg_labeled_cv_list) #pos_unl_pws = cosine_similarity(ab.pos_labeled_cv_list, ab.unlabeled_cv_list) #neg_unl_pws = cosine_similarity(ab.neg_labeled_cv_list, ab.unlabeled_labeled_cv_list) print "Done." print "Saving..."