Skip to content

Commit 33ad720

Browse files
committed
change method name by adding prefix 'MIT', 'SAT', 'NLP'
1 parent 92e71e8 commit 33ad720

13 files changed

+41
-24
lines changed

main.py

+26-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding:utf-8 -*-
22
import warnings
33
import sys
4+
import time
45
from src.models.tools import *
56
from src.models.explain import *
67
from src.models.glance import *
@@ -11,27 +12,41 @@
1112
simplefilter(action='ignore', category=FutureWarning)
1213

1314
# The model name and its corresponding python class implementation
14-
MODEL_DICT = {'TMI-LR': TMI_LR, 'TMI-SVM': TMI_SVM, 'TMI-MNB': TMI_MNB, 'TMI-DT': TMI_DT, 'TMI-RF': TMI_RF,
15-
'LineDP': LineDP,
16-
'PMD': PMD, 'CheckStyle': CheckStyle,
17-
'NGram': NGram, 'NGram-C': NGram_C,
18-
'Glance-EA': Glance_EA, 'Glance-MD': Glance_MD, 'Glance-LR': Glance_LR, 'Glance-EA-SATD': Glance_EA_SATD,
15+
MODEL_DICT = {'MIT-TMI-LR': TMI_LR, 'MIT-TMI-SVM': TMI_SVM, 'MIT-TMI-MNB': TMI_MNB, 'MIT-TMI-DT': TMI_DT,
16+
'MIT-TMI-RF': TMI_RF, 'MIT-LineDP': LineDP,
17+
'SAT-PMD': PMD, 'SAT-CheckStyle': CheckStyle,
18+
'NLP-NGram': NGram, 'NLP-NGram-C': NGram_C,
19+
'Glance-EA': Glance_EA, 'Glance-MD': Glance_MD, 'Glance-LR': Glance_LR,
1920
}
2021

2122

2223
# ========================= Run RQ1 experiments =================================
2324
def run_cross_release_predict(prediction_model):
25+
# time
26+
release_name, build_time_list, pred_time_list = [], [], []
2427
for project, releases in get_project_releases_dict().items():
2528
for i in range(len(releases) - 1):
2629
# 1. Loading data. train data index = i, test data index = i + 1
2730
print(f'========== {prediction_model.model_name} CR PREDICTION for {releases[i + 1]} ================'[:60])
31+
# ####### Build time #######
32+
t_start = time.time()
2833
model = prediction_model(releases[i], releases[i + 1])
34+
t_end = time.time()
35+
build_time_list.append(t_end - t_start)
2936

37+
# ####### Pred time #######
38+
t_start = time.time()
3039
model.file_level_prediction()
31-
model.analyze_file_level_result()
32-
40+
# model.analyze_file_level_result()
3341
model.line_level_prediction()
34-
model.analyze_line_level_result()
42+
# model.analyze_line_level_result()
43+
t_end = time.time()
44+
pred_time_list.append(t_end - t_start)
45+
release_name.append(releases[i + 1])
46+
47+
data = {'release_name': release_name, 'build_time': build_time_list, 'pred_time': pred_time_list}
48+
data = pd.DataFrame(data, columns=['release_name', 'build_time', 'pred_time'])
49+
data.to_csv(model.time_file, index=False)
3550

3651

3752
def run_default():
@@ -41,10 +56,11 @@ def run_default():
4156
# ======= NLP-based approaches ======= NGram, NGram_C
4257
# ======= Glance-XX approaches ======= Glance_MD, Glance_EA, Glance_LR
4358

44-
# run_cross_release_predict(Glance_LR)
59+
run_cross_release_predict(Glance_LR)
4560
# run_cross_release_predict(Glance_EA)
4661
# run_cross_release_predict(Glance_MD)
47-
run_cross_release_predict(LineDP)
62+
# run_cross_release_predict(LineDP)
63+
pass
4864

4965
def parse_args():
5066
# If there is no additional parameters in the command line, run the default models.
37 Bytes
Binary file not shown.
53 Bytes
Binary file not shown.
15 Bytes
Binary file not shown.
15 Bytes
Binary file not shown.
25 Bytes
Binary file not shown.

src/models/base_model.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, train_release: str = '', test_release: str = '', test_result_
2727
# evaluation path
2828
self.file_level_evaluation_file = f'{self.file_level_result_path}evaluation.csv'
2929
self.line_level_evaluation_file = f'{self.line_level_result_path}evaluation.csv'
30+
self.time_file = f'{self.result_path}time.csv'
3031

3132
# Model configuration info
3233
self.project_name = train_release.split('-')[0]

src/models/explain.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
class LineDP(BaseModel):
22-
model_name = 'LineDP'
22+
model_name = 'MIT-LineDP'
2323

2424
def __init__(self, train_release: str = '', test_release: str = ''):
2525
super().__init__(train_release, test_release)
@@ -110,7 +110,7 @@ def line_level_prediction(self):
110110

111111
#################################### Traditional model interpretation approaches #######################################
112112
class TMI_Model(BaseModel):
113-
model_name = 'TMI-Model'
113+
model_name = 'MIT-TMI-Model'
114114

115115
def __init__(self, train_release: str = '', test_release: str = ''):
116116
super().__init__(train_release, test_release)
@@ -208,7 +208,7 @@ def line_level_prediction(self):
208208

209209

210210
class TMI_LR(TMI_Model):
211-
model_name = 'TMI-LR'
211+
model_name = 'MIT-TMI-LR'
212212

213213
def __init__(self, train_release: str = '', test_release: str = ''):
214214
super().__init__(train_release, test_release)
@@ -218,7 +218,7 @@ def __init__(self, train_release: str = '', test_release: str = ''):
218218

219219

220220
class TMI_SVM(TMI_Model):
221-
model_name = 'TMI-SVM'
221+
model_name = 'MIT-TMI-SVM'
222222

223223
def __init__(self, train_release: str = '', test_release: str = ''):
224224
super().__init__(train_release, test_release)
@@ -228,7 +228,7 @@ def __init__(self, train_release: str = '', test_release: str = ''):
228228

229229

230230
class TMI_MNB(TMI_Model):
231-
model_name = 'TMI-MNB'
231+
model_name = 'MIT-TMI-MNB'
232232

233233
def __init__(self, train_release: str = '', test_release: str = ''):
234234
super().__init__(train_release, test_release)
@@ -238,7 +238,7 @@ def __init__(self, train_release: str = '', test_release: str = ''):
238238

239239

240240
class TMI_DT(TMI_Model):
241-
model_name = 'TMI-DT'
241+
model_name = 'MIT-TMI-DT'
242242

243243
def __init__(self, train_release: str = '', test_release: str = ''):
244244
super().__init__(train_release, test_release)
@@ -248,7 +248,7 @@ def __init__(self, train_release: str = '', test_release: str = ''):
248248

249249

250250
class TMI_RF(TMI_Model):
251-
model_name = 'TMI-RF'
251+
model_name = 'MIT-TMI-RF'
252252

253253
def __init__(self, train_release: str = '', test_release: str = ''):
254254
super().__init__(train_release, test_release)

src/models/glance.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class Glance_MD(Glance):
115115
"""
116116
File level classifier: ManualDown
117117
"""
118-
model_name = 'Glance-MD'
118+
model_name = 'BASE-Glance-MD'
119119

120120
def __init__(self, train_release='', test_release='', line_threshold=0.5, file_threshold=0.5, test=False):
121121
test_result_path = ''
@@ -166,7 +166,7 @@ class Glance_EA(Glance):
166166
"""
167167
File level classifier: Effort-Aware ManualDown
168168
"""
169-
model_name = 'Glance-EA'
169+
model_name = 'BASE-Glance-EA'
170170

171171
def __init__(self, train_release='', test_release='', line_threshold=0.5, file_threshold=0.5, test=False):
172172
test_result_path = ''
@@ -279,7 +279,7 @@ class Glance_LR(Glance):
279279
"""
280280
File level classifier: Logistic Regression
281281
"""
282-
model_name = 'Glance-LR'
282+
model_name = 'BASE-Glance-LR'
283283

284284
def __init__(self, train_release='', test_release='', line_threshold=0.5, test=False):
285285
test_result_path = ''

src/models/natural.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class NGram(BaseModel):
8-
model_name = 'NGram'
8+
model_name = 'NLP-NGram'
99

1010
def __init__(self,train_release: str = '', test_release: str = ''):
1111
super().__init__(train_release, test_release)
@@ -58,7 +58,7 @@ def line_level_prediction(self):
5858

5959

6060
class NGram_C(NGram):
61-
model_name = 'NGram-C'
61+
model_name = 'NLP-NGram-C'
6262

6363
def __init__(self, train_release: str = '', test_release: str = ''):
6464
super().__init__(train_release, test_release)

src/models/tools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def line_level_prediction(self):
119119
# ################################################ PMD ##########################################################
120120

121121
class PMD(StaticAnalysisTool):
122-
model_name = 'PMD'
122+
model_name = 'SAT-PMD'
123123

124124
def __init__(self, train_release: str = '', test_release: str = ''):
125125
super().__init__(train_release, test_release)
@@ -162,7 +162,7 @@ def detect_detailed_result_of_bugs(self):
162162

163163
# ################################################ CheckStyle ##########################################################
164164
class CheckStyle(StaticAnalysisTool):
165-
model_name = 'CheckStyle'
165+
model_name = 'SAT-CheckStyle'
166166

167167
def __init__(self, train_release: str = '', test_release: str = ''):
168168
super().__init__(train_release, test_release)
-671 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)