Skip to content

Local Weighted Learning #5615

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

Merged
merged 17 commits into from
Oct 31, 2021
Merged

Conversation

venkateshtantravahi
Copy link
Contributor

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@ghost ghost added awaiting reviews This PR is ready to be reviewed documentation This PR modified documentation files require tests Tests [doctest/unittest/pytest] are required labels Oct 26, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@cclauss
Copy link
Member

cclauss commented Oct 26, 2021

@poyea @dhruvmanila How do you folks feel about our requirements? We currently have a list of 20 and it takes time and space to install all these requirements when we test both locally and in our GitHub Actions. For this reason, I have been trying to limit our requirements to PyPI modules that help build great algorithms.

I struggle when someone wants to add new requirements like this PR that wants to add seaborn.

For this PR, I would recommend that seaborn not be imported at global scope. This is because seaborn is used for data display, not calculations. There could be plotting functions that would import seaborn at local scope but these would not be run in our CI or tests. In CONTRIBUTING.md and in my pull request reviews, I have been trying to emphasize the differences algorithmic functions that do not print() or plot vs. helper functions that display the results calculated from those algorithmic functions. Please let me know if you agree with this approach or not.

@ghost ghost added the tests are failing Do not merge until tests pass label Oct 26, 2021
@venkateshtantravahi
Copy link
Contributor Author

venkateshtantravahi commented Oct 26, 2021 via email

@ghost ghost added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Oct 26, 2021
@poyea
Copy link
Member

poyea commented Oct 27, 2021

@poyea @dhruvmanila How do you folks feel about our requirements? We currently have a list of 20 and it takes time and space to install all these requirements when we test both locally and in our GitHub Actions. For this reason, I have been trying to limit our requirements to PyPI modules that help build great algorithms.

I struggle when someone wants to add new requirements like this PR that wants to add seaborn.

For this PR, I would recommend that seaborn not be imported at global scope. This is because seaborn is used for data display, not calculations. There could be plotting functions that would import seaborn at local scope but these would not be run in our CI or tests. In CONTRIBUTING.md and in my pull request reviews, I have been trying to emphasize the differences algorithmic functions that do not print() or plot vs. helper functions that display the results calculated from those algorithmic functions. Please let me know if you agree with this approach or not.

I agree. Algorithms like this rely heavily on display (like images, graphs, lines, etc.). I suggest we review those existing ones and make it clear later. Should we allow .csv or .txt files?

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR tests are failing Do not merge until tests pass labels Oct 28, 2021
@venkateshtantravahi
Copy link
Contributor Author

venkateshtantravahi commented Oct 28, 2021 via email

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@ghost ghost removed the require tests Tests [doctest/unittest/pytest] are required label Oct 30, 2021
@ghost ghost added the require tests Tests [doctest/unittest/pytest] are required label Oct 30, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@venkateshtantravahi
Copy link
Contributor Author

Hi clauss as requested by you changes has been made and pull requested review and approve

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

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

Awesome work! Thanks for your persistance.

@ghost ghost added tests are failing Do not merge until tests pass and removed awaiting reviews This PR is ready to be reviewed labels Oct 30, 2021
@venkateshtantravahi
Copy link
Contributor Author

venkateshtantravahi commented Oct 30, 2021 via email

@venkateshtantravahi
Copy link
Contributor Author

venkateshtantravahi commented Oct 30, 2021 via email

Comment on lines 15 to 16
>>> weighted_matrix(np.array([1., 1.]),np.mat([[16.99, 10.34], [21.01,23.68],
[24.59,25.69]]), 0.6)
Copy link
Member

Choose a reason for hiding this comment

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

You just need to use the ... to show doctest that we are continuing the previous line.

Suggested change
>>> weighted_matrix(np.array([1., 1.]),np.mat([[16.99, 10.34], [21.01,23.68],
[24.59,25.69]]), 0.6)
>>> weighted_matrix(np.array([1., 1.]),np.mat([[16.99, 10.34], [21.01,23.68],
... [24.59,25.69]]), 0.6)

Comment on lines 38 to 39
>>> local_weight(np.array([1., 1.]),np.mat([[16.99, 10.34], [21.01,23.68],
[24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>>> local_weight(np.array([1., 1.]),np.mat([[16.99, 10.34], [21.01,23.68],
[24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)
>>> local_weight(np.array([1., 1.]),np.mat([[16.99, 10.34], [21.01,23.68],
... [24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)

Comment on lines 56 to 57
>>> local_weight_regression(np.mat([[16.99, 10.34], [21.01,23.68],
[24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>>> local_weight_regression(np.mat([[16.99, 10.34], [21.01,23.68],
[24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)
>>> local_weight_regression(np.mat([[16.99, 10.34], [21.01,23.68],
... [24.59,25.69]]),np.mat([[1.01, 1.66, 3.5]]), 0.6)

def load_data(dataset_name: str, cola_name: str, colb_name: str) -> np.mat:
"""
Function used for loading data from the seaborn splitting into x and y points
"""
Copy link
Member

Choose a reason for hiding this comment

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

Let's silence @algorithms-keeper

Suggested change
"""
>>> pass # This function has no doctest.
"""

) -> plt.plot:
"""
This function used to plot predictions and display the graph
"""
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"""
>>> pass # This function has no doctest.
"""

@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed require tests Tests [doctest/unittest/pytest] are required labels Oct 31, 2021
@ghost ghost removed the tests are failing Do not merge until tests pass label Oct 31, 2021
@cclauss cclauss merged commit 508589e into TheAlgorithms:master Oct 31, 2021
@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This PR modified documentation files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants