Giter Site home page Giter Site logo

Comments (2)

fmfn avatar fmfn commented on May 22, 2024

It seems like a problem resulting from using a sparse matrix. To be honest, sparse matrix were completely neglected when writing this. Which kinda makes sense given when they are usually needed and the fact that most methods here (definitely SMOTE) rely on local density estimations to generate new samples.

I'll take a look over the weekend.

from imbalanced-learn.

eromoe avatar eromoe commented on May 22, 2024

I found above problem cause by y_train be converted to pandas.Series in some place at my code. After I fix that, sparse become pain, you are right.

concatenate((overx,self.x[self.y == key],self.x[self.y == key][indx]), axis=0)
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 3066, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-40-b5ea4e093941>", line 1, in <module>
    concatenate((overx,self.x[self.y == key],self.x[self.y == key][indx]), axis=0)
ValueError: zero-dimensional arrays cannot be concatenated

test code:

a = sparse.csr_matrix(np.zeros((100,200)))
b = sparse.csr_matrix(np.zeros((200,200)))
c = sparse.csr_matrix(np.zeros((300,200)))

np.concatenate((a,b,c), axis=0)

>>>  ValueError: zero-dimensional arrays cannot be concatenated .....

sulotion:

import scipy.sparse as sp
sparse.vstack((a, b, c))
>>> <600x200 sparse matrix of type '<type 'numpy.float64'>'
        with 0 stored elements in Compressed Sparse Row format>

Add a custom function to detect the type then choose concatenate or vstack?
Maybe there are some similar problem like this, I would search for is there any exist package would play this situation well.

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.