[MRG+1] - DeprecationWarning for n_components parameter for linkage_tree#9309
[MRG+1] - DeprecationWarning for n_components parameter for linkage_tree#9309TomDLT merged 20 commits intoscikit-learn:masterfrom
Conversation
Update from base Jul-04-2017
Change 10JUL2017
|
Needs a test, thanks! |
|
@jnothman Why can't i use this as a test? |
| assert_raises(ValueError, linkage_tree, X, connectivity=np.ones((4, 4))) | ||
|
|
||
| # Test for warning of deprecation of n_components in linkage_tree | ||
| children, n_nodes, n_leaves, parent = assert_warns(UserWarning, linkage_tree, n_components=10) |
There was a problem hiding this comment.
Put it in a separate test function, please. You should probably assert that output is identical to without the n_components.
| with ignore_warnings(): | ||
| # Test for warning of deprecation of n_components in linkage_tree | ||
| children, n_nodes, n_leaves, parent = assert_warns(DeprecationWarning, linkage_tree,this_X.T, n_components=10) | ||
| children1, n_nodes1, n_leaves1, parent1 = linkage_tree(this_X.T, n_components=10) |
There was a problem hiding this comment.
What's the point in this line?
There was a problem hiding this comment.
Without it, you shouldn't need the ignore_warnings
There was a problem hiding this comment.
To compare the output with and without n_components. To make sure it's same.. is it not required ?
There was a problem hiding this comment.
The previous line will calculate the same. As long as we believe assert_warns works, and we do
There was a problem hiding this comment.
i have removed the lines and i have made it check only for the warning.
| def test_deprecation_of_n_components_in_linkage_tree(): | ||
| rng = np.random.RandomState(0) | ||
| X = rng.randn(50, 100) | ||
| for tree_builder in _TREE_BUILDERS.values(): |
There was a problem hiding this comment.
This variable is unused in the loop
| rng = np.random.RandomState(0) | ||
| X = rng.randn(50, 100) | ||
| for tree_builder in _TREE_BUILDERS.values(): | ||
| for this_X in (X, X[0]): |
| assert_raises(ValueError, linkage_tree, X, linkage='foo') | ||
| assert_raises(ValueError, linkage_tree, X, connectivity=np.ones((4, 4))) | ||
|
|
||
|
|
|
@jnothman All checks have passed. Please take a look. TIA! |
| X = rng.randn(50, 100) | ||
| # Test for warning of deprecation of n_components in linkage_tree | ||
| children, n_nodes, n_leaves, parent = assert_warns( | ||
| DeprecationWarning, |
There was a problem hiding this comment.
This indentation is a bit unconventional
| linkage_tree, | ||
| X.T, | ||
| n_components=10) | ||
|
|
There was a problem hiding this comment.
I had suggested comparing children, n_nodes, n_leaves, parent to linkage_tree(X.T)
sklearn/cluster/hierarchical.py
Outdated
| -------- | ||
| ward_tree : hierarchical clustering with ward linkage | ||
| """ | ||
| if n_components is not None: |
There was a problem hiding this comment.
To be sure, we should really be testing against a different value, like if n_components != 'deprecated' and setting the default to 'deprecated' so that a user explicitly passing None will receive the warning.
|
Thanks @sharanry |
…ree (scikit-learn#9309) * Depreciation warning for n_components in sklearn/cluster/hierarchical.py * typo fix * Whitespace fix * Update hierarchical.py * Added test * Added test-v2 * Test for deprecation * Test function name change * Updated test * Update test_hierarchical.py * fixing flake8 errors * removed blank line * modifying test * Change condition for deprecation warning * Change indentation and compare function output * fix flake8 errors * Update test_hierarchical.py
…ree (scikit-learn#9309) * Depreciation warning for n_components in sklearn/cluster/hierarchical.py * typo fix * Whitespace fix * Update hierarchical.py * Added test * Added test-v2 * Test for deprecation * Test function name change * Updated test * Update test_hierarchical.py * fixing flake8 errors * removed blank line * modifying test * Change condition for deprecation warning * Change indentation and compare function output * fix flake8 errors * Update test_hierarchical.py
…ree (scikit-learn#9309) * Depreciation warning for n_components in sklearn/cluster/hierarchical.py * typo fix * Whitespace fix * Update hierarchical.py * Added test * Added test-v2 * Test for deprecation * Test function name change * Updated test * Update test_hierarchical.py * fixing flake8 errors * removed blank line * modifying test * Change condition for deprecation warning * Change indentation and compare function output * fix flake8 errors * Update test_hierarchical.py
…ree (scikit-learn#9309) * Depreciation warning for n_components in sklearn/cluster/hierarchical.py * typo fix * Whitespace fix * Update hierarchical.py * Added test * Added test-v2 * Test for deprecation * Test function name change * Updated test * Update test_hierarchical.py * fixing flake8 errors * removed blank line * modifying test * Change condition for deprecation warning * Change indentation and compare function output * fix flake8 errors * Update test_hierarchical.py
…ree (scikit-learn#9309) * Depreciation warning for n_components in sklearn/cluster/hierarchical.py * typo fix * Whitespace fix * Update hierarchical.py * Added test * Added test-v2 * Test for deprecation * Test function name change * Updated test * Update test_hierarchical.py * fixing flake8 errors * removed blank line * modifying test * Change condition for deprecation warning * Change indentation and compare function output * fix flake8 errors * Update test_hierarchical.py
…ree (scikit-learn#9309) * Depreciation warning for n_components in sklearn/cluster/hierarchical.py * typo fix * Whitespace fix * Update hierarchical.py * Added test * Added test-v2 * Test for deprecation * Test function name change * Updated test * Update test_hierarchical.py * fixing flake8 errors * removed blank line * modifying test * Change condition for deprecation warning * Change indentation and compare function output * fix flake8 errors * Update test_hierarchical.py
…ree (scikit-learn#9309) * Depreciation warning for n_components in sklearn/cluster/hierarchical.py * typo fix * Whitespace fix * Update hierarchical.py * Added test * Added test-v2 * Test for deprecation * Test function name change * Updated test * Update test_hierarchical.py * fixing flake8 errors * removed blank line * modifying test * Change condition for deprecation warning * Change indentation and compare function output * fix flake8 errors * Update test_hierarchical.py
Reference Issue
Fixes #9307
What does this implement/fix? Explain your changes.
Adds DeprecationWarning to n_components parameter which is no longer being used in linkage_tree function.
Any other comments?
No.