Giter Site home page Giter Site logo

Comments (9)

gregversteeg avatar gregversteeg commented on May 26, 2024 1

Can you make x an np.array([]) too?

from npeet.

gregversteeg avatar gregversteeg commented on May 26, 2024 1

Yes, I think so!

from npeet.

gregversteeg avatar gregversteeg commented on May 26, 2024

It could be a question of which quantities it expects to be lists of vectors, and which not. I'd try modifying where the brackets are, e.g. this:
ee.micd(cont.iloc[:,[1]].values.tolist(),disc.iloc[:,1].values.tolist()))
That way, the continuous one is a (n_samples, 1) and the discrete on is just (n_samples,). I think that's right. If it doesn't work, print out the dimensions of cont and disc, and I'll think about it a little more.

from npeet.

gregversteeg avatar gregversteeg commented on May 26, 2024

(I'm pretty sure discrete expects just a single discrete quantity, not a vector, but continuous does expect a vector.)

from npeet.

Angela446-lgtm avatar Angela446-lgtm commented on May 26, 2024

Yes!it works!thank you!

from npeet.

fingoldo avatar fingoldo commented on May 26, 2024

(I'm pretty sure discrete expects just a single discrete quantity, not a vector, but continuous does expect a vector.)

Can you please provide a working example for micd?
I can use one for mi:

x = [[1.3], [3.7], [5.1], [2.4], [3.4]]
y = [[1.5], [3.32], [5.3], [2.3], [3.3]]
ee.mi(x, y)

0.16831442143704642

Now, according to your recommendations:

x = [[1.3], [3.7], [5.1], [2.4], [3.4]]
y = [5, 3, 5, 2, 3]
ee.micd(x, y)

C:\ProgramData\Anaconda3\lib\site-packages\npeet\entropy_estimators.py in micd(x, y, k, base, warning)
223 entropy_x_given_y = 0.0
224 for yval, py in zip(y_unique, y_proba):
--> 225 x_given_y = x[(y == yval).all(axis=1)]
226 if k <= len(x_given_y) - 1:
227 entropy_x_given_y += py * entropy(x_given_y, k, base)

C:\ProgramData\Anaconda3\lib\site-packages\numpy\core_methods.py in _all(a, axis, dtype, out, keepdims, where)
62 # Parsing keyword arguments is currently fairly slow, so avoid it for now
63 if where is True:
---> 64 return umr_all(a, axis, dtype, out, keepdims)
65 return umr_all(a, axis, dtype, out, keepdims, where=where)
66

AxisError: axis 1 is out of bounds for array of dimension 1

from npeet.

gregversteeg avatar gregversteeg commented on May 26, 2024

Oh, how annoying! The way you called it seems more natural, but at a glance it seems like it also expects "vectors" for the discrete values y = np.array([[5], [3]...]).
Also it seems like it would only work if y is a numpy array. I can't believe I didn't just put in a check, as y = np.asarray(y) would be an efficient way to avoid problems like this.
Let me know if this works.

from npeet.

fingoldo avatar fingoldo commented on May 26, 2024

ld only work if y is a numpy array. I can't believe I didn't just put in a check, as y = np.asarray(y) would be an efficient way to avoid

mm, then I get

x = [[1.3], [3.7], [5.1], [2.4], [3.4]]
y =np.array([[5], [3], [5], [2], [3]])
ee.micd(x, y)

TypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_19412\3742637936.py in
1 x = [[1.3], [3.7], [5.1], [2.4], [3.4]]
2 y =np.array([[5], [3], [5], [2], [3]])
----> 3 ee.micd(x, y)

C:\ProgramData\Anaconda3\lib\site-packages\npeet\entropy_estimators.py in micd(x, y, k, base, warning)
223 entropy_x_given_y = 0.0
224 for yval, py in zip(y_unique, y_proba):
--> 225 x_given_y = x[(y == yval).all(axis=1)]
226 if k <= len(x_given_y) - 1:
227 entropy_x_given_y += py * entropy(x_given_y, k, base)

TypeError: only integer scalar arrays can be converted to a scalar index

from npeet.

fingoldo avatar fingoldo commented on May 26, 2024

oh wait. it's actually x that has to be a numpy array. now it works:

x = np.array([[1.3], [3.7], [5.1], [2.4], [3.4]])
y =np.array([[5], [3], [5], [2], [3]])
ee.micd(x, y)

0.0

One more question if possible:
the fact that we are using list of lists implies that in npeet functions we can use m-dimensional arrays for x and y, right?
so we can estimate a MI of a 3-dimensional x on 2-dimensional y and it will be supported?

from npeet.

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.