Skip to content

Commit

Permalink
retire deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhao062 committed Dec 21, 2019
1 parent 1df9354 commit c7b5a7d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
28 changes: 27 additions & 1 deletion examples/temp_do_not_use/deprecated_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from sklearn.utils import check_X_y
from pyod.utils.data import get_color_codes


def visualize(clf_name, X_train, y_train, X_test, y_test, y_train_pred,
Expand Down Expand Up @@ -85,3 +84,30 @@ def visualize(clf_name, X_train, y_train, X_test, y_test, y_train_pred,
if show_figure:
plt.show()
return


def get_color_codes(y):
"""Internal function to generate color codes for inliers and outliers.
Inliers (0): blue; Outlier (1): red.
Parameters
----------
y : list or numpy array of shape (n_samples,)
The ground truth. Binary (0: inliers, 1: outliers).
Returns
-------
c : numpy array of shape (n_samples,)
Color codes.
"""
y = column_or_1d(y)

# inliers are assigned blue
c = np.full([len(y)], 'b', dtype=str)
outliers_ind = np.where(y == 1)

# outlier are assigned red
c[outliers_ind] = 'r'

return c
2 changes: 0 additions & 2 deletions pyod/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from .utility import invert_order
from .data import generate_data
from .data import evaluate_print
from .data import get_color_codes
from .stat_models import pairwise_distances_no_broadcast
from .stat_models import wpearsonr
from .stat_models import pearsonr_mat
Expand All @@ -22,7 +21,6 @@
'invert_order',
'generate_data',
'evaluate_print',
'get_color_codes',
'pairwise_distances_no_broadcast',
'wpearsonr',
'pearsonr_mat']
26 changes: 0 additions & 26 deletions pyod/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,32 +194,6 @@ def generate_data(n_train=1000, n_test=500, n_features=2, contamination=0.1,
return X_train, X_test, y_train, y_test


def get_color_codes(y):
"""Internal function to generate color codes for inliers and outliers.
Inliers (0): blue; Outlier (1): red.
Parameters
----------
y : list or numpy array of shape (n_samples,)
The ground truth. Binary (0: inliers, 1: outliers).
Returns
-------
c : numpy array of shape (n_samples,)
Color codes.
"""
y = column_or_1d(y)

# inliers are assigned blue
c = np.full([len(y)], 'b', dtype=str)
outliers_ind = np.where(y == 1)

# outlier are assigned red
c[outliers_ind] = 'r'

return c


def check_consistent_shape(X_train, y_train, X_test, y_test, y_train_pred,
y_test_pred):
Expand Down

0 comments on commit c7b5a7d

Please sign in to comment.