-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (45 loc) · 2.34 KB
/
main.py
File metadata and controls
66 lines (45 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# script to execute notebooks using the Python API interface
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from nbconvert.preprocessors import CellExecutionError
# Path of notebooks
classification_directory = "classification-models/"
regression_directory = "regression-models/"
classifierInter_directory = "Classifier interpretability/"
Cfile_paths = ["Adult/", "Breast Cancer Wisconsin/", "Default of credit card clients/", "Diabetic Retinopathy/", "Seismic-Bumps/", "Statlog-Australian credit approval/",
"Statlog-German credit data/", "Steel Plates Faults/", "Thoracic Surgery Data/", "Yeast/"]
Rfile_paths = ["Bike Sharing/", "Communities and Crime/", "Concrete Compressive Strength/", "Facebook metrics/", "Merck Molecular Activity Challenge/",
"Parkinson Speech/", "QSAR aquatic toxicity/", "SGEMM GPU kernel performance/", "Student Performance/", "Wine Quality/"]
file_name = "model.ipynb"
def execute_notebook(datasetName):
print("\nexecuting..."+str(datasetName))
with open(datasetName+file_name) as f:
nb = nbformat.read(f, as_version=4)
ep = ExecutePreprocessor(timeout=36000, kernel_name='python3')
try:
out = ep.preprocess(nb, {'metadata': {'path': datasetName}})
except CellExecutionError:
out = None
msg = 'Error executing the notebook "%s".\n\n' % datasetName+file_name
msg += 'See notebook "%s" for the traceback.' % datasetName+file_name
print(msg)
raise
finally:
with open(datasetName+file_name, mode='w', encoding='utf-8') as f:
nbformat.write(nb, f)
def start_classification():
for i, file_path in enumerate(Cfile_paths):
datasetname = classification_directory + file_path
execute_notebook(datasetname)
print("complete the execution of..."+str(datasetname))
def start_regression():
for i, file_path in enumerate(Rfile_paths):
datasetname = regression_directory + file_path
execute_notebook(datasetname)
print("complete the execution of..."+str(datasetname))
def start_classifierInterpretability():
execute_notebook(classifierInter_directory)
print("complete the execution of..."+str(classifierInter_directory))
start_classification()
start_regression()
start_classifierInterpretability()