Skip to content
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

Scipy curve fit #5919

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Scipy curve fit #5919

wants to merge 22 commits into from

Conversation

ca999
Copy link

@ca999 ca999 commented Jan 5, 2025

Description

  1. Add a new entry in scipy.optimize
  2. Create a new directory: content/scipy/concepts/scipy-optimize/terms/curve-fit
  3. Added curve-fit documentation under curve-fit.md

Issue Solved

closes #5848

Type of Change

  • Adding a new entry

Checklist

  • All writings are my own. - the code example was taken from https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html with minor alterations. Chatgpt was used for better coherence for certain explanations.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@CLAassistant
Copy link

CLAassistant commented Jan 5, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
10 out of 11 committers have signed the CLA.

✅ mamtawardhani
✅ ca999
✅ tommaso-berti
✅ Nil-Morah
✅ vlrnsnk
✅ Maverick073
✅ ebikatsudon
✅ hitomipupil
✅ jrood
✅ SaviDahegaonkar
❌ codecademy-gh-api
You have signed the CLA already but the status is still pending? Let us recheck it.

@ca999 ca999 marked this pull request as ready for review January 6, 2025 01:58
@mamtawardhani mamtawardhani self-assigned this Jan 6, 2025
@mamtawardhani
Copy link
Collaborator

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.1 out of 2 committers have signed the CLA.✅ ca999❌ Nayana

Nayana seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Hey @ca999, looks like you have made a commit from a local ID as well, could you please use that to sign the CLA?

@mamtawardhani mamtawardhani added new entry New entry or entries scipy Python scipy enteries labels Jan 6, 2025
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing to Codecademy Docs @ca999😄

The entry looks good for a second round of review! 🚀

@ca999
Copy link
Author

ca999 commented Jan 8, 2025

Hi @mamtawardhani I am unable to get the CLA for the local account. Can you please guide me on how I can get the CLA agreement to the account

ca999 and others added 18 commits January 8, 2025 22:53
* Github check to verify that there are not missing md files

* linebreaks
* volatile-variables file created and filled, examples pending

* Created volatile variable term for cpp variables

* File has been added.

* File has been modified.

* minor changes

* Fixes

---------
* feat: [Concept Entry] Git Checkout (Codecademy#5748)

* Update content/git/concepts/checkout/checkout.md

Co-authored-by: Pragati Verma <[email protected]>

* Update content/git/concepts/checkout/checkout.md

Co-authored-by: Pragati Verma <[email protected]>

* Update content/git/concepts/checkout/checkout.md

Co-authored-by: Pragati Verma <[email protected]>

* Update content/git/concepts/checkout/checkout.md

Co-authored-by: Pragati Verma <[email protected]>

* Update content/git/concepts/checkout/checkout.md

Co-authored-by: Pragati Verma <[email protected]>

* Update content/git/concepts/checkout/checkout.md

Co-authored-by: Pragati Verma <[email protected]>

* Update content/git/concepts/checkout/checkout.md

Co-authored-by: Pragati Verma <[email protected]>

* Apply suggestions from code review

Co-authored-by: Pragati Verma <[email protected]>

* feat: [Concept Entry] Git Checkout (Codecademy#5748): added optional flags

* Update options syntax

* Update checkout.md

* fix: [Bug/Error] Java Map: .replaceAll() (Codecademy#5748)

* revert wrong commit on feat branch

* Minor fixes

* Formatting fixes

---------
Remove trailing commas on pseudocode JSON
* New file has been added.

* Update user-input.md

* Update user-input.md

* File has been modified.

* Update anova-lm.md

major fixes in meta data and some content

* Update anova-lm.md

---------
…my#5827)

* Added docs for javascript spread operator

* Update spread-operator.md

fixes done

* Update spread-operator.md

* Update content/javascript/concepts/spread-operator/spread-operator.md

* Update content/javascript/concepts/spread-operator/spread-operator.md

* Update content/javascript/concepts/spread-operator/spread-operator.md

---------
fixed formatting
* merged conflicting focus group entries into one

* updated to fix formatting errors

* Revert yarn.lock changes

* Revert yarn.lock changes

* Revert yarn.lock changes

* Revert yarn.lock changes

* Update focus-group.md

* Update focus-group.md

* Update focus-group.md

* Update focus-group.md

---------
* New file has been added.

* Update user-input.md

* Update user-input.md

* File has been modified.

* Update content/rust/concepts/ownership/ownwership.md

* Update content/rust/concepts/ownership/ownwership.md

* Update content/rust/concepts/ownership/ownwership.md

* Rename ownwership.md to ownership.md

fixed minor issues and corrected file name spelling

* Update content/rust/concepts/ownership/ownership.md

* Update ownership.md

* Update ownership.md

---------
* Initial commit

* removed extra information and modified grammar mistakes

* Update nullish-coalescing.md

minor fixes

* Minor changes

---------
@ca999
Copy link
Author

ca999 commented Jan 8, 2025

Hi @mamtawardhani So I update the commit email using the ones related to this account, I think it did the job, I no longer see the local account, but I think all the other commiter also have been added in to the CLA

@avdhoottt avdhoottt added status: under review Issue or PR is currently being reviewed and removed status: ready for next review labels Jan 9, 2025
@avdhoottt avdhoottt self-assigned this Jan 9, 2025
Copy link
Collaborator

@avdhoottt avdhoottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ca999, I've suggested some changes, please make them as soon as possible. Thank you!!

Comment on lines +24 to +45
- `f`: This is the function to fit to the data.
- `xdata`: An array-like input representing the independent variable values (e.g., time, x-coordinates, etc.).
- `ydata`: An array-like input representing the dependent variable values (e.g., measured data corresponding to `xdata`).
- `p0`: Inital guess of the parameters.
- `sigma`: Defines the uncertainty in `ydata`.
- `absolute_sigma`: If `True`, `sigma` is interpreted absolutely, and the parameter covariance pcov reflects absolute values. If `False` which is the default, `sigma` is scaled to normalize residual variance. Here, pcov(absolute_sigma=False) = pcov(absolute_sigma=True) \* chisq(popt)/(M-N).
- `check_finite`: Ensures input arrays do not contain `NaN` or `inf`. If `True`, a `ValueError` is raised when such values are found. Defaults to `True` unless `nan_policy` is explicitly specified.
- `bounds`: Specifies parameter bounds. Defaults to no bounds. Options include:
- An instance of the `Bounds` class.
- A 2-tuple of array-like objects or scalars: Scalars apply bounds uniformly and `np.inf` can disable bounds partially.
- `method` - Optimization method. Choices are:
- `'lm'` (default for unconstrained problems): Levenberg-Marquardt.
- `'trf'` (default if bounds are set): Trust Region Reflective.
- `'dogbox'`: Dogleg.
`'lm'` cannot handle cases where observations < variables. Use `'trf'` or `'dogbox'` instead.
- `jac`: Jacobian matrix computation for `jac(x, ...)`. Defaults to numerical estimation if None. Supports finite difference schemes for `'trf'` and `'dogbox'` methods.
- `full_output`: If `True`, returns additional information such as infodict, mesg, ier.
- `nan_policy`: Decides behavior when `NaN` values exist in input data:
- None (default): No special handling, behavior depends on implementation.
- `'raise'`: Throws an error.
- `'omit'`: Ignores NaN values during computation.
- `**kwargs`: Additional keyword arguments passed to leastsq (if method = 'lm') or least_squares otherwise.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `f`: This is the function to fit to the data.
- `xdata`: An array-like input representing the independent variable values (e.g., time, x-coordinates, etc.).
- `ydata`: An array-like input representing the dependent variable values (e.g., measured data corresponding to `xdata`).
- `p0`: Inital guess of the parameters.
- `sigma`: Defines the uncertainty in `ydata`.
- `absolute_sigma`: If `True`, `sigma` is interpreted absolutely, and the parameter covariance pcov reflects absolute values. If `False` which is the default, `sigma` is scaled to normalize residual variance. Here, pcov(absolute_sigma=False) = pcov(absolute_sigma=True) \* chisq(popt)/(M-N).
- `check_finite`: Ensures input arrays do not contain `NaN` or `inf`. If `True`, a `ValueError` is raised when such values are found. Defaults to `True` unless `nan_policy` is explicitly specified.
- `bounds`: Specifies parameter bounds. Defaults to no bounds. Options include:
- An instance of the `Bounds` class.
- A 2-tuple of array-like objects or scalars: Scalars apply bounds uniformly and `np.inf` can disable bounds partially.
- `method` - Optimization method. Choices are:
- `'lm'` (default for unconstrained problems): Levenberg-Marquardt.
- `'trf'` (default if bounds are set): Trust Region Reflective.
- `'dogbox'`: Dogleg.
`'lm'` cannot handle cases where observations < variables. Use `'trf'` or `'dogbox'` instead.
- `jac`: Jacobian matrix computation for `jac(x, ...)`. Defaults to numerical estimation if None. Supports finite difference schemes for `'trf'` and `'dogbox'` methods.
- `full_output`: If `True`, returns additional information such as infodict, mesg, ier.
- `nan_policy`: Decides behavior when `NaN` values exist in input data:
- None (default): No special handling, behavior depends on implementation.
- `'raise'`: Throws an error.
- `'omit'`: Ignores NaN values during computation.
- `**kwargs`: Additional keyword arguments passed to leastsq (if method = 'lm') or least_squares otherwise.
- `f`: This is the function to fit to the data.
- `xdata`: An array-like input representing the independent variable values (e.g., time, x-coordinates, etc.).
- `ydata`: An array-like input representing the dependent variable values (e.g., measured data corresponding to `xdata`).
- `p0`: Initial guess of the parameters.
- `sigma`: Defines the uncertainty in `ydata`.
- `absolute_sigma`: If `True`, `sigma` is interpreted absolutely, and the parameter covariance pcov reflects absolute values. If `False` which is the default, `sigma` is scaled to normalize residual variance. Here, pcov(absolute_sigma=False) = pcov(absolute_sigma=True) \* chisq(popt)/(M-N).
- `check_finite`: Ensures input arrays do not contain `NaN` or `inf`. If `True`, a `ValueError` is raised when such values are found. Defaults to `True` unless `nan_policy` is explicitly specified.
- `bounds`: Specifies parameter bounds. Defaults to no bounds. Options include:
- An instance of the `Bounds` class.
- A 2-tuple of array-like objects or scalars: Scalars apply bounds uniformly, and `np.inf` can disable bounds partially.
- `method` - Optimization method. Choices are:
- `'lm'` (default for unconstrained problems): Levenberg-Marquardt.
- `'trf'` (default if bounds are set): Trust Region Reflective.
- `'dogbox'`: Dogleg.
`'lm'` cannot handle cases where observations < variables. Use `'trf'` or `'dogbox'` instead.
- `jac`: Jacobian matrix computation for `jac(x, ...)`. Defaults to numerical estimation if None. Supports finite difference schemes for `'trf'` and `'dogbox'` methods.
- `full_output`: If `True`, returns additional information such as infodict, mesg, ier.
- `nan_policy`: Decides behavior when `NaN` values exist in input data:
- None (default): No special handling; behavior depends on implementation.
- `'raise'`: Throws an error.
- `'omit'`: Ignores NaN values during computation.
- `**kwargs`: Additional keyword arguments passed to `leastsq` (if method = 'lm') or least_squares otherwise.

print(popt)
```

The above will give the following output:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output differs every time we run the code. We should add a note here saying that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @avdhoottt I have added in a note saying that the output will differ for each run

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @avdhoottt Is there anything else that I need to do to get this PR merged ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Term Entry] Python:SciPy scipy.optimize: curve_fit()