mlconcepts
This library is a wrapper around libmlconcepts, namely
a c++
library which implements a series of (interpretable) machine learning algorithms
based on FCA, e.g. [3].
Installing mlconcepts
from a source distribution only requires a c++23
compiler, all the
other dependencies are automatically fetched. If cmake
is not able to find the compiler
during the installation process, please set the environment variable CXX
as follows
CXX = /path/to/c++/compiler
Basic example
Assuming that a dataset containing a column outlier
is stored in the file
dataset.csv
, a basic model could be trained as follows.
import mlconcepts
model = mlconcepts.SODModel()
model.fit("dataset.csv", labels = "outlier")
model.save("model.bin")
A slightly more involved example
import mlconcepts
import mlconcepts.data
import sklearn.metrics
import sklearn.model_selection
data = mlconcepts.data.load("dataset.csv", labels = "outlier")
skf = sklearn.model_selection.StratifiedKFold(n_splits = 4, shuffle = True)
for train, test in data.split(skf):
model = mlconcepts.SODModel(
n = 32,
epochs = 1000,
show_training = False
)
model.fit(train)
predictions = model.predict(test)
print("AUC: ", sklearn.metrics.roc_auc_score(test.y, predictions))
References
[1] Flexible categorization for auditing using formal concept analysis and
Dempster-Shafer theory
[2] A Meta-Learning Algorithm for Interrogative Agendas
[3] Outlier detection using flexible categorisation and interrogative agendas