Code Monkey home page Code Monkey logo

aws-mlu-explain's Introduction

MLU-Explain Logo & Title

This repository holds the code used for Amazon's MLU-Explain educational articles on machine learning. MLU-Explain exists to illustrate core machine learning concepts using visual essays in a fun, informative, and accessible manner.

This material exists as supplementary educational material for Machine Learning University (MLU), which provides anybody, anywhere, at any time access to the same machine learning courses used to train Amazon’s own developers on machine learning.

Articles

Linear Regression

Linear Regression Article Image

Title: Linear Regression

Summary: A visual, interactive explanation of linear regression for machine learning.

Code: /code/linear-regression/

Authors: Jared Wilber

Logistic Regression

Logistic Regression Article Image

Title: Logistic Regression

Summary: Learn about how logistic regression can be used for binary classification through an interactive example.

Code: /code/logistic-regression/

Authors: Erin Bugbee, Jared Wilber

ROC & AUC

ROC & AUC Article Preview

Title: ROC & AUC

Summary: A visual explanation of the Receiver Operating Characteristic Curve (ROC) curve, how it works with a live interactive example, and how it relates to Area Under The Curve (AUC).

Code: /code/roc-auc/

Authors: Jared Wilber

Train, Test, And Validation Sets

Train, Test, And Validation Sets Article Image

Title: Train, Test, and Validation Sets

Summary: Learn why it is best practice to split your data into training, testing, and validation sets, and explore the utility of each with a live machine learning model.

Code: /code/train-test-validation/

Authors: Jared Wilber, Brent Werness

Precision & Recall

Precision & Recall Article Preview

Title: Precision & Recall

Summary: When it comes to evaluating classification models, accuracy is often a poor metric. This article covers two common alternatives, Precision and Recall, as well as the F1-score and Confusion Matrices.

Code: /code/precision-recall/

Authors: Jared Wilber

Random Forest

Random Forest Article Image

Title: Random Forest

Summary: Learn how the majority vote and well-placed randomness can extend the decision tree model to one of machine learning's most widely-used algorithms, the Random Forest.

Code: /code/random-forest/

Authors: Jenny Yeon, Jared Wilber

Decision Trees

Decision Trees Article Image

Title: Decision Trees

Summary: Explore one of machine learning's most popular supervised algorithms: the Decision Tree. Learn how the tree makes its splits, the concepts of Entropy and Information Gain, and why going too deep is problematic.

Code: /code/decision-tree/

Authors: Jared Wilber, Lucía Santamaría

Bias Variance Tradeoff

Bias Variance Tradeoff Article Image

Title: The Bias Variance Tradeoff

Summary: Understand the tradeoff between under- and over-fitting models, how it relates to bias and variance, and explore interactive examples related to LASSO and KNN.

Code: /code/bias-variance/

Authors: Jared Wilber, Brent Werness

Double Descent: A Visual Introduction

Double Descent Article Image

Title: Double Descent

Summary: Meet the double descent phenomenon in modern machine learning: what it is, how it relates to the bias-variance tradeoff, the importance of the interpolation regime, and a theory of what lies behind.

Code: /code/double-descent/

Authors: Jared Wilber, Brent Werness

Double Descent 2: A Mathematical Explanation

Double Descent 2 Article Image

Title: Double Descent 2

Summary: Deepen your understanding of the double descent phenomenon. The article builds on the cubic spline example introduced in Double Descent 1, describing in mathematical detail what is happening.

Code: /code/double-descent2/

Authors: Brent Werness, Jared Wilber

Running Locally

This article holds code for each articles, as well as the generated builds from the code (e.g. the static assets comprising the articles).

First, clone this repo.

git clone https://github.com/aws-samples/aws-mlu-explain.git

Next, cd into the article of interest and install the required libraries.

# e.g. bias variance tradeoff article
cd bias-variance
# install libraries
npm install

Now, to run the development version:

npm start

To build and view the static assests:

# build assets
npm run build
# view generated article
cd dist/
# run local server
python3 -m http.server # or just `live-server`

License Summary

This open source articles are made available under the Creative Commons Attribution-ShareAlike 4.0 International License. See LICENSE file.

The sample and reference code within this open source book is made available under a modified MIT license. See the LICENSE-SAMPLECODE file.

aws-mlu-explain's People

Contributors

amazon-auto avatar anandkamat05 avatar cd-jcroome avatar dependabot[bot] avatar erebus9856 avatar erinbugbee avatar jaspercroome avatar jwilber avatar mimicarina avatar mlu-explain avatar natsirtguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-mlu-explain's Issues

Make internalization easier

Thanks for this initiative.

I would like to contribute a translation to an RTL (right to left) language for your articles. Could you document how you intend to support internationalization for this website?

Thanks

Minor typo in the r-squared definition

Hi there,

This latex equation

`\\begin{aligned} R^2 = 1 - \\frac{\\Sigma^{n}_{i=1}(y_i - \\hat{y_i})^2 }{\\Sigma^{n}_{i=1}(y_i - \\bar{y_i})^2 } \\end{aligned}`,

image

should be (removing the i sub for the mean in the r^2 metric definition)

 `\\begin{aligned} R^2 = 1 - \\frac{\\Sigma^{n}_{i=1}(y_i - \\hat{y_i})^2 }{\\Sigma^{n}_{i=1}(y_i - \\bar{y})^2 }  \\end{aligned}`, 

image

Can not reproduce double descent phenomenon

I tried to reproduce the double descent phenomenon shown here in the blog but have had no success so far.

double_descent

The mean absolute error first decreases with more features and then grows only very slightly as the model overfits the training data set, which is what I would expect if double descent did not exist.

A thing I was not sure about were the "random non-linear features" mentioned in the blog. I chose scaled and shifted Tanh features since that was the first that came to my mind, but my MAE is slightly smaller than the one in the blog post, so maybe that is the issue? Which non-linear features have been used in the blog post?

Another potential issue could be insufficient regularization during matrix inversion since the problem is under-constrained with too many features. Maybe we are seeing numerical issues in the image from the blog post which get smoothed out with even more features? I'd imagine that with too many elements, numerical issues might behave like random noise, which has a regularizing effect.

double_descent_from_blog

Could you perhaps share the code which was used to generate the data shown in the figures from the blog? So far, I could only find a file with the data, but not the code to generate it, although I did not look very hard. Maybe it is somewhere else or I did not recognize it.

For reproducibility, here is my code to generate my figure at the very top.

import numpy as np
import matplotlib.pyplot as plt
np.random.seed(0)
# Initialize data
x_train = np.linspace(-2, 2, 41)
y_train = np.float64([-20,-13,-7,-2,1,4,20,9,10,11,11,11,10,9,13,9,4,2,0,-1,-4,-6,-8,-11,-13,-15,-16,-18,-19,-19,-15,-19,-18,-17,-15,-13,0,-5,0,5,11])/10
x_test = np.linspace(-2, 2, 1000)
y_test = -0.4 - 2.27 * x_test + 0.76 * x_test**3
rand_vals = np.random.randn(100, 2)
MAE = []

def gen_rand_features(x):
    # Use scaled and shifted tanh as non-linear features
    return np.array([np.tanh(a * x + b) for a, b in rand_vals[:K]])

for K in range(1, 100):
    R = gen_rand_features(x_train)
    # Solve for weights of random features. 1e-10 seems to be sufficient
    # regularization to avoid numerical issues without influencing the result.
    weights = np.linalg.solve(R @ R.T + 1e-10 * np.eye(K), R @ y_train)
    y_prediction = gen_rand_features(x_test).T @ weights
    MAE.append(np.mean(np.abs(y_test - y_prediction)))

    if K == 33:
        plt.figure(figsize=(10, 4))
        plt.subplot(1, 2, 1)
        plt.title(f"Model with K = {K} Features")
        plt.plot(x_train, y_train, label="$y_{train}$")
        plt.plot(x_test, y_prediction, label="$y_{prediction}$")
        plt.legend()

        plt.subplot(1, 2, 2)
        plt.plot([np.log(K), np.log(K)], [0, 1], '--k', label=f"K = {K}")

plt.plot(np.log(np.arange(K) + 1), MAE)
plt.xlabel("Log(# of Non-linear Features)")
plt.ylabel("Mean Absolute Error")
plt.legend()
plt.ylim([0, 1])
plt.show()

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.