Skip to content

Commit

Permalink
Improve codes
Browse files Browse the repository at this point in the history
  • Loading branch information
yuezhao@cs.toronto.edu authored and yuezhao@cs.toronto.edu committed Jun 3, 2018
1 parent 3e12941 commit 73d33b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyod/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__version__ = '0.4.3'
__version__ = '0.4.4'

from . import models
from . import utils
Expand Down
7 changes: 3 additions & 4 deletions pyod/utils/utility.py
Expand Up @@ -10,6 +10,7 @@
from sklearn.metrics import precision_score
from sklearn.preprocessing import StandardScaler
from sklearn.utils import column_or_1d
from sklearn.utils.validation import check_consistent_length


def check_parameter_range(param, low=None, high=None):
Expand Down Expand Up @@ -55,6 +56,7 @@ def standardizer(X_train, X_test):
:return: X_train_ and X_test after the Z-score normalization
:rtype: tuple(ndarray, ndarray)
"""
check_consistent_length(X_train, X_test)
scaler = StandardScaler().fit(X_train)
return (scaler.transform(X_train), scaler.transform(X_test))

Expand Down Expand Up @@ -113,12 +115,9 @@ def get_label_n(y, y_pred, n=None):
y = column_or_1d(y)
y_pred = column_or_1d(y_pred)

check_consistent_length(y, y_pred)
y_len = len(y) # the length of targets

if y.shape != y_pred.shape:
ValueError(
'ground truth y and prediction labels_ shape does not match')

# calculate the percentage of outliers
if n is not None:
outlier_perc = n / y_len
Expand Down

0 comments on commit 73d33b2

Please sign in to comment.