Different variations of minimax risk classifiers(MRC) using different loss functions and uncertainity set of distributions.
The variants available here are -
- MRC with 0-1 loss (MRC.py)
- MRC with log loss (MRC.py)
- MRC with 0-1 loss and fixed instances' marginals (CMRC.py)
- MRC with log loss and fixed instances' marginals (CMRC.py)
We will need have installed the following libraries:
- numpy
- sklearn
- cvxpy
We can install the requirements directly from the file "requirements.txt"
pip install -r requirements.txt
MRC with 0-1 loss
clf = MRC(r=r, loss='0-1').fit(X, Y)
MRC with log loss
clf = MRC(r=r, loss='log').fit(X, Y)
MRC with 0-1 loss and fixed instances' marginals
clf = CMRC(r=r, loss='0-1').fit(X, Y)
MRC with log loss and fixed instances' marginals
clf = CMRC(r=r, loss='log').fit(X, Y)
from MRC import MRC
from datasets import load_mammographic
X, Y = load_mammographic(return_X_y=True)
r = len(np.unique(Y))
clf = MRC(r=r).fit(X, Y)
y_pred = clf.predict(X[:2,:])
clf = MRC(r=r).fit(X, Y)
upper_bound = clf.upper
lower_bound = clf.getLowerBound()
Only available for the MRC class
Using instances X_ and Y_ to calculate tau and lambda
clf = MRC(r=r).fit(X, Y, X_, Y_)
By passing the values for tau and lambda
clf = MRC(r=r).fit(X, Y, _tau=0.5, _lambda=0.1)