DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Homemade Machine Learning in Python

Homemade Machine Learning in Python

When it comes to Jupyter Notebook demos, libraries such as Matplotlib and Plotly are being used for data visualizations.

Oleksii Trekhleb user avatar by
Oleksii Trekhleb
·
Jan. 03, 19 · Opinion
Like (8)
Save
Tweet
Share
7.52K Views

Join the DZone community and get the full member experience.

Join For Free

I’ve recently launched Homemade Machine Learning repository that contains examples of popular Machine Learning algorithms and approaches (like linear/logistic regressions, K-Means clustering, neural networks) implemented in Python with mathematics behind them being explained. Each algorithm has an interactive Jupyter Notebook demo that allows you to play with training data and algorithms configurations and immediately see the results, charts, and predictions right in your browser. In most cases, the explanations are based on this great Machine Learning course by Andrew Ng.

The purpose of the repository was not to implement Machine Learning algorithms by using 3rd-party library “one-liners” but rather to practice implementing these algorithms from scratch and get a better understanding of the mathematics behind each algorithm. That’s why all algorithms implementations are called “homemade.”

The main Python libraries that are used there are NumPy and Pandas. These two are used for efficient matrix operations and for loading/parsing CSV datasets. When it comes to Jupyter Notebook demos, libraries such as Matplotlib and Plotly are being used for data visualizations.

Currently, the following topics have been covered:

Regression: Linear Regression

In regression problems, we do real value predictions. Basically, we try to draw a line/plane/n-dimensional plane along the training examples.

Usage examples: stock price forecast, sales analysis, dependency of any number, etc.

  • Linear Regression Math — theory and links for further readings
  • Linear Regression Implementation Example
  • Demo | Univariate Linear Regression — predict country happinessscore by economy GDP
  • Demo | Multivariate Linear Regression — predict country happinessscore by economy GDP and freedom index
  • Demo | Non-linear Regression — use linear regression with polynomial and sinusoid features to predict non-linear dependencies.

Classification: Logistic Regression

In classification problems, we split input examples by certain characteristic.

Usage examples: spam-filters, language detection, finding similar documents, handwritten letters recognition, etc.

  • Logistic Regression Math — theory and links for further readings
  • Logistic Regression Implementation Example
  • Demo | Logistic Regression (Linear Boundary) — predict Iris flower class based on petal_length and petal_width
  • Demo | Logistic Regression (Non-Linear Boundary) — predict microchip validity based on param_1 and param_2
  • Demo | Multivariate Logistic Regression — recognize handwritten digits from 28x28 pixel images.

Clustering: K-Means Algorithm

In clustering problems, we split the training examples by unknown characteristics. The algorithm itself decides what characteristic to use for splitting.

Usage examples: market segmentation, social networks analysis, organize computing clusters, astronomical data analysis, image compression, etc.

  • K-means Algorithm Math — theory and links for further readings
  • K-means Algorithm Implementation Example
  • Demo | K-means Algorithm — split Iris flowers into clusters based on petal_length and petal_width

Neural Networks: Multilayer Perceptron (MLP)

The neural network itself isn’t an algorithm, but rather a framework for many different Machine Learning algorithms to work together and process complex data inputs.

Usage examples: as a substitute of all other algorithms in general, image recognition, voice recognition, image processing (applying a specific style), language translation, etc.

  • Multilayer Perceptron Math — theory and links for further readings
  • Multilayer Perceptron Implementation Example
  • Demo | Multilayer Perceptron — recognize handwritten digits from 28x28 pixel images.

Anomaly Detection: Gaussian Distribution

Anomaly detection (also outlier detection) is the identification of rare items, events or observations which raise suspicions by differing significantly from the majority of the data.

Usage examples: intrusion detection, fraud detection, system health monitoring, removing anomalous data from the dataset etc.

  • The Math Behind Anomaly Detection using Gaussian Distribution

I hope you’ll find the repository useful. Either by playing with demos or by reading the math sections or by simply exploring the source code. Happy coding!

Machine learning Linear regression Algorithm Python (language) jupyter notebook clustering

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Memory Debugging: A Deep Level of Insight
  • Microservices Discovery With Eureka
  • 2023 Software Testing Trends: A Look Ahead at the Industry's Future
  • How and Why You Should Start Automating DevOps

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: