From 3ce21ccc79c9289cb8d0c68cbaa512eaa36d4601 Mon Sep 17 00:00:00 2001 From: Antoine Barbez Date: Mon, 22 Apr 2019 20:07:36 -0400 Subject: [PATCH] implemented new training, tuning and predict scripts for smad and asci --- .DS_Store | Bin 6148 -> 6148 bytes detection_tools/feature_envy/hist.py | 16 ++- detection_tools/feature_envy/incode.py | 16 +++ detection_tools/feature_envy/jdeodorant.py | 15 +++ detection_tools/god_class/decor.py | 18 +++- detection_tools/god_class/hist.py | 13 +++ detection_tools/god_class/jdeodorant.py | 17 ++- experiments/.DS_Store | Bin 6148 -> 6148 bytes experiments/training/.DS_Store | Bin 0 -> 6148 bytes experiments/training/context.py | 5 +- experiments/training/train_asci.py | 101 ++++++++++++++++++ experiments/training/train_smad.py | 25 +---- experiments/tuning/.DS_Store | Bin 0 -> 6148 bytes experiments/tuning/context.py | 5 +- experiments/tuning/results/.DS_Store | Bin 0 -> 6148 bytes experiments/tuning/results/asci/.DS_Store | Bin 0 -> 6148 bytes .../tuning/results/asci/god_class/.DS_Store | Bin 0 -> 6148 bytes experiments/tuning/results/smad/.DS_Store | Bin 0 -> 6148 bytes .../tuning/results/smad/god_class/.DS_Store | Bin 0 -> 6148 bytes .../tuning/results/smad_god_class_jedit.csv | 101 ------------------ experiments/tuning/tune_asci.py | 93 ++++++++++++++++ experiments/tuning/tune_smad.py | 19 +++- neural_networks/.DS_Store | Bin 6148 -> 6148 bytes neural_networks/asci/.DS_Store | Bin 0 -> 6148 bytes .../asci}/__init__.py | 0 neural_networks/asci/context.py | 15 +++ neural_networks/asci/predict.py | 29 +++++ neural_networks/asci/trained_models/.DS_Store | Bin 0 -> 6148 bytes neural_networks/loss.py | 23 ---- neural_networks/smad/.DS_Store | Bin 6148 -> 6148 bytes neural_networks/smad/context.py | 3 +- neural_networks/smad/model.py | 23 +++- neural_networks/smad/predict.py | 34 ++++++ .../smad/trained_models/god_class/.DS_Store | Bin 6148 -> 6148 bytes utils/dataUtils.py | 10 +- utils/nnUtils.py | 64 ++++++----- 36 files changed, 460 insertions(+), 185 deletions(-) create mode 100644 experiments/training/.DS_Store create mode 100644 experiments/training/train_asci.py create mode 100644 experiments/tuning/.DS_Store create mode 100644 experiments/tuning/results/.DS_Store create mode 100644 experiments/tuning/results/asci/.DS_Store create mode 100644 experiments/tuning/results/asci/god_class/.DS_Store create mode 100644 experiments/tuning/results/smad/.DS_Store create mode 100644 experiments/tuning/results/smad/god_class/.DS_Store delete mode 100644 experiments/tuning/results/smad_god_class_jedit.csv create mode 100644 experiments/tuning/tune_asci.py create mode 100644 neural_networks/asci/.DS_Store rename {experiments/training => neural_networks/asci}/__init__.py (100%) create mode 100644 neural_networks/asci/context.py create mode 100644 neural_networks/asci/predict.py create mode 100644 neural_networks/asci/trained_models/.DS_Store delete mode 100644 neural_networks/loss.py create mode 100644 neural_networks/smad/predict.py diff --git a/.DS_Store b/.DS_Store index 3cee62a72bceba8a935b785db58cf79e22beb149..4ff05ff19d77c005b9d2a78706d7e5275b286cc6 100644 GIT binary patch delta 20 bcmZoMXffC@mywZi@;pX+M#jze7}dl8M6Ct- delta 20 bcmZoMXffC@mywZS@;pX+MuyGz7}dl8M4JWp diff --git a/detection_tools/feature_envy/hist.py b/detection_tools/feature_envy/hist.py index ec5b7f4..d4990a1 100644 --- a/detection_tools/feature_envy/hist.py +++ b/detection_tools/feature_envy/hist.py @@ -86,4 +86,18 @@ def getSmells(systemName, alpha=2.6): smells.append(m + ';' + c) - return smells \ No newline at end of file + return smells + + +def predict(systemName): + entities = dataUtils.getEntities('feature_envy', systemName) + smells = getSmells(systemName) + + prediction = [] + for entity in entities: + if entity in smells: + prediction.append([1.]) + else: + prediction.append([0.]) + + return np.array(prediction) \ No newline at end of file diff --git a/detection_tools/feature_envy/incode.py b/detection_tools/feature_envy/incode.py index 76e0580..44b8e3f 100644 --- a/detection_tools/feature_envy/incode.py +++ b/detection_tools/feature_envy/incode.py @@ -1,6 +1,8 @@ from __future__ import division from context import ROOT_DIR, dataUtils, entityUtils +import numpy as np + import csv import os @@ -84,4 +86,18 @@ def getEnviedClasses(className, classAttributeMap, atfd, laa, fdp): return enviedClass +def predict(systemName): + entities = dataUtils.getEntities('feature_envy', systemName) + smells = getSmells(systemName) + + prediction = [] + for entity in entities: + if entity in smells: + prediction.append([1.]) + else: + prediction.append([0.]) + + return np.array(prediction) + + \ No newline at end of file diff --git a/detection_tools/feature_envy/jdeodorant.py b/detection_tools/feature_envy/jdeodorant.py index e521404..e665ca5 100644 --- a/detection_tools/feature_envy/jdeodorant.py +++ b/detection_tools/feature_envy/jdeodorant.py @@ -1,6 +1,8 @@ from __future__ import division from context import ROOT_DIR, dataUtils, entityUtils +import numpy as np + import os def getSmells(systemName): @@ -23,3 +25,16 @@ def getSmells(systemName): return list(set(smells)) +def predict(systemName): + entities = dataUtils.getEntities('feature_envy', systemName) + smells = getSmells(systemName) + + prediction = [] + for entity in entities: + if entity in smells: + prediction.append([1.]) + else: + prediction.append([0.]) + + return np.array(prediction) + diff --git a/detection_tools/god_class/decor.py b/detection_tools/god_class/decor.py index 0a0888e..df85b21 100644 --- a/detection_tools/god_class/decor.py +++ b/detection_tools/god_class/decor.py @@ -1,5 +1,7 @@ from __future__ import division -from context import ROOT_DIR +from context import ROOT_DIR, dataUtils + +import numpy as np import csv import os @@ -31,3 +33,17 @@ def getSmells(systemName): smells.append(row['ClassName']) return smells + + +def predict(systemName): + entities = dataUtils.getEntities('god_class', systemName) + smells = getSmells(systemName) + + prediction = [] + for entity in entities: + if entity in smells: + prediction.append([1.]) + else: + prediction.append([0.]) + + return np.array(prediction) diff --git a/detection_tools/god_class/hist.py b/detection_tools/god_class/hist.py index e9fa2ad..6a10e31 100644 --- a/detection_tools/god_class/hist.py +++ b/detection_tools/god_class/hist.py @@ -42,3 +42,16 @@ def getSmells(systemName, alpha=8.0): return smells +def predict(systemName): + entities = dataUtils.getEntities('god_class', systemName) + smells = getSmells(systemName) + + prediction = [] + for entity in entities: + if entity in smells: + prediction.append([1.]) + else: + prediction.append([0.]) + + return np.array(prediction) + diff --git a/detection_tools/god_class/jdeodorant.py b/detection_tools/god_class/jdeodorant.py index cf12334..5304e01 100644 --- a/detection_tools/god_class/jdeodorant.py +++ b/detection_tools/god_class/jdeodorant.py @@ -1,4 +1,6 @@ -from context import ROOT_DIR +from context import ROOT_DIR, dataUtils + +import numpy as np import os @@ -8,3 +10,16 @@ def getSmells(systemName): with open(JDBlobFile, 'r') as file: return list(set([line.split()[0] for line in file])) + +def predict(systemName): + entities = dataUtils.getEntities('god_class', systemName) + smells = getSmells(systemName) + + prediction = [] + for entity in entities: + if entity in smells: + prediction.append([1.]) + else: + prediction.append([0.]) + + return np.array(prediction) diff --git a/experiments/.DS_Store b/experiments/.DS_Store index 068d136b80edf43db8ff57dc80dbd1c3bf2be3f6..491ccf6ba22ae3e1e3ad78b647566a665690fafd 100644 GIT binary patch delta 67 zcmZoMXfc@J&nUDpU^g?P&}2gvnavt3xlEiX#mPBI`T02vlN;G~i?T74FqAUnF=PU9 PI!tO};mpnK9Dn%%q~{d+ delta 35 rcmZoMXfc@J&nU1lU^g?Pz+^)fnavt3xlEHcu`Qoia(Xj6$6tN`$eau7 diff --git a/experiments/training/.DS_Store b/experiments/training/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0?LV7}B^*xxbJ<2q&u zV)F#C7fy-H&@8FMq*{#_mUQM@)%C(DG3l@xKCDi*noulG=lfff!+N5k6p#Yf3M_KF z_Wr-4|1kewleCipQs7@HV9V`(yWy3px6Ur-y|&Sx>0a|mcjG!J4AG8>(T=(CcKjGc bS=W5c=e=-B3_9~cC+cUwb&*MdzgFM^$#@mR literal 0 HcmV?d00001 diff --git a/experiments/tuning/context.py b/experiments/tuning/context.py index e47e0de..f4b7cb1 100644 --- a/experiments/tuning/context.py +++ b/experiments/tuning/context.py @@ -5,5 +5,6 @@ sys.path.insert(0, ROOT_DIR) import utils.nnUtils as nnUtils -import experiments.training.train_smad as train_smad -import neural_networks.smad.model as md \ No newline at end of file + +import neural_networks.asci.predict as asci +import neural_networks.smad.model as md \ No newline at end of file diff --git a/experiments/tuning/results/.DS_Store b/experiments/tuning/results/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e951c0ca5c9f8f92cf4832ba73207ca16af30777 GIT binary patch literal 6148 zcmeHK!AitH49(OYs)Fp%}Op_rj{F^<2~A;>FN-=#Y!{$R|fd*a(bnK z8v2;t-)QXK_NONF=gA31UmvQf?m`V;@%?c3m>s^JrW^L5{ndYdU)g)09tpMcWYoBt zjQTc{8T}i{sDCAy$(e0x3>X8(zy&dYn$1$&3fgE47z4(@$N+yIJe09ijDqRYfg!a3 zz#Qfzm~$_|Fq^BaDB9M@V8eSxy@x+pk?V3JBP f)^aJnhbDpD^8{EbMnPC0_9KvJu)!GkQwDwjt%664 literal 0 HcmV?d00001 diff --git a/experiments/tuning/results/asci/.DS_Store b/experiments/tuning/results/asci/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f95a71e9c10300830751f4b1b5e305647e7aa374 GIT binary patch literal 6148 zcmeHKu};G<5Iu(usbJ{H=wGN1VqpkX7+L5C07*(25?m3A#1`=%d<=iaJNr~p#jV6r zA#^95pL4!*e9w`cBO)_fS5u-15v5SZWQ-;vJkC0hL@XR<{2Xg~p#|MRp9kJ*_=^ni z-ks1RcI<&(slR`3^je&xS<8mwhZ zOLA18N`dezNwyX>1YJ83q8IB|r@#?4Y@p*P5sYE@0lGyJVS$>aI?J5JxfHH7c z2KbPKq{jiZRR)v+WnjYqpAQzwmmOH>qunPzaM1KT4 L4caIJ2W8+JzO`C5 literal 0 HcmV?d00001 diff --git a/experiments/tuning/results/asci/god_class/.DS_Store b/experiments/tuning/results/asci/god_class/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0)s$#LL@AUp8DoeD@3Rghkrnnc{){y}(SmNEj{|F6_=^ni z-5t?AZtRYpsegYj^ja^c^U^h|Uf?@z8<*!r?F!hY*XO5Ya`tht@9f4^-?Cpl3}PA6 zk{ng|y_HlW{+8ORE$hO$nj?;EM-qxy^;3C!Ke>`rqLyDt?6-`B&oQbf1ImCh@GA_U zX0xP+0d-UclmTU6!vKFDER-=5>;n2v2L|5)07qE%f;smR>|+Hp!7dmWIH1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0vd`$&kD;aXBL+*Jec~c1A{q&6>>jSSA*T KZf58B%MSo8Nen;$ diff --git a/neural_networks/asci/.DS_Store b/neural_networks/asci/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..92544954fceb937c9d01db5039337085374e1042 GIT binary patch literal 6148 zcmeHKJ5Iw;5S)b+k&vR4l2~NasYm&Kr&b&(7WPX9F5tJkSvFSf(Fe>yYt?@ zoo9IpuNQ#r-uo+H3t&xm#D|Ba`MLYT&MIR>I`4SFBYNE68RMe*bi%nCyx|phc$)Eh z-ZkLZA0LMMaU4$5m6ZZgKnh3!DIf)Yset!h+WI0R>OzYldUEci>LGc7Ui%m zQBev=fw=SU`4#o~0nzePE$Cn`z-DR8d9 zb#8aw{~zc-%>U;k?WBMd_*V+p=J0sf^GelQSC{i%+vv}9ulc0AaUB$fXvf58$J}^3 ezKf!)Yrf|5UbrL%o%x^>^)ukQ$fUquD{unV*%gHV literal 0 HcmV?d00001 diff --git a/neural_networks/loss.py b/neural_networks/loss.py deleted file mode 100644 index 14fc51a..0000000 --- a/neural_networks/loss.py +++ /dev/null @@ -1,23 +0,0 @@ -from __future__ import division - -import tensorflow as tf - -def f_measure_approx(logits, labels, gamma): - ''' - This function implements the Differentiable approximation of the f-measure from: - Martin Jansche (2005): - [Maximum Expected F-Measure Training of Logistic Regression Models] - - true_positive: sum(sigmoid(gamma*logits)) for label = +1 - detected: sum(sigmoid(gamma*logits)) - gamma > 0 - ''' - true_positive = tf.reduce_sum(tf.multiply(labels, tf.nn.sigmoid(gamma*logits))) - positive = tf.reduce_sum(labels) - detected = tf.reduce_sum(tf.nn.sigmoid(gamma*logits)) - - return 2*true_positive/(positive+detected) - -# Custom loss function that maximizes f-measure -def compute(logits, labels): - return 1 - f_measure_approx(logits, labels, 4) \ No newline at end of file diff --git a/neural_networks/smad/.DS_Store b/neural_networks/smad/.DS_Store index 24d0c2b3d71d59eae7e05a1784d63468531b8aeb..ff1341055ae20d5e2177e1e43ebad8d7a8ab6dac 100644 GIT binary patch delta 18 ZcmZoMXffDe!pO)tnTJtfb136_F#s@|1l|Au delta 18 ZcmZoMXffDe!pO)lnTJtfb136_F#s@;1l<4t diff --git a/neural_networks/smad/context.py b/neural_networks/smad/context.py index 23bad9c..2c70b53 100644 --- a/neural_networks/smad/context.py +++ b/neural_networks/smad/context.py @@ -4,4 +4,5 @@ ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.insert(0, ROOT_DIR) -import neural_networks.loss as loss \ No newline at end of file +import neural_networks.loss as loss +import utils.nnUtils as nnUtils \ No newline at end of file diff --git a/neural_networks/smad/model.py b/neural_networks/smad/model.py index 8a5bf48..ef73516 100644 --- a/neural_networks/smad/model.py +++ b/neural_networks/smad/model.py @@ -1,4 +1,4 @@ -from context import loss +from __future__ import division import tensorflow as tf @@ -42,9 +42,28 @@ def __init__(self, shape, input_size): # Loss function with tf.name_scope("loss"): - self.loss = loss.compute(self.logits, self.input_y) + self.loss = loss(self.logits, self.input_y) l2_loss = tf.losses.get_regularization_loss() loss_reg = self.loss + l2_loss # Learning mechanism self.learning_step = tf.train.GradientDescentOptimizer(self.learning_rate).minimize(loss_reg) + + +def loss(logits, labels): + ''' + This function implements the Differentiable approximation of the f-measure from: + Martin Jansche (2005): + [Maximum Expected F-Measure Training of Logistic Regression Models] + + true_positive: sum(sigmoid(gamma*logits)) for label = +1 + detected: sum(sigmoid(gamma*logits)) + gamma > 0 + ''' + gamma = 4 + + true_positive = tf.reduce_sum(tf.multiply(labels, tf.nn.sigmoid(gamma*logits))) + positive = tf.reduce_sum(labels) + detected = tf.reduce_sum(tf.nn.sigmoid(gamma*logits)) + + return 1 - 2*true_positive/(positive+detected) diff --git a/neural_networks/smad/predict.py b/neural_networks/smad/predict.py new file mode 100644 index 0000000..0a0c703 --- /dev/null +++ b/neural_networks/smad/predict.py @@ -0,0 +1,34 @@ +from context import ROOT_DIR, nnUtils + +import model as md + +import ast +import csv +import os + +def get_optimal_parameters(antipattern, system): + tuning_file = os.path.join(ROOT_DIR, 'experiments', 'tuning', 'results', 'smad', antipattern, test_system + '.csv') + + with open(tuning_file, 'r') as file: + reader = csv.DictReader(file, delimiter=';') + + for row in reader: + if row['F-measure'] != 'nan': + return {key:ast.literal_eval(row[key]) for key in row} + +def predict(antipattern, system): + params = get_optimal_parameters(antipattern, system) + X = nnUtils.getInstances(antipattern, system) + + # New graph + tf.reset_default_graph() + + # Create model + model = md.SMAD( + shape=params['Dense sizes'], + input_size=X.shape[-1]) + + return nnUtils.ensemble_prediction( + model=model, + save_paths=[nnUtils.get_save_path('smad', antipattern, system, i) for i in range(10)], + input_x=X) \ No newline at end of file diff --git a/neural_networks/smad/trained_models/god_class/.DS_Store b/neural_networks/smad/trained_models/god_class/.DS_Store index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..715af757fcc7fc97a1dc0807efa951ed9fb863c2 100644 GIT binary patch delta 75 zcmZoMXfc?eJ=s8n#h8^Liy@UEg&~unB&9exCn-NahXDkbz$60$BajAS0S1Kp#>A!U MAibNpIezj30BBYa+5i9m delta 51 vcmZoMXfc?e&B4IH0LBvwMFg0D92j6^U=Y|?IE{T`gVbaL5thx|96$L1%DD*$ diff --git a/utils/dataUtils.py b/utils/dataUtils.py index e925869..85637ae 100644 --- a/utils/dataUtils.py +++ b/utils/dataUtils.py @@ -87,7 +87,7 @@ def getMethods(systemName): return methods # Get the hand-validated occurences reported in the considered system for antipattern in [god_class, feature_envy]. -def getAntipatterns(systemName, antipattern): +def getAntipatterns(antipattern, systemName): assert antipattern in ['god_class', 'feature_envy'], antipattern + ' not valid antipattern name. Choose "god_class" or "feature_envy instead"' labelFile = os.path.join(ROOT_DIR, 'data/antipatterns/' + antipattern + '/' + systemName + '.txt') @@ -113,6 +113,14 @@ def getCandidateFeatureEnvy(systemName): if (entityUtils.getEmbeddingClass(entityUtils.normalizeMethodName(row['Method']))!=row['TargetClass']) & (entityUtils.normalizeMethodName(row['Method']) in methods) & (row['TargetClass'] in classes)] +def getEntities(antipattern, systemName): + assert antipattern in ['god_class', 'feature_envy'] + + if antipattern == 'god_class': + return getClasses(systemName) + else: + return getCandidateFeatureEnvy(systemName) + ### METRICS GETTERS FOR GOD CLASS ### def getGCDecorMetrics(systemName): diff --git a/utils/nnUtils.py b/utils/nnUtils.py index 3463009..7bce13f 100644 --- a/utils/nnUtils.py +++ b/utils/nnUtils.py @@ -6,6 +6,7 @@ import matplotlib.pyplot as plt import dataUtils +import os import random import sys @@ -33,24 +34,16 @@ def f_measure(output, labels): ### UTILS ### -def shuffle(X, Y): - assert len(X) == len(Y), 'X and Y must have the same number of elements' - idx = range(len(X)) - random.shuffle(idx) +def build_dataset(antipattern, systems): + input_size = {'god_class':8, 'feature_envy':9} + X = np.empty(shape=[0, input_size[antipattern]]) + Y = np.empty(shape=[0, 1]) + for systemName in systems: + X = np.concatenate((X, getInstances(antipattern, systemName)), axis=0) + Y = np.concatenate((Y, getLabels(antipattern, systemName)), axis=0) - shuffled_X = np.array([X[i] for i in idx]) - shuffled_Y = np.array([Y[i] for i in idx]) - - return shuffled_X, shuffled_Y - -def split(X, Y, nb_split): - assert len(X) == len(Y), 'X and Y must have the same number of elements' - - length = len(X)//nb_split - sections = [(i+1)*length for i in range(nb_split-1)] - - return np.split(X, sections), np.split(Y, sections) + return X, Y # Returns the Bayesian averaging between many network's predictions def ensemble_prediction(model, save_paths, input_x): @@ -64,6 +57,13 @@ def ensemble_prediction(model, save_paths, input_x): return np.mean(np.array(predictions), axis=0) +# Get the path of a trained model for a given approach (smad or asci) +def get_save_path(approach, antipattern, test_system, model_number): + directory = os.path.join(ROOT_DIR, 'neural_networks', approach, 'trained_models', antipattern, test_system) + if not os.path.exists(directory): + os.makedirs(directory) + return os.path.join(directory, 'model_' + str(model_number)) + def plot_learning_curves(losses_train, losses_test): plt.figure() plt.ylim((0.0, 1.0)) @@ -88,21 +88,35 @@ def plot_learning_curves(losses_train, losses_test): plt.legend(loc='best') plt.show() +def shuffle(X, Y): + assert len(X) == len(Y), 'X and Y must have the same number of elements' + + idx = range(len(X)) + random.shuffle(idx) + + shuffled_X = np.array([X[i] for i in idx]) + shuffled_Y = np.array([Y[i] for i in idx]) + + return shuffled_X, shuffled_Y + +def split(X, Y, nb_split): + assert len(X) == len(Y), 'X and Y must have the same number of elements' + + length = len(X)//nb_split + sections = [(i+1)*length for i in range(nb_split-1)] + + return np.split(X, sections), np.split(Y, sections) + ### INSTANCES AND LABELS GETTERS ### # Get labels in vector form for a given system # antipattern in ['god_class', 'feature_envy'] -def getLabels(systemName, antipattern): - assert antipattern in ['god_class', 'feature_envy'] - - if antipattern == 'god_class': - entities = dataUtils.getClasses(systemName) - else: - entities = dataUtils.getCandidateFeatureEnvy(systemName) +def getLabels(antipattern, systemName): + entities = dataUtils.getEntities(antipattern, systemName) + true = dataUtils.getAntipatterns(antipattern, systemName) labels = [] - true = dataUtils.getAntipatterns(systemName, antipattern) for entity in entities: if entity in true: labels.append([1.]) @@ -112,7 +126,7 @@ def getLabels(systemName, antipattern): return np.array(labels) -def getInstances(systemName, antipattern, normalized=True): +def getInstances(antipattern, systemName, normalized=True): assert antipattern in ['god_class', 'feature_envy'] metrics = []