Skip to content

pm429015/SmartML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

About

Welcome to my Machine Learning playground. SmartML is a collection of experiment machine learning algorithms that I implemented from scratch in python. The goal of this project is to get hands dirty and experience the real power of Machine Learning.

My ultimate goal is to build a ML toolbox that speed up the time on finding the best approach for your dataset. This is the reason why I call it ‘smart’ ML.

Currently, this project is very far from my ultimate goal, but it is good for anyone who want to play around the well-known ML algorithms. You are free to change or use it.

My blog also cover most of ML algorithms that I implemented in SmartML with examples, so feel free to use it as reference. Thanks.

My Blog : Make it easy

Project Setup:

Requirement:

  • Python 2.75
  • Numpy
  • Matplotlib
  • Libsvm

(Please Go to : Libsvm to Download the library, then open a terminal direct to .libsvm.3.XX/python/ and type “make”.)

Libsvm

SmartML Algorithm include : ============

Dimension reduction:

  • PCA
  • Kernel PCA
  • SVD
  • LDA
  • Factor Analysis

Normalization:

  • min MAX
  • Z Score
  • log

Supervise Algorithms (Classifiers):

  • KNN
  • Logistic Regression
  • ID3 Tree
  • Naive Bayes
  • SVM
  • Adaboost

Unsupervised Algorithm :

  • KMean

Regression :

  • RidgeRegression
  • Local weighted linear regression (lwlr)
  • Regression tree (regtree)

Others:

  • Hidden Markov Model

Usage

  1. Import SmartML:

    from smartML.main import SmartML

# General Usage

  1. first, Declare my smart ML:

    myML = SmartML()
  2. load data using trainSet.txt for example:

    myML.loadfile('./trainSet.txt', ',', 'supervise', normalize=‘minMax’)
  3. (Optional) plot data:

    myML.plot(1, 0)
  4. (Optional) dim reduce methods call:

    myML.dimReduce('FactorAnalysis')
  5. call ML methods:

Methods Include:

  • unsupervise: kmeans
  • regression: Linear, local weighted linear regression (lwlr) and regression tree (regtree)
  • supervise: KNN, naive bayes (naivebay), logistic regression (logistic), ID3, adaboost and SVM (libsvm)

    myML.learner(method=‘ID3’)

  1. test your model:

    myML.tester(test.dataset)
  2. return a result label array for testing dataset

# HMM

  1. construct a probability table:

    prob = {}
    
    prob['transition'] = array([[.6, .2, .1, .2], [.6, .05, .1, .25], [.15, .05, .6, .2], [.2, .1, .3, .4]])
    
    prob['emission'] = array([[.2, .1, .5, .2], [.1, .4, .3, .2], [.2, .3, .5, 0], [.2, .2, .1, .5]])
    
    prob['state'] = ['watching TV', 'Pub Night', 'Party Night', 'Study']
    
    prob['observations'] = ['tired', 'hungover', 'scared', 'fine']
  2. call smartML:

    myML = SmartML()
  3. call leaner method with table:

    my.learner('HMM', param=prob)
  4. create a observation:

    obs = array([0, 3, 2, 3, 0, 1, 1])
  5. probability return:

    my.tester(obs)

My Blog for HMM silly example

Have Fun !~

About

Machine Learning from Scratch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages