Giter Site home page Giter Site logo

SMOTE on pipeline about imbalanced-learn HOT 3 CLOSED

flolas avatar flolas commented on May 16, 2024
SMOTE on pipeline

from imbalanced-learn.

Comments (3)

stavskal avatar stavskal commented on May 16, 2024

I would like to know that too. I'm trying to use UnderSampler in sklearn pipeline and I get some errors

from imbalanced-learn.

fmfn avatar fmfn commented on May 16, 2024

Hum, I forgot about this issue, I apologize. Can you please post the error msg?

from imbalanced-learn.

stavskal avatar stavskal commented on May 16, 2024

So the following error occurs when I add the UnderSampler to the pipeline, otherwise it works just fine:

File "pipeTrain.py", line 56, in
score = cross_val_score(pipe,X,Y,cv=3)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/sklearn/cross_validation.py", line 1361, in cross_val_score
for train, test in cv)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 659, in call
self.dispatch(function, args, kwargs)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 406, in dispatch
job = ImmediateApply(func, args, kwargs)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 140, in init
self.results = func(_args, *_kwargs)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/sklearn/cross_validation.py", line 1459, in _fit_and_score
estimator.fit(X_train, y_train, *_fit_params)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/sklearn/pipeline.py", line 141, in fit
self.steps[-1][-1].fit(Xt, y, *_fit_params)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/sklearn/ensemble/forest.py", line 195, in fit
X = check_array(X, dtype=DTYPE, accept_sparse="csc")
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/sklearn/utils/validation.py", line 337, in check_array
array = np.atleast_2d(array)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/numpy/core/shape_base.py", line 100, in atleast_2d
ary = asanyarray(ary)
File "/home/tabrianos/Desktop/Thesis/Database/venv/local/lib/python2.7/site-packages/numpy/core/numeric.py", line 525, in asanyarray
return array(a, dtype, copy=False, order=order, subok=True)
ValueError: could not broadcast input array from shape (200,26) into shape (200)

Code looks like this:

X=np.load('numdata/epochFeats.npy')
Y=np.load('numdata/epochLabels.npy')
forest = RandomForestClassifier(n_estimators=100, n_jobs = -1)
us = UnderSampler(verbose=True)
pipe = Pipeline(steps=[('UnderSampler',us) ,('forest',forest)])
score = cross_val_score(pipe,X,Y,cv=3)

Sorry for bad formating

from imbalanced-learn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.