DEV Community

es404020
es404020

Posted on

Using Numpy histogram2d

Histogram2d is a Numpy function used in group two by two matrix based on certain bin conditions.

For Example

a=np.array([0.00, 1.00, 1.00, 0.98, 0.04, 0.85, 1.00, 1.00, 1.00, 0.36, 1.00,
       1.00, 1.00, 0.00, 0.63, 1.00, 0.00, 0.15, 1.00])

b=np.array([0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1])


bins=np.array([0,0.5,1])

Enter fullscreen mode Exit fullscreen mode

BINS : means from 0 - 0.4 is 0 and 0.5 to 1 is one


cm = np.histogram2d(a,b), bins=bins)[0]

array([[5.00, 1.00],
       [1.00, 12.00]])

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay