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

Adding PCA correlation circle graph #544

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ install:
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- conda create -q -n test-environment python=%PYTHON_VERSION% numpy scipy scikit-learn pandas nose
- conda create -q -n test-environment python=%PYTHON_VERSION% numpy scipy scikit-learn pandas pytest
- activate test-environment
- pip install nose-exclude
- pip install dlib
- pip install imageio
- pip install scikit-image

test_script:
- nosetests -s -v --exclude-dir=mlxtend/plotting
- PYTHONPATH='.' pytest -sv --ignore=mlxtend/plotting

notifications:

Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Fixes #366
- [ ] Added a note about the modification or contribution to the `./docs/sources/CHANGELOG.md` file (if applicable)
- [ ] Added appropriate unit test functions in the `./mlxtend/*/tests` directories (if applicable)
- [ ] Modify documentation in the corresponding Jupyter Notebook under `mlxtend/docs/sources/` (if applicable)
- [ ] Ran `nosetests ./mlxtend -sv` and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g., `nosetests ./mlxtend/classifier/tests/test_stacking_cv_classifier.py -sv`)
- [ ] Ran `PYTHONPATH='.' pytest ./mlxtend -sv` and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g., `PYTHONPATH='.' pytest ./mlxtend/classifier/tests/test_stacking_cv_classifier.py -sv`)
- [ ] Checked for style issues by running `flake8 ./mlxtend`


Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Test Suites
.pytest_cache/

# Documentation builds
docs/site/
docs/mlxtend.pdf
Expand Down
3 changes: 1 addition & 2 deletions ci/.travis_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fi

conda install matplotlib
conda install jupyter
conda install pytest

if [ "${IMAGE}" = "true" ]; then
pip install dlib
Expand All @@ -50,8 +51,6 @@ if [ "${COVERAGE}" = "true" ]; then
conda install coveralls
fi

pip install nose-exclude

python --version
python -c "import pandas; print('pandas %s' % pandas.__version__)"
python -c "import numpy; print('numpy %s' % numpy.__version__)"
Expand Down
10 changes: 5 additions & 5 deletions ci/.travis_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then
if [[ "$COVERAGE" == "true" ]]; then

if [[ "$IMAGE" == "true" ]]; then
nosetests -s -v --with-coverage
PYTHONPATH='.' pytest -sv --with-coverage
else
nosetests -s -v --with-coverage --exclude-dir=mlxtend/image
PYTHONPATH='.' pytest -sv --with-coverage --ignore=mlxtend/image
fi

else
if [[ "$IMAGE" == "true" ]]; then
nosetests -s -v
PYTHONPATH='.' pytest -sv
else
nosetests -s -v --exclude-dir=mlxtend/image
PYTHONPATH='.' pytest -sv --ignore=mlxtend/image
fi
fi

else
nosetests -s -v --exclude-dir=mlxtend/plotting
PYTHONPATH='.' pytest -sv --ignore=mlxtend/plotting
fi


Expand Down
14 changes: 4 additions & 10 deletions docs/_site/sources/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ and checking off items as you go.
3. [ ] Create and check out a new topic branch (please don't make modifications in the master branch)
4. [ ] Implement the new feature or apply the bug-fix
5. [ ] Add appropriate unit test functions in `mlxtend/*/tests`
6. [ ] Run `nosetests ./mlxtend -sv` and make sure that all unit tests pass
7. [ ] Check/improve the test coverage by running `nosetests ./mlxtend --with-coverage`
8. [ ] Check for style issues by running `flake8 ./mlxtend` (you may want to run `nosetests` again after you made modifications to the code)
6. [ ] Run `PYTHONPATH='.' pytest ./mlxtend -sv` and make sure that all unit tests pass
7. [ ] Check/improve the test coverage by running `PYTHONPATH='.' pytest ./mlxtend --with-coverage`
8. [ ] Check for style issues by running `flake8 ./mlxtend` (you may want to run `pytest` again after you made modifications to the code)
8. [ ] Add a note about the modification/contribution to the `./docs/sources/changelog.md` file
9. [ ] Modify documentation in the appropriate location under `mlxtend/docs/sources/`
10. [ ] Push the topic branch to the server and create a pull request
Expand Down Expand Up @@ -164,13 +164,7 @@ Now it's time to modify existing code or to contribute new code to the project.
Add the respective unit tests and check if they pass:

```bash
$ nosetests -sv
```

Use the `--with-coverage` flag to ensure that all code is being covered in the unit tests:

```bash
$ nosetests --with-coverage
$ PYTHONPATH='.' pytest -sv
```

#### 5. Documenting changes
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The CHANGELOG for the current development version is available at
- Added an enhancement to the existing `iris_data()` such that both the UCI Repository version of the Iris dataset as well as the corrected, original
version of the dataset can be loaded, which has a slight difference in two data points (consistent with Fisher's paper; this is also the same as in R). (via [#539](https://github.com/rasbt/mlxtend/pull/532) via [janismdhanbad](https://github.com/janismdhanbad))
- Add optional `groups` parameter to `SequentialFeatureSelector` and `ExhaustiveFeatureSelector` `fit()` methods for forwarding to sklearn CV ([#537](https://github.com/rasbt/mlxtend/pull/537) via [arc12](https://github.com/qiaguhttps://github.com/arc12))

- Adds a new `plot_pca_correlation_graph` function to the `mlxtend.plotting` submodule for plotting a PCA correlation graph. ([#544](https://github.com/rasbt/mlxtend/pull/544) via [Gabriel-Azevedo-Ferreira](https://github.com/qiaguhttps://github.com/Gabriel-Azevedo-Ferreira))

##### Changes

Expand Down
203 changes: 203 additions & 0 deletions docs/sources/user_guide/plotting/pca_correlated_circle.ipynb

Large diffs are not rendered by default.

127 changes: 0 additions & 127 deletions mlxtend/_base/oldtests/test_base_estimator.py

This file was deleted.

52 changes: 25 additions & 27 deletions mlxtend/_base/tests/test_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from mlxtend._base import _BaseModel
from mlxtend._base import _Classifier
import numpy as np
from mlxtend.utils import assert_raises
import pytest


class BlankClassifier(_BaseModel, _Classifier):
Expand Down Expand Up @@ -44,39 +44,40 @@ def test_check_labels_ok_2():
def test_check_labels_not_ok_1():
y = np.array([1, 3, 2])
cl = BlankClassifier(print_progress=0, random_seed=1)
assert_raises(AttributeError,
'Labels not in {(1, 2), (0, 1)}.\nFound (1, 2, 3)',
cl._check_target_array,
y,
{(0, 1), (1, 2)})
with pytest.raises(AttributeError) as excinfo:

cl._check_target_array(y, {(0, 1), (1, 2)})
assert excinfo.value.message == ('Labels not in {(1, 2), (0, 1)}'
'.\nFound (1, 2, 3)')

def test_check_labels_interger_notok():

def test_check_labels_integer_notok():
y = np.array([1., 2.], dtype=np.float64)
cl = BlankClassifier(print_progress=0, random_seed=1)
assert_raises(AttributeError,
'y must be an integer array.\nFound float64',
cl._check_target_array,
y)
with pytest.raises(AttributeError) as excinfo:
cl._check_target_array(y)
assert excinfo.value.message == ('y must be an integer'
' array.\nFound float64')


def test_check_labels_positive_notok():
y = np.array([1, 1, -1])
cl = BlankClassifier(print_progress=0, random_seed=1)
assert_raises(AttributeError,
'y array must not contain negative labels.\nFound [-1 1]',
cl._check_target_array,
y)
with pytest.raises(AttributeError) as excinfo:
cl._check_target_array(y)
assert excinfo.value.message == ('y array must not '
'contain negative '
'labels.\nFound [-1 1]')


def test_predict_fail():
X = np.array([[1], [2], [3]])
est = BlankClassifier(print_progress=0, random_seed=1)
est._is_fitted = False
assert_raises(AttributeError,
'Model is not fitted, yet.',
est.predict,
X)
with pytest.raises(AttributeError) as excinfo:
est.predict(X)
assert excinfo.value.message == ('Model is not '
'fitted, yet.')


def test_predict_pass():
Expand All @@ -86,14 +87,11 @@ def test_predict_pass():
est.fit(X, y)
est.predict(X)


def test_fit_1():
X = np.array([[1], [2], [3]])
est = BlankClassifier(print_progress=0, random_seed=1)
assert_raises(TypeError,
"fit() missing 1 required positional argument: 'y'",
est.fit,
X)
with pytest.raises(TypeError) as excinfo:
est.fit(X)
assert excinfo.value.message == ("fit() missing 1 "
"required positional "
"argument: 'y'")


def test_fit_2():
Expand Down
Loading