Ejemplo n.º 1
0
			acc = TestAccuracy(semisup_classifier, classA_test, classB_test, thresh)
			print 'accuracy {0}'.format(acc)

			segfun = semisup_classifier.segfun
			with open("../models/init_nonum_semi%i.pkl" % (iter_num + 1), 'w') as f:
				semisup_classifier.segfun = None
				cPickle.dump(semisup_classifier, f)
			semisup_classifier.segfun = segfun
		return semisup_classifier


if __name__ == '__main__':
	target = 'gender'
	whereclause = "where gender is not ''" if target == 'gender' else ''
	model = segmenter.load_model('../models/idmorphs_naworl.model')
	segfun = segmenter.morph_segmenter(model, match='[a-z]+')

	# model_semi = segmenter.load_model('../models/idmorphs.model')
	# segfun_semi = segmenter.morph_segmenter(model_semi, match='[a-z]+')

	users = segmenter.get_users_from_db(whereclause=whereclause)
	male_ids = [user.id for user in users if user.gender == 'M']
	female_ids = [user.id for user in users if user.gender == 'F']

	# unlabeled_users = segmenter.get_users_from_db(tablename='naver')
	# unknown_ids = [user.id for user in unlabeled_users]
	unknown_ids = None
	cls = DoTest(male_ids, female_ids, segfun, unknown_ids, balance=False)

	# cls = cPickle.load(open("../models/init_nonum_semi3.pkl"))
Ejemplo n.º 2
0
__author__ = 'hee'

import pytagcloud

import segmenter


if __name__ == '__main__':
    # model_path = "../models/idmorphs_naworl.model"
    model_path = "../models/okcupid.model"
    model = segmenter.load_model(model_path)

    top_morphs = segmenter.top_morphs(model, 100, exclude_number=True, min_length=2)
    tags = pytagcloud.make_tags(top_morphs, maxsize=130)

    print "here"
    pytagcloud.create_tag_image(tags, "../results/okcupid.bmp", size=(900, 600), rectangular=False)