Skip to content

Commit efd9339

Browse files
Merge branch 'main' of github.com:SDM-TIB/InterpretME into main
2 parents 3d92d69 + beaf03c commit efd9339

File tree

6 files changed

+46
-68
lines changed

6 files changed

+46
-68
lines changed

InterpretME/classification.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def binary_classification(sampled_data, sampled_target, imp_features, cross_vali
260260
for f in range(important_features_size):
261261
important_features.add(X.columns.values[indices[f]])
262262

263-
data = plot_feature_importance(estimator.feature_importances_, X.columns, model, st)
263+
data = plot_feature_importance(estimator.feature_importances_, X.columns)
264264
results['feature_importance'] = data
265265

266266
# Taking important features
@@ -401,7 +401,7 @@ def multiclass(sampled_data, sampled_target, imp_features, cv, classes, st, lime
401401
for f in range(important_features_size):
402402
important_features.add(X.columns.values[indices[f]])
403403

404-
data = plot_feature_importance(estimator.feature_importances_, X.columns, model, st)
404+
data = plot_feature_importance(estimator.feature_importances_, X.columns)
405405
results['feature_importance'] = data
406406

407407
# Taking important features

InterpretME/plots.py

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from validating_models.visualizations.classification import confusion_matrix_decomposition
55

66

7-
def sampling(results,path):
7+
def sampling(results, path):
88
"""Sampling strategy plots.
99
1010
Parameters
@@ -14,23 +14,17 @@ def sampling(results,path):
1414
path : str
1515
Path to save plot results.
1616
17-
Returns
18-
-------
19-
2017
"""
21-
22-
print("########################################################################")
23-
print("************************* Sampling strategy ****************************")
24-
print("########################################################################")
2518
autopct = "%.2f"
2619
val = results['sampling']
27-
run = results['run_id']
20+
file = path + f"/sampling_{results['run_id']}.png"
21+
print("Saving sampling strategy plot to", file)
2822
val.plot.pie(autopct=autopct)
2923
plt.title("Sampling Strategy")
30-
plt.savefig(path+f'/sampling_{run}.png')
24+
plt.savefig(file)
3125

3226

33-
def feature_importance(results,path):
27+
def feature_importance(results, path):
3428
"""
3529
3630
Parameters
@@ -40,15 +34,10 @@ def feature_importance(results,path):
4034
path : str
4135
Path to save plot results.
4236
43-
Returns
44-
-------
45-
4637
"""
47-
print("#####################################################################")
48-
print("******************* Feature Importance plot *************************")
49-
print("#####################################################################")
5038
fi_df = results['feature_importance']
51-
run = results['run_id']
39+
file = path + f"/Feature Importance_{results['run_id']}.png"
40+
print("Saving feature importance plot to", file)
5241
# Define size of bar plot
5342
plt.figure(figsize=(20, 15))
5443
# Plot Searborn bar chart
@@ -57,7 +46,7 @@ def feature_importance(results,path):
5746
plt.title('FEATURE IMPORTANCE')
5847
plt.xlabel('FEATURE IMPORTANCE')
5948
plt.ylabel('FEATURE NAMES')
60-
plt.savefig(path +f'/Feature Importance_{run}.png')
49+
plt.savefig(file)
6150

6251

6352
def decision_trees(results, path):
@@ -70,16 +59,12 @@ def decision_trees(results, path):
7059
path : str
7160
Path to save plot results.
7261
73-
Returns
74-
-------
75-
7662
"""
77-
print("#####################################################################")
78-
print("*********************** Decision Trees ******************************")
79-
print("#####################################################################")
63+
file = path + f"/Decision_trees_{results['run_id']}.svg"
64+
print("Saving decision trees to", file)
8065
vis = results['dtree']
81-
run = results['run_id']
82-
vis.save(path+f'/Decision_tree_{run}.svg')
66+
vis.save(file)
67+
8368

8469
def constraints_decision_trees(results, path, constraint_num):
8570
"""
@@ -93,13 +78,8 @@ def constraints_decision_trees(results, path, constraint_num):
9378
constraint_num : list
9479
Number of constraints for saving plots.
9580
96-
Returns
97-
-------
98-
9981
"""
100-
print("#########################################################################")
101-
print("*************************** Constraints Decision Trees ******************")
102-
print("##########################################################################")
82+
print("Saving constraints decision trees to", path)
10383
run = results['run_id']
10484
checker = results['checker']
10585
shadow_tree = results['shadow_tree']
@@ -121,11 +101,3 @@ def constraints_decision_trees(results, path, constraint_num):
121101
plot = constraint_viz.dtreeviz(shadow_tree, checker, constraints, coverage=True,
122102
non_applicable_counts=non_applicable_counts)
123103
plot.save(path + f'/constraints_validation_dtree_{run}.svg')
124-
125-
126-
127-
128-
129-
130-
131-

LIBRARY.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ pipeline(path_config, sampling, cv, imp_features, test_split, model, lime_result
2424

2525
`pipeline()` executes the whole pipeline; including extracting data and metadata from the input KGs, validating SHACL constraints, preprocessing the data and running predictive models.
2626
InterpretME aims at collecting metadata at each step of pipeline.
27-
The current version of InterpretME resorts to interpretable surrogate tools like `LIME` [1].
27+
The current version of InterpretME resorts to interpretable surrogate tools like LIME [1].
2828
The user can provide a path to store the LIME results.
2929
Even model performance metrics like accuracy, precision etc. are recorded as metadata.
30-
The RDF mapping language (`RML`) is used to define mappings for the metadata collected from the predictive pipeline in order to integrate them into the **InterpretME KG**.
30+
The RDF mapping language (RML) is used to define mappings for the metadata collected from the predictive pipeline in order to integrate them into the **InterpretME KG**.
3131
The RML mappings are used by the SDM-RDFizer [2], an efficient RML engine for creating knowledge graphs, to semantify the metadata.
3232
The function `pipeline()` returns results from the pipeline which are used later in traceability of a target entity.
3333

@@ -131,4 +131,4 @@ A Python dictionary following the SPARQL protocol with the query result.
131131

132132
[2] E. Iglesias, S. Jozashoori, D. Chaves-Fraga, D. Collarana and M.-E. Vidal. SDM-RDFizer: An RML Interpreter for the Efficient Creation of RDF Knowledge Graphs. In: CIKM ’20:Proceedings of the 29th ACM International Conference on Information & Knowledge Management, ACM, New York, NY,USA, 2020. DOI: [10.1145/3340531.3412881](https://dl.acm.org/doi/pdf/10.1145/3340531.3412881).
133133

134-
[3] P.D. Rohde. DeTrusty v0.6.1, August 2022. DOI: [10.5281/zenodo.6998001](https://doi.org/10.5281/zenodo.6998001).
134+
[3] P.D. Rohde. DeTrusty v0.6.1, August 2022. DOI: [10.5281/zenodo.6998001](https://doi.org/10.5281/zenodo.6998001).

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
include README.md
2-
include InterpretME/mappings/*.ttl
1+
include LIBRARY.md
2+
include InterpretME/mappings/*.ttl

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
[![Latest Release](http://img.shields.io/github/release/SDM-TIB/InterpretME.svg?logo=github)](https://github.com/SDM-TIB/InterpretME/releases)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
55

6+
[![Python Versions](https://img.shields.io/pypi/pyversions/InterpretME)](https://pypi.org/project/InterpretME)
7+
[![Package Format](https://img.shields.io/pypi/format/InterpretME)](https://pypi.org/project/InterpretME)
8+
[![Package Status](https://img.shields.io/pypi/status/InterpretME)](https://pypi.org/project/InterpretME)
9+
[![Package Version](https://img.shields.io/pypi/v/InterpretME)](https://pypi.org/project/InterpretME)
10+
611
# InterpretME
712

813
![InterpretME Architecture](https://raw.githubusercontent.com/SDM-TIB/InterpretME/main/images/architecture.png "InterpretME Architecture")

setup.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from setuptools import find_packages, setup
1+
from setuptools import setup
22

3-
with open("README.md", "r", encoding="utf8") as fh:
3+
with open("LIBRARY.md", "r", encoding="utf8") as fh:
44
long_description = fh.read()
55

66
setup(
77
name='InterpretME',
88
packages=['InterpretME'],
9-
version='1.0.0',
9+
version='1.1.0',
1010
description='An interpretable machine learning pipeline over knowledge graphs',
1111
long_description=long_description,
1212
long_description_content_type="text/markdown",
@@ -26,21 +26,22 @@
2626
'Operating System :: OS Independent'
2727
],
2828
python_requires='>=3.8, <3.10',
29-
install_requires=['pandas>=1.4.1',
30-
'imbalanced-learn>=0.9.0',
31-
'lime>=0.2.0',
32-
'pydotplus>=2.0.2',
33-
'svglib>=1.2.1',
34-
'colour>=0.1.5',
35-
'matplotlib<=3.3.4',
36-
'rdflib<=6.1.1',
37-
'seaborn>=0.11.2',
38-
'numpy>=1.21.6',
39-
'dtreeviz>=1.3.0',
40-
'python-slugify>=6.0.0',
41-
'requests>=2.27.0',
42-
'rdfizer>=4.5.4',
43-
'Detrusty>=0.6.1',
44-
'validating-models>=0.9.0'
45-
]
29+
install_requires=[
30+
'pandas>=1.4.1',
31+
'imbalanced-learn>=0.9.0',
32+
'lime>=0.2.0',
33+
'pydotplus>=2.0.2',
34+
'svglib>=1.2.1',
35+
'colour>=0.1.5',
36+
'matplotlib<=3.3.4',
37+
'rdflib<=6.1.1',
38+
'seaborn>=0.11.2',
39+
'numpy>=1.21.6',
40+
'dtreeviz>=1.3.0',
41+
'python-slugify>=6.0.0',
42+
'requests>=2.27.0',
43+
'rdfizer>=4.5.4',
44+
'Detrusty>=0.6.1',
45+
'validating-models>=0.9.0'
46+
]
4647
)

0 commit comments

Comments
 (0)