Code Monkey home page Code Monkey logo

plda-1's Introduction

Probabilistic Linear Discriminant Analysis

Disclaimer

This model was written for an Explainable Artificial Intelligence (XAI) project, so it stores a bunch of parameters in memory that are not necessary for simple classification problems.

Paper Citation

Ioffe S. (2006) Probabilistic Linear Discriminant Analysis. In: Leonardis A., Bischof H., Pinz A. (eds) Computer Vision โ€“ ECCV 2006. ECCV 2006.

Dependencies

If you already have Anaconda or Miniconda, you can automatically download all dependencies to a conda environment called plda with the following. Otherwise, see environment.yml.

conda env create -f environment.yml -n plda  # "plda" is the environment name.

Usage

  1. If you have one, activate your conda envrionment with conda activate plda.
  2. Move this repository to the appropriate directory. This might be a modules directory in your project or the same directory as the file importing this code.
  3. Add import plda to your code.
  4. See the demo below on how to use the actual model code.
  5. When you are all done, you can deactivate the conda environment with conda deactivate.

Demo with MNIST Handwritten Digits Data

See mnist_demo/mnist_demo.ipynb.

  • This demo shows you how to extract LDA features from your data.
  • For classification, the model automatically preprocesses your data, but with the default preprocessing setting, it could overfit small training datasets.
  • If you run into this issue, one way to address it is to reduce the number of principal components present in the preprocessed data.
  • The MNIST demo shows you how simple this is: just supply an optional parameter.

Testing

If you created the Conda environment with the name plda, activate it with the following.

conda activate plda  # If `plda` is the name you gave the Conda environment.

To run all tests (~120 seconds with ~60 CPU cores), use the following.

python3.5 pytest plda/  # This README.md should be inside here.

To run a particular test file, run one of the following.

pytest plda/tests/test_model/test_model_units.py  # ~.66s for me.
pytest plda/tests/test_model/test_model_integration.py  # ~1.0s for me.
pytest plda/tests/test_model/test_model_inference.py  #  ~80.6s for me.

pytest plda/tests/test_optimizer/test_optimizer_units.py  # ~.59s for me.
pytest plda/tests/test_optimizer/test_optimizer_integration.py  # ~.78s.
pytest plda/tests/test_optimizer/test_optimizer_inference.py  # ~25.3s for me.

pytest plda/tests/test_classifier/test_classifier_integration.py  # ~.69s.

Once you finish running the tests, remove all the __pycache__/ folders generated by pytest with the following.

py3clean plda/*  # This README.md should be in here.

Finally, if you are done working with the model and test code, deactivate the Conda environment.

conda deactivate  # You can run this from any directory.

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.