Code Monkey home page Code Monkey logo

minimax-risk-classifiers's Introduction

Minimax-Risk-Classifier

Different variations of minimax risk classifiers(MRC) using different loss functions and uncertainity set of distributions.

The variants available here are -

  1. MRC with 0-1 loss (MRC.py)
  2. MRC with log loss (MRC.py)
  3. MRC with 0-1 loss and fixed instances' marginals (CMRC.py)
  4. MRC with log loss and fixed instances' marginals (CMRC.py)

Requirements

Generic badge
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

Usage

Fitting the models

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)

A small training example of MRC

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,:])

Bounds on the error for MRC

clf = MRC(r=r).fit(X, Y)
upper_bound = clf.upper
lower_bound = clf.getLowerBound()

Only available for the MRC class

Setting the interval estimates while fitting

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)

minimax-risk-classifiers's People

Contributors

kartheekcic avatar

Watchers

 avatar  avatar

Forkers

aperez-bcam

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.