ancardona / map-classifier-python

Maximum A Posteriori Classifier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

map-classifier

Build Status Coverage Status

A classifier of Maximum A Posteriori (MAP) which is compatible with scikit-learn.

Install with pip

pip3 install --upgrade git+https://github.com/nwtgck/map-classifier-python.git

Install with Pipenv

pipenv install --dev toml
pipenv install git+https://github.com/nwtgck/map-classifier-python.git@v0.4.1#egg=map-classifier

Mathematical expression

where

(these images created by math2image)

Example Usage

from sklearn.datasets import load_iris
from sklearn import metrics
from sklearn.model_selection import train_test_split

import map_classifier


# Load Iris data set
X, y = load_iris(return_X_y=True)

# Create a classifier
clf = map_classifier.MAPClassifier()

# Create training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.3, random_state=40)

# Learn then model
clf.fit(X_train, y_train)

# Predict
y_pred = clf.predict(X_test)

# Calc accuracy
test_accuracy = metrics.accuracy_score(y_test, y_pred)

# Print the accuracy
print(test_accuracy)

You can find examples in examples.

About

Maximum A Posteriori Classifier


Languages

Language:Python 92.7%Language:TeX 7.3%