IP Library › Granted Patent US 12,596,941
Granted Patent B2
US 12,596,941 · App. 17/378,794 · Granted Apr 7, 2026

Realistic counterfactual explanation of machine learning predictions

Inventors: Michael Vinov (Haifa, IL); Oleg Blinder (Haifa, IL); Diptikalyan Saha (Bangalore, IN); Sandeep Hans (New Delhi, IN); Aniya Aggarwal (New Delhi, IL); Omer Yehuda Boehm (Haifa, IL); Eyal Bin (Haifa, IL)
Assignee: INTERNATIONAL BUSINESS MACHINES CORPORATION
G06N5/045G06N20/00
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,596,941
App. No.
17/378,794
Granted
Apr 7, 2026
Kind
B2
Abstract

A computer-implemented method comprising, automatically: analyzing a machine learning dataset which comprises multiple datapoints, to deduce constraints on features of the datapoints; generating a first set of CSP (Constraint Satisfaction Problem) rules expressing the constraints; based on a machine learning model which was trained on the dataset, generating a second set of CSP rules that define one or more perturbation candidates among the features of one of the datapoints; formulating a CSP based on the first and second sets of CSP rules; solving the formulated CSP using a solver; and using the solution of the CSP as a counterfactual explanation of a prediction made by the machine learning model with respect to the one datapoint.

Claims (65)

1 . A computer-implemented method comprising:

automatically analyzing a machine learning dataset comprising at least one datapoint to deduce constraints on features of the at least one datapoint;

generating a first set of CSP (Constraint Satisfaction Problem) rules expressing the constraints;

based on a machine learning model trained on the machine learning dataset, generating a second set of CSP rules that define one or more perturbation candidates among the features of the at least one datapoint, wherein the perturbation candidates are one or more changes to features associated with the at least one datapoint, comprising:

generating a modified datapoint based on changed feature values associated with the perturbation candidates and the at least one datapoint;

formulating a CSP based on the first and second sets of CSP rules;

solving the formulated CSP using a solver;

using the solution of the CSP as a counterfactual explanation of a prediction made by the machine learning model with respect to the at least one datapoint, wherein the counterfactual explanation is a natural language representation of the solution of the CSP; and

responsive to an accessible loss function of the machine learning model, iterating until an opposite classification is achieved, and subsequently using a set of constraints as the second set of CSP rules, wherein, in each iteration, the modified datapoint of a previous iteration serves as the at least one datapoint of a current iteration.

2 . The computer-implemented method of claim 1 , wherein the analyzing of the machine learning dataset comprises analyzing values of the features of the at least one datapoint.

3 . The computer-implemented method of claim 2 , wherein the analyzing of the values of the features is to discover descriptive statistics of the values across the machine learning dataset.

4 . The computer-implemented method of claim 1 , wherein the current iteration comprises:

modifying the loss function of the machine learning model to use a flipped class label;

calculating gradients of the modified loss function with respect to the at least one datapoint;

translating the calculated gradients into the set of constraints, and formulating another CSP based on the set of constraints and on the first set of CSP rules;

solving the other CSP using the solver, to identify the one or more perturbation candidates among the features of the at least one datapoint;

using the machine learning model to predict a class for the modified datapoint.

5 . The computer-implemented method of claim 1 , wherein the generating of the second set of CSP comprises, when a loss function of the machine learning model is inaccessible:

calculating an anchor for the at least one datapoint using the machine learning model, wherein the anchor is a definition of conditions that are a likely cause of a certain classification by the machine learning model; and

translating the conditions in the second set of CSP rules.

6 . The computer-implemented method of claim 1 , wherein the at least one datapoint is randomly selected among all datapoints in the machine learning dataset.

7 . The computer-implemented method of claim 1 , executed by at least one hardware processor.

8 . A system comprising:

(i) at least one hardware processor; and

(ii) a non-transitory computer-readable storage medium having program code embodied therewith, the program code executable by said at least one hardware processor to:

automatically analyze a machine learning dataset comprising at least one datapoint to deduce constraints on features of the at least one datapoint;

generate a first set of CSP (Constraint Satisfaction Problem) rules expressing the constraints;

based on a machine learning model trained on the machine learning dataset, generate a second set of CSP rules that define one or more perturbation candidates among the features at least one datapoint in the one or more datapoints, wherein the perturbation candidates are one or more changes to features associated with the at least one datapoint, comprising:

generating a modified datapoint based on changed feature values associated with the perturbation candidates and the at least one datapoint;

formulate a CSP based on the first and second sets of CSP rules;

solve the formulated CSP using a solver;

use the solution of the CSP as a counterfactual explanation of a prediction made by the machine learning model with respect to the at least one datapoint, wherein the counterfactual explanation is a natural language representation of the solution of the CSP; and

responsive to an accessible loss function of the machine learning model, iterate until an opposite classification is achieved, and subsequently using a set of constraints as the second set of CSP rules, wherein, in each iteration, the modified datapoint of a previous iteration serves as the at least one datapoint of a current iteration.

9 . The system of claim 8 , wherein the analyzing of the machine learning dataset comprises analyzing values of the features of the at least one datapoint.

10 . The system of claim 9 , wherein the analyzing of the values of the features is to discover descriptive statistics of the values across the machine learning dataset.

11 . The system of claim 8 , wherein the current iteration comprises:

modifying the loss function of the machine learning model to use a flipped class label;

calculating gradients of the modified loss function with respect to the at least one datapoint;

translating the calculated gradients into the set of constraints, and formulating another CSP based on the set of constraints and on the first set of CSP rules;

solving the other CSP using the solver, to identify the one or more perturbation candidates among the features of the at least one datapoint;

using the machine learning model to predict a class for the modified datapoint.

12 . The system of claim 8 , wherein the generating of the second set of CSP comprises, when a loss function of the machine learning model is inaccessible:

calculating an anchor for the at least one datapoint using the machine learning model, wherein the anchor is a definition of conditions that are a likely cause of a certain classification by the machine learning model; and

translating the conditions in the second set of CSP rules.

13 . The system of claim 8 , wherein the at least one datapoint is randomly selected among all datapoints in the dataset.

14 . A computer program product comprising a non-transitory computer-readable storage medium having program code embodied therewith, the program code executable by at least one hardware processor to:

automatically analyze a machine learning dataset comprising at least one datapoints to deduce constraints on features of the at least one datapoint;

generate a first set of CSP (Constraint Satisfaction Problem) rules expressing the constraints;

based on a machine learning model trained on the machine learning dataset, generate a second set of CSP rules that define one or more perturbation candidates among the features at least one datapoint, wherein the perturbation candidates are one or more changes to features associated with the at least one datapoint, comprising:

generating a modified datapoint based on changed feature values associated with the perturbation candidates and the at least one datapoint;

formulate a CSP based on the first and second sets of CSP rules; solve the formulated CSP using a solver;

use the solution of the CSP as a counterfactual explanation of a prediction made by the machine learning model with respect to the at least one datapoint, wherein the counterfactual explanation is a natural language representation of the solution of the CSP; and

responsive to an accessible loss function of the machine learning model, iterate until an opposite classification is achieved, and subsequently using a set of constraints as the second set of CSP rules, wherein, in each iteration, the modified datapoint of a previous iteration serves as the at least one datapoint of a current iteration.

15 . The computer program product of claim 14 , wherein the analyzing of the machine learning dataset comprises analyzing values of the features of the at least one datapoint.

16 . The computer program product of claim 15 , wherein the analyzing of the values of the features is to discover descriptive statistics of the values across the machine learning dataset.

17 . The computer program product of claim 14 , wherein current iteration comprises:

modifying the loss function of the machine learning model to use a flipped class label;

calculating gradients of the modified loss function with respect to the at least one datapoint;

translating the calculated gradients into the set of constraints, and formulating another CSP based on the set of constraints and on the first set of CSP rules;

solving the other CSP using the solver, to identify the one or more perturbation candidates among the features of the at least one datapoint;

using the machine learning model to predict a class for the modified datapoint.

18 . The computer program product of claim 14 , wherein the generating of the second set of CSP comprises, when a loss function of the machine learning model is inaccessible:

calculating an anchor for the at least one datapoint using the machine learning model, wherein the anchor is a definition of conditions that are a likely cause of a certain classification by the machine learning model; and

translating the conditions in the second set of CSP rules.

19 . The computer program product of claim 14 , wherein the one datapoint is randomly selected among all datapoints in the machine learning dataset.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 19, 2021
From: VINOV, MICHAEL; BLINDER, OLEG; SAHA, DIPTIKALYAN; HANS, SANDEEP; AGGARWAL, ANIYA; BOEHM, OMER YEHUDA; BIN, EYAL
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 056893/0143 →
Continuity (1)
Related Publication 20230025731A1 · Jan 26, 2023
References Cited (12)
US 7171393B2 · Naveh · 2007 [cited by examiner]
US 10783401B1 · Jiang · 2020 [cited by examiner]
US 20050278702A1 · Koyfman · 2005 [cited by applicant]
US 20060184468A1 · Adir · 2006 [cited by applicant]
US 20160350155A1 · Brutschy · 2016 [cited by examiner]
US 20170255872A1 · Hamze · 2017 [cited by applicant]
US 20210133630A1 · Dalli · 2021 [cited by examiner]
TrustyAI Explainability Toolkit Rob Geada, Tommaso Teofili, Rui Vieira, Rebecca Whitworth, Daniele Zonca Publisher :arXiv Cornell University (Year: 2021). [cited by examiner]
Alejandro Barredo-Arrieta et al, “Plausible Counterfactuals: Auditing Deep Learning Classifiers with Realistic Adversarial Examples”; Presentation at WCCI 2020; arXiv:2003.11323; Mar. 25, 2020. [cited by applicant]
Marco Tulio Ribeiro et al, “Anchors: High-Precision Model-Agnostic Explanations”; The Thirty-Second AAAI Conference on Artificial Intelligence (AAAI-18); pp. 1527-1535, Apr. 2018. [cited by applicant]
P. J. Hawkins et al, “Solving Set Constraint Satisfaction Problems using ROBDDs”; Journal of Artificial Intelligence Research, vol. 24, pp. 109-156; Sep. 2005. [cited by applicant]
Ramaravind Kommiya Mothilal et al., “Explaining Machine Learning Classifiers through Diverse Counterfactual Explanations”; Conference on Fairness, Accountability, and Transparency; arXiv:1905.07697; May 19, 2019. [cited by applicant]