john-tornblom / VoTE

Verifier of Tree Ensembles
GNU Lesser General Public License v3.0
6 stars 1 forks source link

Yes, ranges can be reported too. If you like to continue analyzing the remaining input space despite finding a violation, you can return vote.PASS instead of vote.FAIL, see example below. #3

Open XAI360 opened 1 year ago

XAI360 commented 1 year ago
    Yes, ranges can be reported too. If you like to continue analyzing the remaining input space despite finding a violation, you can return vote.PASS instead of vote.FAIL, see example below.
import vote

from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_digits

digits = load_digits()
rf = RandomForestClassifier(n_estimators=10)
rf.fit(digits.data, digits.target)

e = vote.Ensemble.from_sklearn(rf)
error_margin = 1

for xvec, label in zip(digits.data, digits.target):

    def check_robustness(m):
        o = vote.mapping_check_argmax(m, label)

        if o == vote.FAIL:
            conds = ['x%d ∈ %s' % (dim, [m.inputs[dim].lower, m.inputs[dim].upper])
                                   for dim in range(m.nb_inputs)]
            print(', '.join(conds))
            print('-' * 80)
            return vote.PASS

        return o

    input_region = [(max(x - error_margin, 0), min(255, x + error_margin))
                    for x in xvec]
    e.absref(check_robustness, input_region)

Originally posted by @john-tornblom in https://github.com/john-tornblom/VoTE/issues/2#issuecomment-1336449050

XAI360 commented 1 year ago

In this example, where VoTE exhaustively searches for all counterexample regions, are those open or closed intervals?

Also, it's not normal for the original test sample that was correctly identified (but not robust) to lie in the counterexample region, right? For example, if x = (0, 0, 0, 0) and my counterexample region, cr = (x0 ∈ [0,1], x1 ∈ [0,1], x2 ∈ [0, 1], x3 ∈ [0,1]), VoTE reports that the test sample x lies in the counterexample region cr, which should't be the case.

Am I missing something here? TIA