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

Add Linear Regression support for Vectors. #3601

Merged
merged 12 commits into from
Jul 22, 2022

Conversation

jdunkerley
Copy link
Member

@jdunkerley jdunkerley commented Jul 21, 2022

Pull Request Description

Adds least squares regression APIs. Covers the basic 4 trend line types from Excel (doesn't cover Polynomial or Moving Average).
Removes the old Model from the Standard.Table.

Checklist

Please include the following checklist in your PR:

  • The documentation has been updated if necessary.
  • All code conforms to the
    Scala,
    Java,
    and
    Rust
    style guides.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed: Enso GUI was tested when built using BOTH
      ./run ide dist and ./run ide watch.

@jdunkerley jdunkerley force-pushed the wip/jd/linear-regression-functions-182060056 branch from 22c3acf to d10e5cb Compare July 21, 2022 14:25
@jdunkerley
Copy link
Member Author

Spreadsheet used to create test data:
Regression tests.xlsx

@jdunkerley jdunkerley marked this pull request as ready for review July 21, 2022 14:27
Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

Looks all good, just a few minor, mostly stylistic comments.

test/Tests/src/Data/Regression_Spec.enso Show resolved Hide resolved
@jdunkerley jdunkerley force-pushed the wip/jd/linear-regression-functions-182060056 branch from e0b2a55 to 57c7932 Compare July 22, 2022 06:45
@jdunkerley jdunkerley added the CI: Ready to merge This PR is eligible for automatic merge label Jul 22, 2022
@mergify mergify bot merged commit be31145 into develop Jul 22, 2022
@mergify mergify bot deleted the wip/jd/linear-regression-functions-182060056 branch July 22, 2022 08:41
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

I am a bit suprised by two Vectors - one for x and one for y


## Use Least Squares to fit a line to the data.
fit_least_squares : Vector -> Vector -> Model -> Fitted_Model ! Illegal_Argument_Error | Fit_Error
fit_least_squares known_xs known_ys model=Linear_Model =
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering how one can do a linear regression on a single Vector!? But there are two!

Copy link
Member Author

Choose a reason for hiding this comment

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

fit_least_squares (input.map _.first) (input.map _.second) would be one way to achieve this.


Test.specify "predict values on a power trend line" <|
known_xs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
known_ys = [0.26128, 0.28144, 0.26353, 0.30247, 0.28677, 0.23992, 0.30586, 0.32785, 0.26324, 0.3411]
Copy link
Member

Choose a reason for hiding this comment

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

I would rather expect zipped array or array and a function - unless this comes from two columns in a table, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Expect it to come from 2 columns in a table In due course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants