Пример #1
0
else:
	if args.trace:
		print 'training a %s classifier' % args.algorithm
	
	classifier = trainf(train_feats, **train_kwargs)

################
## evaluation ##
################

if not args.no_eval:
	if not args.no_accuracy:
		print 'accuracy: %f' % accuracy(classifier, test_feats)
	
	if args.multi and args.binary and not args.no_masi_distance:
		print 'average masi distance: %f' % (scoring.avg_masi_distance(classifier, test_feats))
	
	if not args.no_precision or not args.no_recall or not args.no_fmeasure:
		if args.multi and args.binary:
			refsets, testsets = scoring.multi_ref_test_sets(classifier, test_feats)
		else:
			refsets, testsets = scoring.ref_test_sets(classifier, test_feats)
		
		for label in labels:
			ref = refsets[label]
			test = testsets[label]
			
			if not args.no_precision:
				print '%s precision: %f' % (label, precision(ref, test) or 0)
			
			if not args.no_recall:
Пример #2
0
else:
    classifier = trainf(train_feats)

################
## evaluation ##
################
if not args.no_eval:
    if not args.no_accuracy:
        try:
            print('accuracy: %f' % accuracy(classifier, test_feats))
        except ZeroDivisionError:
            print('accuracy: 0')

    if args.multi and args.binary and not args.no_masi_distance:
        print('average masi distance: %f' %
              (scoring.avg_masi_distance(classifier, test_feats)))

    if not args.no_precision or not args.no_recall or not args.no_fmeasure:
        if args.multi and args.binary:
            refsets, testsets = scoring.multi_ref_test_sets(
                classifier, test_feats)
        else:
            refsets, testsets = scoring.ref_test_sets(classifier, test_feats)

        for label in labels:
            ref = refsets[label]
            test = testsets[label]

            if not args.no_precision:
                print('%s precision: %f' % (label, precision(ref, test) or 0))
Пример #3
0
else:
	classifier = trainf(train_feats)

################
## evaluation ##
################

if not args.no_eval and not args.cross_fold:
	if not args.no_accuracy:
		try:
			print 'accuracy: %f' % accuracy(classifier, test_feats)
		except ZeroDivisionError:
			print 'accuracy: 0'
	
	if args.multi and args.binary and not args.no_masi_distance:
		print 'average masi distance: %f' % (scoring.avg_masi_distance(classifier, test_feats))
	
	if not args.no_precision or not args.no_recall or not args.no_fmeasure:
		if args.multi and args.binary:
			refsets, testsets = scoring.multi_ref_test_sets(classifier, test_feats)
		else:
			refsets, testsets = scoring.ref_test_sets(classifier, test_feats)
		
		for label in labels:
			ref = refsets[label]
			test = testsets[label]
			
			if not args.no_precision:
				print '%s precision: %f' % (label, precision(ref, test) or 0)
			
			if not args.no_recall: