Пример #1
0
    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:
                print('%s recall: %f' % (label, recall(ref, test) or 0))

            if not args.no_fmeasure:
                print('%s f-measure: %f' % (label, f_measure(ref, test) or 0))

if args.show_most_informative and hasattr(
Пример #2
0
################
## 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:
				print '%s recall: %f' % (label, recall(ref, test) or 0)
			
			if not args.no_fmeasure:
				print '%s f-measure: %f' % (label, f_measure(ref, test) or 0)

if args.show_most_informative and args.algorithm != 'DecisionTree' and not (args.multi and args.binary):