Giter Site home page Giter Site logo

alan-toledo / machine-learning-algorithms Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 3.0 15.82 MB

Machine Learning From Scratch

License: MIT License

Python 100.00%
machine-learning-algorithms neural-networks expectation-maximization-algorithm svm-classifier gaussian-discriminant-analysis k-means naive-bayes-classifier poisson-regression polynomial-regression logistic-regression reinforcement-learning

machine-learning-algorithms's Introduction

ML

ML from Scratch

Polynomial Regression

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • This code generate a polynomial (degree k) feature map (0 to k) using the training data (function create_poly).
  • This code generate a polynomial (degree k) feature map (0 to k) plus sinusoidal function using the training data (function create_sin).
  • This code fit linear model solving Ax = b (function fit)
  • This code make a prediction given new inputs (function predict).

Execution

python main.py

Description (vscikit-learn.py)

  • This version of code uses sklearn functions to valid the previous results.

Execution

python vscikit-learn.py

Logistic Regression

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • This code fits a model using Newton's method to minimize the logistic regression loss function.
  • This code make a prediction given new inputs (function predict).

Execution

python main.py

Description (vscikit-learn.py)

  • This version of code uses sklearn functions to valid the previous results.

Execution

python vscikit-learn.py

Gaussian Discriminant Analysis

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • Parameters associated to Multivariate Gaussian distribution are computed: mean vectors (mu) and covariance matrix (sigma).
  • This code make a prediction given new inputs (function predict).

Execution

python main.py

Description (vscikit-learn.py)

  • This version of code uses sklearn functions to valid the previous results.

Execution

python vscikit-learn.py

Poisson Regression

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • This code implements a Generalized Linear Model with a Poisson distribution with gradient ascent.
  • This code make a prediction given new inputs (function predict).

Execution

python main.py

Description (vscikit-learn.py)

  • This version of code uses sklearn functions to valid the previous results.

Execution

python vscikit-learn.py

Naive Bayes Classifier

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • This code classifies (predicts) a message text is spam or not.
  • This code make a prediction given new inputs (function predict_from_naive_bayes_model).

Execution

python main.py

Description (vscikit-learn.py)

  • This version of code uses sklearn functions to valid the previous results.

Execution

python vscikit-learn.py

Support Vector Machines

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • This code classifies (predicts) a message text is spam (1) or not (0).
  • This code make a prediction given new inputs (function svm.train_and_predict_svm).

Execution

python main.py

Description (vscikit-learn.py)

  • This version of code uses sklearn functions to valid the previous results.

Execution

python vscikit-learn.py

K-means

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • This code uses k-Means to compress a image. Where the image is reduced to 16 colors (num_clusters = 16).
  • Each pixel (RGB) is assigned to the closest centroid.

Execution

python main.py

Description (vscikit-learn.py)

  • This version of code uses sklearn functions to valid the previous results.

Execution

python vscikit-learn.py

Semi Supervised Expectation Maximization

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • This code implements Gaussian Mixture Model (GMM) to apply semi-supervised EM algorithm with labelled and unlabelled data.
  • E-step and M-step are computed.
  • The input data (or new data) is clustered.

Execution

python main.py

Description (vscikit-learn.py)

  • This version of code uses sklearn functions to valid the previous results (Unsupervised Expectation-Maximization).

Execution

python vscikit-learn.py

Neural Network

Description (main.py)

  • This code does not use sklearn functions (from scratch)
  • This code implements a simple neural network (NN) to classify grayscale images of handwritten digits (0 - 9) from the MNIST dataset.
  • This NN has a single hidden layer (sigmoid function as activation) and cross entropy loss (softmax function for the output layer).

Execution

python main.py

Description (vTensorFlow.py)

  • This version of code uses TensorFlow functions to valid the previous results.

Execution

python vTensorFlow.py

Reinforcement Learning - The inverted pendulum

Description (cartpole.py)

  • This code does not use sklearn functions (from scratch)
  • Parts of the code (cart and pole dynamics, and the state discretization) are inspired from code available at the RL repository http://all.cs.umass.edu//rlr//domains.html and the course XCS229 Machine Learning from Stanford University.
  • The cart-pole system is described in cartpole.py. The main simulation loop in this file calls the simulate() function for simulating the pole dynamics, get_state() for discretizing the otherwise continuous state space in discrete states, and show_cart() for display.
  • The code presented in functions.py shows a estimate model for the underlying Markov Decision Process (MDP), solving the Bellman's equations for this estimated MDP.

Execution

python cartpole.py

Reinforcement Learning - Grid World environment

Description

  • This code does not use sklearn functions (from scratch)
  • This code implements REINFORCE policy gradient algorithm to optimize on a stochastic policy that solves a simple gridded environment.

Execution

python train.py

machine-learning-algorithms's People

Contributors

alan-toledo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.