Ejemplo n.º 1
0
		else:
			core_metrics[system] = hist_cm.getFECoreMetrics(system)

	params = np.arange(0.0, 20.0, 0.5)/100. if args.antipattern == 'god_class' else np.arange(100., 300., 5)/100.

	# Initialize progressbar
	bar = progressbar.ProgressBar(maxval=len(params), \
		widgets=['Tuning HIST parameters for ' + args.test_system + ': ' ,progressbar.Percentage()])
	bar.start()

	perfs = []
	for i, alpha in enumerate(params):
		bar.update(i)
		overall_prediction = np.empty(shape=[0, 1])
		overall_labels = np.empty(shape=[0, 1])
		for system in systems:
			smells = [entityName for entityName, ratio in core_metrics[system].items() if ratio[0]>alpha]
			prediction = detection_utils.predictFromDetect(args.antipattern, system, smells)
			overall_prediction = np.concatenate((overall_prediction, prediction), axis=0)
			overall_labels = np.concatenate((overall_labels, detection_utils.getLabels(args.antipattern, system)), axis=0)
		
		perfs.append(detection_utils.mcc(overall_prediction, overall_labels))
	bar.finish()
	output_file_path = os.path.join(ROOT_DIR, 'experiments', 'tuning', 'results', 'hist', args.antipattern, args.test_system + '.csv')

	indexes = np.argsort(np.array(perfs))
	with open(output_file_path, 'w') as file:
		file.write("Alpha;MCC\n")
		for i in reversed(indexes):
			file.write("{0:.3f};{1}\n".format(params[i], perfs[i]))
Ejemplo n.º 2
0
def predict(systemName):
	return detection_utils.predictFromDetect('feature_envy', systemName, detect(systemName))
Ejemplo n.º 3
0
def predict(systemName):
    return detection_utils.predictFromDetect('god_class', systemName,
                                             detect(systemName))
Ejemplo n.º 4
0
              for fdp in range(1, 6)]

    # Initialize progressbar
    bar = progressbar.ProgressBar(maxval=len(params), \
     widgets=['Tuning InCode parameters for ' + args.test_system + ': ' ,progressbar.Percentage()])
    bar.start()

    perfs = []
    count = 0
    for atfd, laa, fdp in params:
        count += 1
        bar.update(count)
        overall_prediction = np.empty(shape=[0, 1])
        for system in systems:
            prediction = detection_utils.predictFromDetect(
                'feature_envy', system,
                incode.detect_with_params(system, atfd, laa, fdp))
            overall_prediction = np.concatenate(
                (overall_prediction, prediction), axis=0)
        perfs.append(detection_utils.mcc(overall_prediction, overall_labels))
    bar.finish()

    output_file_path = os.path.join(ROOT_DIR, 'experiments', 'tuning',
                                    'results', 'incode',
                                    args.test_system + '.csv')

    indexes = np.argsort(np.array(perfs))
    with open(output_file_path, 'w') as file:
        file.write("ATFD;LAA;FDP;MCC\n")
        for i in reversed(indexes):
            atfd, laa, fdp = params[i]