Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
sklearn
/
utils
/
File Content:
mocking.py
import numpy as np from ..base import BaseEstimator, ClassifierMixin from .testing import assert_true from .validation import _num_samples, check_array class ArraySlicingWrapper(object): def __init__(self, array): self.array = array def __getitem__(self, aslice): return MockDataFrame(self.array[aslice]) class MockDataFrame(object): # have shape an length but don't support indexing. def __init__(self, array): self.array = array self.values = array self.shape = array.shape self.ndim = array.ndim # ugly hack to make iloc work. self.iloc = ArraySlicingWrapper(array) def __len__(self): return len(self.array) def __array__(self, dtype=None): # Pandas data frames also are array-like: we want to make sure that # input validation in cross-validation does not try to call that # method. return self.array def __eq__(self, other): return MockDataFrame(self.array == other.array) class CheckingClassifier(BaseEstimator, ClassifierMixin): """Dummy classifier to test pipelining and meta-estimators. Checks some property of X and y in fit / predict. This allows testing whether pipelines / cross-validation or metaestimators changed the input. """ def __init__(self, check_y=None, check_X=None, foo_param=0): self.check_y = check_y self.check_X = check_X self.foo_param = foo_param def fit(self, X, y): assert_true(len(X) == len(y)) if self.check_X is not None: assert_true(self.check_X(X)) if self.check_y is not None: assert_true(self.check_y(y)) self.classes_ = np.unique(check_array(y, ensure_2d=False, allow_nd=True)) return self def predict(self, T): if self.check_X is not None: assert_true(self.check_X(T)) return self.classes_[np.zeros(_num_samples(T), dtype=np.int)] def score(self, X=None, Y=None): if self.foo_param > 1: score = 1. else: score = 0. return score
Submit
FILE
FOLDER
Name
Size
Permission
Action
__pycache__
---
0755
sparsetools
---
0755
tests
---
0755
__init__.py
13522 bytes
0644
_logistic_sigmoid.cpython-35m-x86_64-linux-gnu.so
33688 bytes
0755
_random.cpython-35m-x86_64-linux-gnu.so
81096 bytes
0755
_scipy_sparse_lsqr_backport.py
18021 bytes
0644
arpack.py
73115 bytes
0644
arrayfuncs.cpython-35m-x86_64-linux-gnu.so
38104 bytes
0755
bench.py
370 bytes
0644
class_weight.py
7411 bytes
0644
deprecation.py
2417 bytes
0644
estimator_checks.py
60116 bytes
0644
extmath.py
27057 bytes
0644
fast_dict.cpython-35m-x86_64-linux-gnu.so
176248 bytes
0755
fixes.py
13923 bytes
0644
graph.py
6239 bytes
0644
graph_shortest_path.cpython-35m-x86_64-linux-gnu.so
86208 bytes
0755
lgamma.cpython-35m-x86_64-linux-gnu.so
20080 bytes
0755
linear_assignment_.py
9524 bytes
0644
metaestimators.py
4309 bytes
0644
mocking.py
2190 bytes
0644
multiclass.py
14732 bytes
0644
murmurhash.cpython-35m-x86_64-linux-gnu.so
77272 bytes
0755
optimize.py
5739 bytes
0644
random.py
10523 bytes
0644
seq_dataset.cpython-35m-x86_64-linux-gnu.so
77384 bytes
0755
setup.py
2993 bytes
0644
sparsefuncs.py
13505 bytes
0644
sparsefuncs_fast.cpython-35m-x86_64-linux-gnu.so
404296 bytes
0755
stats.py
1692 bytes
0644
testing.py
28245 bytes
0644
validation.py
26027 bytes
0644
weight_vector.cpython-35m-x86_64-linux-gnu.so
38080 bytes
0755
N4ST4R_ID | Naxtarrr