Skip to main content

Machine Learning Python Library

Project description

BuildTest PythonVersion PyPi Downloads License

Machine Learning Python Library

Install

pip install machlearn

Example 1: Model evaluation

from machlearn import model_evaluation as me
me.demo()

Selected Output:

image_demo_confusion_matrix

image_demo_ROC_curve

image_demo_PR_curve


Example 2: Naive Bayes

from machlearn import naive_bayes as nb
nb.demo()

Selected Output:

This demo uses a public dataset of SMS spam, which has a total of 5574 messages = 747 spam and 4827 ham (legitimate).
The goal is to use 'term frequency in the message' to predict whether the message is ham (class=0) or spam (class=1).

Using test_size = 0.25 and training a multinomial naive bayes model, the best hyperparameters were found to be:
   Step1: Convert from text to count matrix = CountVectorizer(analyzer = __lemmas);
   Step2: Transform count matrix to tf-idf = TfidfTransformer(use_idf = True).

Application example:
   - Message: "URGENT! We are trying to contact U. Todays draw shows that you have won a 2000 prize GUARANTEED. Call 090 5809 4507 from a landline. Claim 3030. Valid 12hrs only."
   - Probability of class=1 (spam): 95.85%
   - Classification: spam

image_naive_bayes_confusion_matrix

image_naive_bayes_ROC_curve

image_naive_bayes_PR_curve


module: model_evaluation

function

description

plot_confusion_matrix()

plots the confusion matrix, along with key statistics, and returns accuracy

plot_ROC_curve()

plots the ROC (Receiver Operating Characteristic) curve, along with statistics

plot_PR_curve()

plots the precision-recall curve, along with statistics

plot_ROC_and_PR_curves()

plots both the ROC and the precision-recall curves, along with statistics

demo()

provides a demo of the major functions in this module


module: naive_bayes

function

description

naive_bayes_Bernoulli()

when X are independent binary variables (e.g., whether a word occurs in a document or not)

naive_bayes_multinomial()

when X are independent discrete variables with 3+ levels (e.g., term frequency in the document)

naive_bayes_Gaussian()

when X are continuous variables

demo()

provides a demo of selected functions in this module


module: neural_network

function

description

rnn()

Recurrent neural network

demo()

provides a demo of selected functions in this module


module: decision_tree

function

description

boost()

Boosting

demo()

provides a demo of selected functions in this module

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

machlearn-1.0.0.tar.gz (9.3 kB view hashes)

Uploaded Source

Built Distribution

machlearn-1.0.0-py3-none-any.whl (11.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page