Skip to content

Commit

Permalink
Merge pull request #312 from yzhao062/development
Browse files Browse the repository at this point in the history
V0.8.9
  • Loading branch information
yzhao062 authored Jun 12, 2021
2 parents d0e550c + 2ede4ab commit d9186d2
Show file tree
Hide file tree
Showing 15 changed files with 964 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
command: |
. venv/bin/activate
pytest
no_output_timeout: 30m
no_output_timeout: 60m

- store_artifacts:
path: test-reports
Expand Down
5 changes: 4 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ v<0.8.7>, <01/16/2021> -- Add ROD.
v<0.8.7>, <02/18/2021> -- Dependency optimization.
v<0.8.8>, <04/08/2021> -- COPOD optimization.
v<0.8.8>, <04/08/2021> -- Add parallelization for COPOD.
v<0.8.8>, <04/26/2021> -- fix XGBOD issue with xgboost 1.4.
v<0.8.8>, <04/26/2021> -- Fix XGBOD issue with xgboost 1.4.
v<0.8.9>, <05/17/2021> -- Turn on test for Python 3.5-3.8.
v<0.8.9>, <06/10/2021> -- Add PyTorch AutoEncoder
v<0.8.9>, <06/11/2021> -- Fix LMDD parameter (#307)



Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ be found at `Moving to require Python 3 <https://python3statement.org/>`_.

**Warning 1**\ :
PyOD has multiple neural network based models, e.g., AutoEncoders, which are
implemented in Keras. However, PyOD does **NOT** install **keras** and/or
**tensorflow** for you. This reduces the risk of interfering with your local copies.
implemented in both PyTorch and Tensorflow. However, PyOD does **NOT** install DL libraries for you.
This reduces the risk of interfering with your local copies.
If you want to use neural-net based models, please make sure Keras and a backend library, e.g., TensorFlow, are installed.
Instructions are provided: `neural-net FAQ <https://github.com/yzhao062/pyod/wiki/Setting-up-Keras-and-Tensorflow-for-Neural-net-Based-models>`_.
Similarly, models depending on **xgboost**, e.g., XGBOD, would **NOT** enforce xgboost installation by default.
Expand Down
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'sphinx.ext.viewcode',
'sphinxcontrib.bibtex',
'sphinx.ext.napoleon',
'sphinx_rtd_theme',
]

bibtex_bibfiles = ['zreferences.bib']
Expand Down Expand Up @@ -87,7 +88,9 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'
# html_theme = 'default'

html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
4 changes: 2 additions & 2 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Alternatively, you could clone and run setup.py file:
.. warning::

PyOD has multiple neural network based models, e.g., AutoEncoders, which are
implemented in Keras. However, PyOD does **NOT** install **keras** and/or
**tensorflow** for you. This reduces the risk of interfering with your local copies.
implemented in both PyTorch and Tensorflow. However, PyOD does **NOT** install DL libraries for you.
This reduces the risk of interfering with your local copies.
If you want to use neural-net based models, please make sure Keras and a backend library, e.g., TensorFlow, are installed.
Instructions are provided: `neural-net FAQ <https://github.com/yzhao062/pyod/wiki/Setting-up-Keras-and-Tensorflow-for-Neural-net-Based-models>`_.
Similarly, models depending on **xgboost**, e.g., XGBOD, would **NOT** enforce xgboost installation by default.
Expand Down
13 changes: 11 additions & 2 deletions docs/pyod.models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ pyod.models.auto\_encoder module
:show-inheritance:
:inherited-members:

pyod.models.auto\_encoder\_torch module
---------------------------------------

.. automodule:: pyod.models.auto_encoder_torch
:members:
:undoc-members:
:show-inheritance:
:inherited-members:

pyod.models.cblof module
------------------------

Expand Down Expand Up @@ -49,7 +58,7 @@ pyod.models.combination module
:inherited-members:

pyod.models.copod module
----------------------
------------------------

.. automodule:: pyod.models.copod
:members:
Expand Down Expand Up @@ -96,7 +105,7 @@ pyod.models.knn module
:inherited-members:

pyod.models.lmdd module
----------------------
-----------------------

.. automodule:: pyod.models.lmdd
:members:
Expand Down
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ pytest
scipy>=0.19.1
scikit_learn>=0.19.1
six
sphinx-rtd-theme
sphinxcontrib-bibtex
statsmodels
suod
tensorflow
torch
xgboost
docutils==0.16 # need to lift this later see github for issue
55 changes: 55 additions & 0 deletions examples/auto_encoder_torch_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
"""Example of using Autoencoder for outlier detection (pytorch)
detection
"""
# Author: Yue Zhao <[email protected]>
# License: BSD 2 clause

from __future__ import division
from __future__ import print_function

import os
import sys

# temporary solution for relative imports in case pyod is not installed
# if pyod is installed, no need to use the following line
sys.path.append(
os.path.abspath(os.path.join(os.path.dirname("__file__"), '..')))

from pyod.models.auto_encoder_torch import AutoEncoder
from pyod.utils.data import generate_data
from pyod.utils.data import evaluate_print


if __name__ == "__main__":
contamination = 0.1 # percentage of outliers
n_train = 20000 # number of training points
n_test = 2000 # number of testing points
n_features = 300 # number of features

# Generate sample data
X_train, y_train, X_test, y_test = \
generate_data(n_train=n_train,
n_test=n_test,
n_features=n_features,
contamination=contamination,
random_state=42)

# train AutoEncoder detector
clf_name = 'AutoEncoder'
clf = AutoEncoder(epochs=10)
clf.fit(X_train)

# get the prediction labels and outlier scores of the training data
y_train_pred = clf.labels_ # binary labels (0: inliers, 1: outliers)
y_train_scores = clf.decision_scores_ # raw outlier scores

# get the prediction on the test data
y_test_pred = clf.predict(X_test) # outlier labels (0 or 1)
y_test_scores = clf.decision_function(X_test) # outlier scores

# evaluate and print the results
print("\nOn Training Data:")
evaluate_print(clf_name, y_train, y_train_scores)
print("\nOn Test Data:")
evaluate_print(clf_name, y_test, y_test_scores)
Loading

0 comments on commit d9186d2

Please sign in to comment.