Machine Learning Python Library
Project description
Machine Learning Python Library
Install
pip install machlearn
Example 1: Model evaluation
from machlearn import model_evaluation as me
me.demo()
Selected Output:
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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for machlearn-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20b145ef2fdb00295bb052c604e9956203103ec778dbbf72a780c69421f3793a |
|
MD5 | aa70b32e8162c26876099b42e2afa32c |
|
BLAKE2b-256 | 4e5ba946a47661238c63131f43c58f1ea7820ef2e2705e4043b1558529f4d69e |