Category "numpy"

How to make fixed ticks for graph using matplotlib [duplicate]

I am trying to make a graph with fixed ticks, regardless to the points values. For example, I want the ticks to be 0-6, and the points values

Comparing lists within dataframe column to another list using numpy's where function

This is my first post at Stackoverflow, so thank you for the help. I am trying to replicate a code where I can match a list within a dataframe to another list,

How to customize general error messages of numpy?

I am writing a Vector and Matrix classes that use numpy in the backend in order to abstract some common methods and calculations (specifically, physics calculat

Conversion between binary vector and 128 bit number

Is there a way to convert back and forth between a binary vector and a 128-bit number? I have the following binary vector: import numpy as np bits = np.array([

Generate binary outcome dummy data based on probability of items and its feature

I want to generate a synthetic data from scratch which is a binary outcome sequence data (0/1). My data has following property- For the sake of an example, lets

How to correctly compute the gradient of a curve using numpy gradient?

I have a curve which is composed of 1200 values and i just want to compute its derivative so i use numpy gradient function. Here is the code i'm using: data = n

shortest distance between a point and a rectangle based on numpy implementation

Goal: For a point a and a rectangle B, I would like to calculate the shortest distance between these two objects. Motivation Because this calculation is part of

How to check object image color and paste on same background color?

I'm trying to generate augmented image data by pasting objects on different background. Problem is I've objects of different colors and background and the objec

How to create numpy array for a dataset?

I've a dataset of almost 3k colored images each of dim 1920x1080 and I want to store it in a numpy array so when calling shape on it in returns (3716,493,491,3)

Addressing polynomial multiplication and division "overflow" issue

I have a list of the coefficient to degree 1 polynomials, with a[i][0]*x^1 + a[i][1] a = np.array([[ 1. , 77.48514702], [ 1. , 0.

TF-Agents _action_spec: how to define the correct shape for discrete action space?

Scenario 1 My custom environment has the following _action_spec: self._action_spec = array_spec.BoundedArraySpec( shape=(highestIndex+1,), dtype=np.

How can I use Gaussian Mixture to fit 2 gaussians in my data?

I'm trying to fit 2 gaussians in my red/blue population data. But it does not fit. What am I doing wrong? The code is: mag1 = 'z' mag2 = 'y' mask_rich = (wazp_m

Simulating expectation of continuous random variable

Currently I want to generate some samples to get expectation & variance of it. Given the probability density function: f(x) = {2x, 0 <= x <= 1; 0 othe

How to color a grayscale image based on a mask?

I have two images: A grayscale image, and a binary mask with the same dimensions. How do I color the image on the mask, while the rest of the image remains gray

curve fitting error for optimal parameters while using scipy optimize curvefit in python

I am getting optimization errors while creating map of h3 moments using a self-defined function get_h3 in python for an image file called "image_test". The idea

How to make the dataframe faster ? either by using dictionary or numpy?

I am new to data structures and I would like to make my code faster (this is just part of a bigger code). Using dataframes while looking up variables is slowing

Calculating joint probabilities from two tensors of different sizes in pytorch

I am trying to calculate joint probabilities from two tensors.. It's a little bit confusing for me. Suppose we have : a = torch.Tensor((10, 2)) b = torch.Tensor

How to solve the problem with installing google colab?

Tried to solve a simple problem from google.colab import files import numpy as np file = files.upload() !ls my_array = np.loadtxt('train_vector.csv', delimi

Saving Detected Objects Individually from Point Cloud with RANSAC and DBSCAN

Hello, I am trying to detect objects from point cloud data using RANSAC and DBSCAN algorithms. I need to save these detected objects as separate files and then

tf.data pipeline from large numpy arrays for a multiple input, multiple output Keras model and distributed training

This question relates to the optimal setup for a multiple-input multiple-output Keras (Tensorflow) model given corresponding numpy arrays. For example, suppose