-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp.py
More file actions
33 lines (27 loc) · 749 Bytes
/
tmp.py
File metadata and controls
33 lines (27 loc) · 749 Bytes
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
from z3 import *
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import LinearSVC
import mldiff.dt2smt as dt2smt
import mldiff.svm2smt as svm2smt
from mldiff.diff_matrix import evaluateDiffMatrix
# Load data and train classifiers
iris = load_iris()
X, y = iris.data, iris.target
dt = DecisionTreeClassifier(max_depth=3)
dt.fit(X, y)
svm = LinearSVC()
svm.fit(X, y)
# Convert to SMT formulas
clDt = Int("classDT")
s = dt2smt.toSMT(dt, str(clDt))
clSvm = Int("classSVM")
svm2smt.toSMT(svm, str(clSvm), s)
# Check for disagreements
s.push()
s.add(clDt != clSvm)
if s.check() == sat:
print("Classifiers disagree on:", s.model())
else:
print("Classifiers agree on all inputs")
s.pop()