Code Monkey home page Code Monkey logo

pca_from_scratch's Introduction

Principal Component Analysis (PCA) From Scratch Using Numpy

Project Overview

This project recreates the PCA algorithm from scratch using numpy for matrix operations. It then compares it to the PCA implementation from scikit-learn. The dataset used is the Iris flower dataset containing sepal length, width and petal length, width for 3 different types of irises' (Setosa, Versicolour, and Virginica) stored in a 150x4. Each type of irises has 50 instances in the dataset. The labels are removed for PCA since the goal is dimensionality reduction.

Recreating the PCA algorithm gives the benefit of

  • understanding what happens under the hood of the algorithm
  • understanding if the dimension reductionality for a dataset is best achieved using PCA
  • understanding the mathematical concepts leveraged by the algorithm
  • Allows for model customization

For a detailed explanation on the theory used for this computation, check out the accompanying article on medium

Code

You can find the code for this project here.

File overview:

  • Build_PCA_(Principal_Component_Analysis)_from_Scratch.ipynb - the full code from this project

Environment Setup

Installation

To follow this project, please install the following locally:

  • Python 3.8+
  • Python packages
    • pandas
    • numpy
    • scikit-learn

Data

The data used for this implementation is the salary data originally on Kaggle.

You can download the file we'll use in this project here:

  • IRIS.csv - the Iris dataset used in this project.

pca_from_scratch's People

Contributors

ayoakin avatar

Watchers

 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.