# joelgrus/data-science-from-scratch

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/joelgrus-data-science-from-scratch).**

9,636 stars · 4,713 forks · Python · MIT

## Links

- GitHub: https://github.com/joelgrus/data-science-from-scratch
- awesome-repositories: https://awesome-repositories.com/repository/joelgrus-data-science-from-scratch.md

## Description

This project is a collection of foundational machine learning algorithms and data science tools implemented in Python. It focuses on building the logic of these tools using basic programming primitives rather than relying on specialized libraries.

The implementation covers several core domains, including a linear algebra library for matrix and vector operations, a statistical analysis toolkit for probability and hypothesis testing, and a framework for map-reduce distributed processing. It also includes implementations for natural language processing, graph theory for network analysis, and various machine learning models.

The capabilities extend to building specific models such as feed-forward neural networks, decision trees, and recommender systems. It provides tools for mathematical optimization via gradient descent, the calculation of model performance metrics, and data processing utilities for parsing structured data and extracting content from HTML.

## Tags

### Artificial Intelligence & ML

- [Data Science Algorithms](https://awesome-repositories.com/f/artificial-intelligence-ml/data-science-algorithms.md) — Implements fundamental machine learning and data science algorithms using basic programming primitives. ([source](https://github.com/joelgrus/data-science-from-scratch/tree/master/im))
- [Machine Learning Implementations](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning-implementations.md) — Provides code-based implementations of core supervised and unsupervised machine learning algorithms using basic programming primitives. ([source](https://github.com/joelgrus/data-science-from-scratch/tree/master/first-edition))
- [Python Machine Learning Libraries](https://awesome-repositories.com/f/artificial-intelligence-ml/python-machine-learning-libraries.md) — Implements foundational machine learning algorithms and data science tools from scratch using Python.
- [Decision Trees](https://awesome-repositories.com/f/artificial-intelligence-ml/decision-trees.md) — Constructs tree-based models using splits and leaves to classify data attributes. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/decision_trees.py))
- [Feed-Forward Neural Networks](https://awesome-repositories.com/f/artificial-intelligence-ml/feed-forward-neural-networks.md) — Implements the fundamental architecture of neural networks where data flows in a single direction from input to output. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/neural_networks.py))
- [Linear Regression](https://awesome-repositories.com/f/artificial-intelligence-ml/linear-regression.md) — Implements statistical methods for modeling relationships between variables using linear equations and gradient descent. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/simple_linear_regression.py))
- [Gradient Computation](https://awesome-repositories.com/f/artificial-intelligence-ml/gradient-computation.md) — Provides tools for calculating function gradients to support model training and optimization via backpropagation. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/neural_networks.py))
- [Numerical Gradient Approximations](https://awesome-repositories.com/f/artificial-intelligence-ml/gradient-computation/numerical-gradient-approximations.md) — Implements numerical gradient approximations using finite difference methods to estimate function slopes. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/gradient_descent.py))
- [Iterative Parameter Optimizations](https://awesome-repositories.com/f/artificial-intelligence-ml/iterative-parameter-optimizations.md) — Provides logic for repeatedly updating model weights using loss functions and gradient descent to fit data. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/gradient_descent.py))
- [K-Nearest Neighbor Classifiers](https://awesome-repositories.com/f/artificial-intelligence-ml/k-nearest-neighbor-classifiers.md) — Implements a supervised learning model that assigns classes based on the majority vote of the closest training samples. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/k_nearest_neighbors.py))
- [Linear Model Performance Metrics](https://awesome-repositories.com/f/artificial-intelligence-ml/linear-model-performance-metrics.md) — Measures linear fit quality using squared errors and the R-squared coefficient. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/simple_linear_regression.py))
- [Logistic Regression Models](https://awesome-repositories.com/f/artificial-intelligence-ml/logistic-regression-models.md) — Implements algorithms for predicting binary outcomes using the sigmoid function and weight optimization. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/logistic_regression.py))
- [Naive Bayes Classifiers](https://awesome-repositories.com/f/artificial-intelligence-ml/naive-bayes-classifiers.md) — Implements probabilistic classification models based on statistical feature distributions to categorize text. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/naive_bayes.py))
- [Natural Language Processing](https://awesome-repositories.com/f/artificial-intelligence-ml/natural-language-processing.md) — Provides foundational techniques for analyzing and processing human language data. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/README.md))
- [Natural Language Processing Implementations](https://awesome-repositories.com/f/artificial-intelligence-ml/natural-language-processing-implementations.md) — Provides reference implementations for text analysis, n-gram generation, and text classification.
- [N-Gram Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/natural-language-processing/word-embeddings/skip-gram-model-architectures/n-gram-co-occurrence-models/n-gram-generators.md) — Implements tools for generating contiguous word sequences based on n-gram sampling from source text. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/nlp.py))
- [Gradient Descent Algorithms](https://awesome-repositories.com/f/artificial-intelligence-ml/optimization-algorithms/gradient-descent-algorithms.md) — Implements iterative optimization algorithms that update model parameters by moving in the direction of the negative gradient. ([source](https://github.com/joelgrus/data-science-from-scratch/tree/master/first-edition))
- [Perceptrons](https://awesome-repositories.com/f/artificial-intelligence-ml/perceptrons.md) — Implements basic linear classifiers that learn a weight vector to separate two classes of data. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/neural_networks.py))
- [Performance Metrics](https://awesome-repositories.com/f/artificial-intelligence-ml/performance-metrics.md) — Provides tools for calculating essential statistical performance indicators like accuracy, precision, and recall. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/machine_learning.py))
- [Popularity-Based Recommendations](https://awesome-repositories.com/f/artificial-intelligence-ml/popularity-based-recommendations.md) — Suggests items based on global frequency while filtering out items already owned. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/recommender_systems.py))
- [Recommender Systems](https://awesome-repositories.com/f/artificial-intelligence-ml/recommender-systems.md) — Implements algorithms designed to predict user preferences and suggest relevant items based on historical patterns. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/README.md))
- [User-to-User Similarity](https://awesome-repositories.com/f/artificial-intelligence-ml/recommender-systems/recommendation-list-generators/user-to-user-similarity.md) — Identifies similar user profiles using cosine similarity to suggest items based on peer preferences. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/recommender_systems.py))

### Data & Databases

- [Distributed Data Processing Engines](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-transformation/stream-pipeline-orchestration/distributed-data-processing-engines.md) — Implements distributed data processing systems using map-reduce techniques to handle large datasets. ([source](https://github.com/joelgrus/data-science-from-scratch#readme))
- [MapReduce Processing Engines](https://awesome-repositories.com/f/data-databases/mapreduce-processing-engines.md) — Provides a framework for executing batch computations by mapping and reducing records into aggregated results. ([source](https://github.com/joelgrus/data-science-from-scratch/tree/master/first-edition))
- [Data Visualization](https://awesome-repositories.com/f/data-databases/data-analysis-visualization/visualization-frameworks-libraries/data-visualization.md) — Provides tools to render numeric datasets into visual formats like charts and graphs. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/visualization.py))
- [Distribution Histograms](https://awesome-repositories.com/f/data-databases/data-management/unique-identifier-generators/uniqueness-enforcement/distribution-histograms.md) — Generates frequency histograms to visualize the distribution of numeric data. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/working_with_data.py))
- [Graph Libraries](https://awesome-repositories.com/f/data-databases/graph-computing-systems/graph-theory/graph-libraries.md) — Implements graph algorithms and data structures for network analysis and centrality calculations.

### Scientific & Mathematical Computing

- [Linear Algebra Libraries](https://awesome-repositories.com/f/scientific-mathematical-computing/linear-algebra-libraries.md) — Provides foundational matrix and vector operation primitives for mathematical modeling and scientific computing.
- [Linear Algebra Routines](https://awesome-repositories.com/f/scientific-mathematical-computing/linear-algebra-routines.md) — Implements fundamental linear algebra operations, including matrix and vector calculations required for scientific computing. ([source](https://github.com/joelgrus/data-science-from-scratch/tree/master/first-edition))
- [Matrix Manipulations](https://awesome-repositories.com/f/scientific-mathematical-computing/matrix-manipulations.md) — Extracts specific rows and columns or generates identity matrices from custom grids. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/linear_algebra.py))
- [Linear Algebra](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/linear-algebra.md) — Executes fundamental vector and matrix calculations, such as dot products, for mathematical modeling. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/README.md))
- [Statistical Analysis Libraries](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/statistics-probability/statistical-analysis-libraries.md) — Provides a toolkit for applying probability models and statistical inference to derive insights from datasets. ([source](https://github.com/joelgrus/data-science-from-scratch#readme))
- [Statistical Metric Calculators](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/statistics-probability/statistical-analysis-libraries/statistical-metric-calculators.md) — Computes probability and hypothesis tests to analyze data distributions and trends. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/README.md))
- [Statistical Analysis Libraries](https://awesome-repositories.com/f/scientific-mathematical-computing/research-analysis-workflows/research-and-data-analysis-tools/statistical-analysis-libraries.md) — Provides a toolkit for computing probability distributions, hypothesis tests, and central tendency metrics.
- [Hypothesis Testing](https://awesome-repositories.com/f/scientific-mathematical-computing/research-analysis-workflows/research-and-data-analysis-tools/statistical-analysis-libraries/hypothesis-testing.md) — Provides statistical procedures and tools for executing hypothesis tests to determine the significance of observations. ([source](https://github.com/joelgrus/data-science-from-scratch/tree/master/first-edition))
- [Standard Deviation Calculators](https://awesome-repositories.com/f/scientific-mathematical-computing/average-deviation-calculators/standard-deviation-calculators.md) — Computes the standard deviation of a dataset to measure value dispersion. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/statistics.py))
- [Central Tendency Measures](https://awesome-repositories.com/f/scientific-mathematical-computing/central-tendency-measures.md) — Computes mean, median, and mode to identify the center of a distribution. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/statistics.py))
- [Correlation Matrices](https://awesome-repositories.com/f/scientific-mathematical-computing/correlation-coefficient-calculators/correlation-matrices.md) — Generates correlation matrices to identify linear relationships between multiple data vectors. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/working_with_data.py))
- [Discrete Event Simulators](https://awesome-repositories.com/f/scientific-mathematical-computing/discrete-event-simulators.md) — Generates outcomes for Bernoulli and Binomial trials to model discrete random events. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/probability.py))
- [Inverse Cumulative Distribution Functions](https://awesome-repositories.com/f/scientific-mathematical-computing/inverse-cumulative-distribution-functions.md) — Finds the value for a given probability in a normal distribution using binary search. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/probability.py))
- [Network Graph Analysis](https://awesome-repositories.com/f/scientific-mathematical-computing/network-graph-analysis.md) — Provides capabilities to study connections between entities in a network to identify clusters and influence. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/README.md))
- [Normal Distribution Probability Estimation](https://awesome-repositories.com/f/scientific-mathematical-computing/normal-distribution-probability-estimation.md) — Predicts the likelihood that a value falls within a specific range of a Gaussian distribution. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/inference.py))
- [Normal Distribution Bounds](https://awesome-repositories.com/f/scientific-mathematical-computing/normal-distribution-probability-estimation/normal-distribution-bounds.md) — Calculates boundaries that contain a specified probability for a normal distribution. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/inference.py))
- [Shortest Path Algorithms](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithms/graph-processing/shortest-path-algorithms.md) — Implements algorithms to calculate the most efficient path between nodes in a graph. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/network_analysis.py))
- [Distribution Function Calculators](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/statistics-probability/probability-distributions/distribution-function-calculators.md) — Implements functions for computing cumulative distribution functions and their inverses for uniform and normal spreads. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/probability.py))
- [P-Value Calculations](https://awesome-repositories.com/f/scientific-mathematical-computing/p-value-calculations.md) — Determines the probability of observing extreme values in either direction under a normal distribution. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/inference.py))
- [Parameter Estimation](https://awesome-repositories.com/f/scientific-mathematical-computing/population-statistics-calculators/parameter-estimation.md) — Infers population parameters, such as mean and standard deviation, from sample data using binomial distributions. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/inference.py))
- [Quantile and Percentile Calculators](https://awesome-repositories.com/f/scientific-mathematical-computing/quantile-and-percentile-calculators.md) — Provides mathematical tools for dividing sorted data into equal groups via quartiles and percentiles. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/statistics.py))
- [Dot Product Computation](https://awesome-repositories.com/f/scientific-mathematical-computing/vector-dot-product-kernels/dot-product-computation.md) — Computes dot products and Euclidean distances to analyze geometric relationships between vectors. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/linear_algebra.py))
- [Vector Operations](https://awesome-repositories.com/f/scientific-mathematical-computing/vector-operations.md) — Calculates element-wise addition, subtraction, and means for numeric vectors. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/linear_algebra.py))

### Software Engineering & Architecture

- [Betweenness Centrality](https://awesome-repositories.com/f/software-engineering-architecture/system-internals/centralization-patterns/network-centrality-analyses/betweenness-centrality.md) — Implements betweenness centrality to measure node influence via shortest path counts. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/network_analysis.py))
- [Closeness Centrality](https://awesome-repositories.com/f/software-engineering-architecture/system-internals/centralization-patterns/network-centrality-analyses/closeness-centrality.md) — Implements closeness centrality to determine node importance based on path lengths. ([source](https://github.com/joelgrus/data-science-from-scratch/blob/master/scratch/network_analysis.py))
