-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
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
Dimensionality reduction #8590
Dimensionality reduction #8590
Conversation
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.
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.
for more information, see https://pre-commit.ci
@Diegomangasco , run |
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.
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.
return covariance_sum / features.shape[1] | ||
|
||
|
||
def covariance_between_classes( |
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.
As there is no test file in this pull request nor any test function or class in the file machine_learning/dimensionality_reduction.py
, please provide doctest for the function covariance_between_classes
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.
"""
features = np.array([[1, 2, 3], [4, 5, 6]])
labels = np.array([0, 1, 0])
covariance_between_classes(features, labels, 2)
output : array([[-1.5, -1.5],[-1.5, -1.5]])
"""
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.
Pytest discovery is not finding/running these
See the GitHub Actions output.
machine_learning/data_transformations.py .. [ 54%]
machine_learning/decision_tree.py . [ 54%]
machine_learning/k_means_clust.py . [ 54%]
machine_learning/k_nearest_neighbours.py .. [ 55%]
machine_learning/linear_discriminant_analysis.py ....... [ 55%]
machine_learning/multilayer_perceptron_classifier.py . [ 55%]
machine_learning/scoring_functions.py ..... [ 56%]
machine_learning/self_organizing_map.py .. [ 56%]
machine_learning/similarity_search.py ... [ 56%]
machine_learning/support_vector_machines.py ... [ 56%]
machine_learning/word_frequency_functions.py .... [ 57%]
machine_learning/xgboost_classifier.py .. [ 57%]
machine_learning/xgboost_regressor.py ... [ 57%]
machine_learning/forecasting/run.py ..... [ 57%]
machine_learning/local_weighted_learning/local_weighted_learning.py .... [ 58%]
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.
why it is not running these???
for more information, see https://pre-commit.ci
@Diegomangasco , I also tried but getting -ve sign and some different outputs everytime. AssertionError: Expected [[ 6.92820323 8.66025404 10.39230485] |
Yes because the projection could be done in whatever direction (plus or minus sign), the important things are the values. |
I think that the round errors may due to machine rounding. |
yes but values that we are getting are also different. |
Can you provide me the input you gave? |
def test_pca():
features = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
dimensions = 2
expected_output = np.array([[6.92820323, 8.66025404, 10.39230485], [3., 3., 3.]])
output = principal_component_analysis(features, dimensions)
assert np.allclose(expected_output, output), f"Expected {expected_output}, but got {output}"
test_pca() error AssertionError: Expected [[ 6.92820323 8.66025404 10.39230485] |
@rohan472000 @cclauss It seems to be deterministic, maybe there are some problems with doctests (?) |
@rohan472000 @cclauss |
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'm not sure about using different function to test the various cases comes under a good practice or not for this repo, other than that everything looks fine to me.
return covariance_sum / features.shape[1] | ||
|
||
|
||
def covariance_between_classes( |
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.
"""
features = np.array([[1, 2, 3], [4, 5, 6]])
labels = np.array([0, 1, 0])
covariance_between_classes(features, labels, 2)
output : array([[-1.5, -1.5],[-1.5, -1.5]])
"""
return covariance_sum / features.shape[1] | ||
|
||
|
||
def covariance_between_classes( |
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.
why it is not running these???
**_> projected_data = linear_discriminant_analysis(features, labels, classes, 3)
|
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.
projected_data = linear_discriminant_analysis(features, labels, classes, 3)
except AssertionError:
pass
else:
raise AssertionError("Did not raise AssertionError for dimensions > features")
def test_principal_component_analysis() -> None:
features = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
dimensions = 2
expected_output = np.array([[6.92820323, 8.66025404, 10.39230485], [3.0, 3.0, 3.0]])
output = principal_component_analysis(features, labels)
assert np.allclose(
expected_output, output
), f"Expected {expected_output}." {output}"
if name ==dismissed "main":
for more information, see https://pre-commit.ci
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.