Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhao062 committed Aug 2, 2019
1 parent 64c72a1 commit abecbad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion combo/models/classifier_comb.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def predict(self, X):
labels : numpy array of shape (n_samples,)
Class labels for each data sample.
"""
X = check_array(X)

all_scores = np.zeros([X.shape[0], self.n_base_estimators_])

Expand Down Expand Up @@ -146,7 +147,7 @@ def predict_proba(self, X):
The class probabilities of the input samples.
Classes are ordered by lexicographic order.
"""

X = check_array(X)
all_scores = np.zeros(
[X.shape[0], self._classes, self.n_base_estimators_])

Expand Down
7 changes: 3 additions & 4 deletions combo/models/classifier_stacking.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from sklearn.utils import check_array
from sklearn.utils import check_X_y
from sklearn.utils.validation import check_is_fitted
from sklearn.utils.multiclass import check_classification_targets

from ..utils.utility import check_parameter
from ..utils.utility import list_diff
Expand Down Expand Up @@ -121,7 +120,8 @@ class Stacking(BaseAggregator):
"""

def __init__(self, base_estimators, meta_clf=None, n_folds=2, keep_original=True,
def __init__(self, base_estimators, meta_clf=None, n_folds=2,
keep_original=True,
use_proba=False, shuffle_data=False, random_state=None,
threshold=None, pre_fitted=None):

Expand Down Expand Up @@ -170,8 +170,7 @@ def fit(self, X, y):
# Validate inputs X and y
X, y = check_X_y(X, y)
X = check_array(X)
check_classification_targets(y)
self._classes = len(np.unique(y))
self._set_n_classes(y)

n_samples = X.shape[0]

Expand Down
10 changes: 10 additions & 0 deletions docs/zreferences.bib
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,14 @@ @inproceedings{kriegel2011interpreting
pages={13--24},
year={2011},
organization={SIAM}
}

@article{ho1994decision,
title={Decision combination in multiple classifier systems},
author={Ho, Tin Kam and Hull, Jonathan J. and Srihari, Sargur N.},
journal={IEEE Transactions on Pattern Analysis \& Machine Intelligence},
number={1},
pages={66--75},
year={1994},
publisher={IEEE}
}

0 comments on commit abecbad

Please sign in to comment.