Skip to main content

Questions tagged [numpy]

NumPy is one of the fundamental packages used for scientific computing in the Python ecosystem. Specifically, NumPy is used for numerical computing and uses n-dimensional arrays.

Filter by
Sorted by
Tagged with
20 votes
2 answers
159k views

How to include labels in sns heatmap

I got this matrix ...
Srihari's user avatar
  • 777
15 votes
3 answers
68k views

How to remove outliers using box-plot?

I have data of a metric grouped date wise. I have plotted the data, now, how do I remove the values outside the range of the boxplot (outliers)? All the ['AVG'] data is in a single column, I need it ...
Uday T's user avatar
  • 342
12 votes
1 answer
89k views

How to deal with TypeError: ufunc 'isnan' not supported for the input types [closed]

I have dealt with all the Nan values in the features dataframe, then why I am still getting this error? ...
Jodh Singh's user avatar
10 votes
4 answers
8k views

How to replace NaN values for image data?

My data set has a total of 200 columns, where each column corresponds to the same pixel in all of my images. In total, I have 48,500 rows. The labels for the data range from 0-9. The data looks ...
chomprrr's user avatar
  • 203
9 votes
2 answers
41k views

How to determine input shape in keras?

I am having difficulty finding where my error is while building deep learning models, but I typically have issues when setting the input layer input shape. This is my model: ...
Josh Zwiebel's user avatar
9 votes
2 answers
41k views

Python - Converting 3D numpy array to 2D

I have a 3D matrix like this: ...
Tarlan Ahad's user avatar
9 votes
2 answers
389 views

Are there any graph embedding algorithms like this already?

I wrote an algorithm for generating node embeddings based on the graph's topology. Most of the explanation is done in the readme file and the examples. The question is: Am I reinventing the wheel? ...
monomonedula's user avatar
8 votes
1 answer
30k views

how to check all values in particular column has same data type or not?

I have column 'ABC' which has 5000 rows. Currently, dtype of column is object. Mostly it has string values but some values dtype is not string, I want to find all those rows and modify those rows. ...
Kiran's user avatar
  • 195
8 votes
2 answers
6k views

Fill missing values AND normalise

I have two columns of training data for a neural net which are missing values. (There are many other columns which aren't missing values.) For example ...
joel's user avatar
  • 180
7 votes
4 answers
4k views

Convert Numpy array with 'n' and 'y' into integer array of 0 and 1

I have a NumPy array of strings: 'n', 'y', wanna convert it into integer array of 0, 1, how to convert it? ...
JL1829's user avatar
  • 81
7 votes
4 answers
74k views

ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int) in Python

I have written the following code for a neural network to perform regression on a dataset, but I am getting a ValueError. I have looked up to different answers and ...
Ishan Dutta's user avatar
5 votes
3 answers
51k views

Scatter plot for binary class dataset with two features in python

I have my dataset that has multiple features and based on that the dependent variable is defined to be 0 or 1. I want to get a scatter plot such that all my positive examples are marked with 'o' and ...
Nitish's user avatar
  • 91
5 votes
2 answers
73k views

Normalize matrix in Python numpy

I've an array like this: ...
Tarlan Ahad's user avatar
5 votes
1 answer
10k views

Are view() in Pytorch and reshape() in Numpy similar?

Are view() in torch and reshape() in Numpy similar? view() is applied on torch tensors to ...
Kailash Ahirwar's user avatar
5 votes
2 answers
30k views

Plotting in Multiple Linear Regression in Python 3

So I'm working on linear regression. So far I've managed to plot in linear regression, but currently I'm on Multiple Linear Regression and I couldn't manage to plot it, I can get some results if I ...
hael's user avatar
  • 51
4 votes
3 answers
6k views

Count the max number of consecutive 1 and 0 in Pandas Dataframe [closed]

Hey I have the following Dataset import pandas as pd df = pd.DataFrame({ 'column1': [0,0,1,0,1,0,0,1,1,0,1,1,1]}) I want to be able to count the number of ...
Myles Collier's user avatar
4 votes
2 answers
10k views

Cannot reshape array of size 12288 into shape (64,64)

I have an image I loaded with the image.load_img() function but when I try to reshape it I get this error: ...
Houmes's user avatar
  • 41
4 votes
3 answers
5k views

Cosine similarity with arrays contaning NaN

I am trying to calculate a cosine similarity using Python in order to find similar users basing on ratings they have given to movies. As it can be expected there are a lot of NaN values. I am using ...
user641597's user avatar
4 votes
2 answers
3k views

Aggregate NumPy array with condition as mask

I have a matrix $b$ with elements: $$b = \begin{pmatrix} 0.01 & 0.02 & \cdots & 1 \\ 0.01 & 0.02 & \cdots & 1 \\ \vdots& \vdots & \ddots & \vdots \\ 0.01 &...
user3613025's user avatar
4 votes
1 answer
311 views

Can someone please explain what this sample function is upto?

So there is a function in Dino_Name_Generator at Deeplearning.ai notebook ...
thanatoz's user avatar
  • 2,415
4 votes
2 answers
29k views

ValueError: Input contains NaN, infinity or a value too large for dtype('float64') [duplicate]

I am trying to fit my data into my model which takes numpy as input, so I feed the model with the dataframe values ...
Srihari's user avatar
  • 777
4 votes
0 answers
4k views

Memory problems with smaller CNN [closed]

Hello everyone I'm having a weird problem. I having problem with one of two models I've been using. Models take an image data as input and outputs joystick and keyboard information. A simple CNN, ...
Manu's user avatar
  • 41
3 votes
2 answers
880 views

Which is meant by +/-9.2e18 years in timespan?

I was able to convert the 9.2e18 AD to a date, but I am confused about the exact date. Which date is 9.2e18 AD and and 9.2e18 BC? Time span (absolute) - [9.2e18 BC, 9.2e18 AD] i.e +/- 9.2e18 years ...
Rinshan Kolayil's user avatar
3 votes
2 answers
16k views

How feed a numpy array in batches in Keras

I have the data in the following format: 1: DATA NUMPY ARRAY (trainX) A numpy array of a set of numpy array of 3d np arrays. To be more articulate the format is: [[3d data], [3d data], [3d data], [...
thegravity's user avatar
3 votes
2 answers
200 views

How can I determine the relationship between spam and weekdays?

I am trying to check if there is a correlation between spam emails and weekdays. My dataset looks like as follows: ...
LdM's user avatar
  • 165
3 votes
1 answer
2k views

How can I combine two single-column datasets into a single Pandas data frame?

I'd like to import the Rotten Tomatoes Movie Review dataset into a single data frame. How can I combine two datasets that are 1-column strings into a text, label ...
Ryan's user avatar
  • 145
3 votes
3 answers
2k views

Question Related Numpy

With Numpy, what’s the best way to compute the inner product of a vector of size 10 with each row in a matrix of size (5, 10)?
Nikhil Pandarge's user avatar
3 votes
2 answers
1k views

Is there a difference between np.matrix(np.array([0,0])) and np.matrix([0,0])?

I was reading this code, for implemnting linear regression from scratch: ...
Sabito stands with Ukraine's user avatar
3 votes
1 answer
5k views

SVM SMOTE fit_resample() function runs forever with no result

Problem fit_resample(X,y) is taking too long to complete execution for 2million rows. Dataset specifications I have a labeled dataset about network features, ...
cappy0704's user avatar
  • 231
3 votes
1 answer
5k views

How can I create .nii (nifti) file from 3D Numpy array

I have a prediction numpy array. How can I make a .nii or .nii.gz mask file from the array?
Eren Kallikci's user avatar
3 votes
1 answer
7k views

Is it valid to use numpy.gradient to find slope of line as well as slope of curve at any point?

what is the difference between slope of the line and slope of the curve? Is it valid to use numpy.gradient to find the slope of the line and slope of the curve at ...
star's user avatar
  • 1,471
3 votes
3 answers
2k views

Which Format is Faster, Matlab (.mat) or NumPy (.npy)?

I am working on a deep learning problem to detect cancer in images of size 250 x 250. I have hardware limitations and I have been running out of memory. I decided to convert my images to Matlab ...
ndrwnaguib's user avatar
3 votes
1 answer
52k views

MemoryError for np.array [closed]

I was trying the Keras CNN Stater Code on Ubuntu 16.04, from the below link: https://www.hackerearth.com/challenge/competitive/deep-learning-3/machine-learning/predict-the-energy-used-612632a9/#...
Nands's user avatar
  • 133
3 votes
1 answer
150 views

Expectation Maximization Algorithm (EM) for Gaussian Mixture Models (GMMs)

I'm trying to apply the Expectation Maximization algorithm (EM) to a Gaussian Mixture Model (GMM) using Python and NumPy. The PDF document I am basing my implementation on can be found here. Below are ...
Blg Khalil's user avatar
3 votes
1 answer
241 views

Data sets that have strings and numerical data all in one column [closed]

Here's a code I wrote for pre-processing a data set. It works ...
Dulangi_Kanchana's user avatar
3 votes
2 answers
2k views

Inputting (a lot of )data into a dataframe one row at a time

I'm using python. Some 2D numpy arrays are stored in individual rows of a Series. They are 30x30 images. It looks something like this: ...
Isu Shrestha's user avatar
3 votes
1 answer
432 views

Better code completion in python notebooks

How come python code suggestion is awful in notebooks and spyder? Smetimes it shows classes methods and variables, sometimes not
3nomis's user avatar
  • 541
3 votes
1 answer
34k views

TypeError: Image data of dtype object cannot be converted to float [closed]

I am trying to convert files stored in a CSV file dataset to grayscale. I run the code which worked on my previous dataset but I now get this error: TypeError: Image data of dtype object cannot be ...
Jack's user avatar
  • 155
3 votes
1 answer
355 views

Feeding uint8 type to NN

I’m facing some (RAM) memory issues to train a neural network. I have an input array consisting of grayscale images encoded as the type numpy.uint8 (therefore the whole range 0-255 can be covered). ...
L. B.'s user avatar
  • 176
3 votes
1 answer
460 views

How to deal with memory exceptions while processing large amount of data?

Am trying to develop a python script which reads a large CSV file (approx 1.2 GB historical data) in chunks and performs following steps: Take backup of the file Extract new records of previous day ...
Optimizor's user avatar
3 votes
1 answer
2k views

SVR is giving same prediction for all features

I'm creating a basic application to predict the 'Closing' value of a stock for day n+1, given features of stock n using Python and Scikit-learn A sample row in my dataframe looks like this (2000 rows) ...
Ben Williams's user avatar
3 votes
1 answer
2k views

Large Numpy.Array for Multi-label Image Classification (CelebA Dataset)

Task: Build CNN Model (preferably Keras or TensorFlow) to Predict Labels Associated to Each Image in CelebA Dataset (Multi-label Image Classification) In past, for majority of multiclass/binary image ...
TwinPenguins's user avatar
  • 4,259
3 votes
0 answers
114 views

Detecting pushups based on pose data

I've been playing with Google's MLKit, and decided to detect push ups. As a quick test, I took the position of the left shoulder, and plotted the Y Axis. Here's how a variety of trials look: Five ...
Stepan Parunashvili's user avatar
3 votes
1 answer
233 views

tensorflow pseudo inverse doesn't work for complex matrices!

The Tensorflow documentation here says that: tf.linalg.pinv is ''analogous to numpy.linalg.pinv. It differs only in default value of rcond''. However, tf.linalg.pinv requires the matrix to ...
eMichel's user avatar
  • 33
3 votes
0 answers
2k views

How to apply a groupby rolling function to create multiple columns in the dataframe

I am setting up a volume profile series over a stock data. I have implemented the market profile code from this github repo and the link to the data is here and the example here. Some Sample of data ...
Scrappy Coco's user avatar
3 votes
0 answers
84 views

Neural network cost is constant never changing during training

I am trying to build a binary classifier to predict a pulsar star with Single Hidden layer Neural Network. But the cost on training dataset after almost 100 iterations has no change, following is the ...
Chinmaya B's user avatar
2 votes
1 answer
156 views

is there a way to normalize [-3,1] to ${\begin{bmatrix} \dfrac{-3}{\sqrt{10}}\\ \dfrac{1}{\sqrt{10}}\\ \end{bmatrix}}$ with python?

I am learning SVD by following this MIT course The lecturer is trying to normalize a vector $${\begin{bmatrix} -3\\ 1\\ \end{bmatrix}}$$ to $${\begin{bmatrix} \dfrac{-3}{\sqrt{10}}\\ \dfrac{1}{\...
Jay's user avatar
  • 425
2 votes
3 answers
29k views

Numpy element wise comparison for a particular value in two arrays [closed]

If I have two arrays as shown below: a = numpy.array([0, 0, 1, 0, 1, 1, 1, 0, 1]) b = numpy.array([1, 1, 1, 0, 0, 1, 1, 0, 0]) Is there an easy way using numpy ...
K L D'Souza's user avatar
2 votes
2 answers
2k views

Ways to simulate weather data over several periods (Python or R)?

I have a time series dataset that has several variables for a state/province for fixed periods of time. That is for state A, there are samples from April 2017 to July 2019. Of course, I thought adding ...
Shiv_90's user avatar
  • 265
2 votes
1 answer
863 views

How can I count the number of matching zero elements between two numpy arrays?

I have a function that returns the predicted accuracy of a time-series model. I have two equally-sized numpy arrays, one for the actual direction and one for the predicted direction. I'm classifying ...
brohjoe's user avatar
  • 135

1
2 3 4 5
8