-
Notifications
You must be signed in to change notification settings - Fork 37
Anisha/calc #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Anisha/calc #107
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Learn Calculus for Machine Learning | ||
|
|
||
| _🚧 This collection is a work in progress. Please help us add notebooks!_ | ||
|
|
||
| This collection of marimo notebooks is designed to teach you the basics of calculus for machine learning. | ||
|
|
||
| **Help us build this course! ⚒️** | ||
|
|
||
| We're seeking contributors to help us build these notebooks. Every contributor will be acknowledged as an author in this README and in their contributed notebooks. Head over to the [tracking issue](https://github.com/marimo-team/learn/issues/58) to sign up for a planned notebook or propose your own. | ||
|
|
||
| **Running notebooks.** To run a notebook locally, use | ||
|
|
||
| ```bash | ||
| uvx marimo edit <file_url> | ||
| ``` | ||
|
|
||
| You can also open notebooks in our online playground by appending marimo.app/ to a notebook's URL. | ||
|
|
||
| **Thanks to all our notebook authors!** | ||
|
|
||
| [Anisha Kalgi](https://github.com/k-anisha) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,232 @@ | ||||||||||||||||||
| import marimo | ||||||||||||||||||
|
|
||||||||||||||||||
| __generated_with = "0.13.1" | ||||||||||||||||||
| app = marimo.App(width="medium") | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @app.cell | ||||||||||||||||||
| def _(): | ||||||||||||||||||
| import marimo as mo | ||||||||||||||||||
| import numpy as np | ||||||||||||||||||
| import matplotlib.pyplot as plt | ||||||||||||||||||
| from sympy import symbols | ||||||||||||||||||
| from sympy import diff | ||||||||||||||||||
| return diff, mo, np, plt, symbols | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @app.cell | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Would recommend doing this (hiding markdown cell blocks) throughout the notebook |
||||||||||||||||||
| def _(mo): | ||||||||||||||||||
| mo.md( | ||||||||||||||||||
| r""" | ||||||||||||||||||
| In this notebook, we'll learn about rates of change in Machine Learning. | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+17
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd start the notebook with the title being mentioned (h1 tag) followed by the author's name. Something like # Rates of Change in Machine Learning
*By [YourName](https://github.com/k-anisha)*
In this notebook, we'll learn about... |
||||||||||||||||||
| In simple terms, the rate of change measures how one quantity changes as we adjust its inputs or parameters. The rate of change can represent how a model's output changes as we adjust the input or parameters. | ||||||||||||||||||
|
|
||||||||||||||||||
| In calculus, the rate of change of a function is given by calculating the derivative at a certain point. So, if f(x) is a function, then f'(x) is the rate of change. | ||||||||||||||||||
|
|
||||||||||||||||||
| In the context of Machine Learning, rates of change are especially useful when working with optimization problems - for example, minimizing a loss function, or using gradient descent to try and find optimal parameters and minimize error. | ||||||||||||||||||
|
|
||||||||||||||||||
| Let's get into rates of change! | ||||||||||||||||||
| """ | ||||||||||||||||||
| ) | ||||||||||||||||||
| return | ||||||||||||||||||
|
Comment on lines
+23
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing that would help connect this to the issue description - consider adding a section before you get into derivatives directly, that shows the difference between:
You could use your Something like picking points at x=2 & x=4, then x=2 & x=3, then x=2 & x=2.1, showing how the slopes approach the derivative value at x=2. |
||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @app.cell | ||||||||||||||||||
| def _(np, plt): | ||||||||||||||||||
| # First, let's start by definiting a simple function. | ||||||||||||||||||
|
||||||||||||||||||
| # First, let's start by definiting a simple function. | |
| # First, let's start by defining a simple function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I'd recommend checking out our plotting tutorial: https://links.marimo.app/tutorial-plotting
Has a good example where various functions are visualized iteratively.
Copilot
AI
May 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the stray '.abs' in the comment, e.g. 'plot the function.'
| # Now, we can plot the function.abs | |
| # Now, we can plot the function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a static plot, consider adding sliders to explore different functions:
# Could use mo.ui.slider to let users change the coefficient
coeff = mo.ui.slider(1, 5, value=1, label="Coefficient")
def f(x):
return coeff.value * x**2This would let users see how changing the coefficient affects the parabola (+ also adds to the interactivity of the notebook).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The learning rate, initial point, & iterations are hardcoded. Consider making these interactive:
learning_rate = mo.ui.slider(0.01, 0.5, value=0.1, step=0.01, label="Learning Rate")
initial = mo.ui.slider(-10, 10, value=8, label="Starting Point")
iterations = mo.ui.slider(5, 50, value=20, label="Iterations")Users could experiment with different values and see how it affects convergence.
Copilot
AI
May 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in preceding line: 'wjich' should be 'which'.
| We can use another example in economics. In economics, there is a term known as 'Price Sensitivity,' wjich essentially measures the rate of change in the quantity demanded or supplied of a good. The price elasticity is given by the formula: | |
| We can use another example in economics. In economics, there is a term known as 'Price Sensitivity,' which essentially measures the rate of change in the quantity demanded or supplied of a good. The price elasticity is given by the formula: |
Copilot
AI
May 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This empty cell appears unused; consider removing redundant stub cells at the end of the notebook.
| @app.cell | |
| def _(): | |
| return | |
| @app.cell | |
| def _(): | |
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this cell to the bottom (better to directly start with the notebook topic - also consistent and followed in most notebooks in the learn repo).