Giter Site home page Giter Site logo

minerrorrateclassifier's Introduction

Bayesian Minimum Error Rate Classifier

Running the model

Create a new directory Data and place the csv files containing the data of the two classes (separately) in it.

Add the relevant column names to the list features in the binClassifier.py. Assign the split values to split1 and split2 in binClassifier.py.

On running binClassifier.py, the dataset is shuffled and sampled 100 times. The mean, minimum and maximum accuracies are printed(classwise and overall).

Mathematical Background

Likelihood

The probability density function used is the multivariate normal distribution. the likelihood p(x|wi) is given by

x is the d-dimensional feature vector, μ is the mean vector, Σ is the covariance matrix,|Σ| is the determinant of the covariance matrix, Σ−1 is the inverse of the covariance matrix and (x − μ)t is the transpose of the (x - μ) vector. p(x) is calculated using the covariance matrix of the data of a class wi.

p(x) for each of the classes is computed given the equation for multivariate normal distribution. This would be p(x|wi ) for i = 1, 2 (being a binary classifier).

Apriori Probabilities

the apriori probabilities P(w1) and P(w2) are calculated using

P(wi) = (numberof data points in wi) / (total number of datapoints)

Evidence

the evidence for each data point(in the test set) is calculated using the equation

p(x) = P (w1) ∗ p(x|w1) + P (w2) ∗ p(x|w2) (being a two category case)

Posterior Probability

Using Bayes rule, the posterior probability (Conditional probability) is found for each of the two classes.

posterior probability = apriori probability ∗ likelihood / evidence

Now with the conditional probabilities computed for each of the two classes, we can make a prediction based off of the values of P(w1|x) and P (w2|x).

Prediction

And being a minimum error rate classifier, we define the discriminant function gi(x) as P (wi|x). if P(w1|x) ≥ P (w2|x) (i.e., g1(x) ≥ g2(x)) then we predict the class to be w1 and predict w2 otherwise.

minerrorrateclassifier's People

Contributors

tejvi-m avatar

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.