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.

104 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
118 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
234 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
0 answers
1k views

Applyingv a 2D mask onto a 3D rgb color list

Problem I have the following image data as a 3D numpy array containing rgb values of the image in a (n,n,3) shaped list (Image). I also have data of the corresponding black and white mask image in a (...
Hector Edu Nseng's user avatar
2 votes
1 answer
286 views

Not able to encode multiple categorical columns at once

I have written the following code for encoding categorical features of the dataframe( named 't') - ...
Sumit Jha's user avatar
2 votes
0 answers
34 views

What would be a good randomization environment for data science?

I would like to know if there are any best practices to optimize random environment. Currently I use this simple structure in my config : ...
Al_P's user avatar
  • 21
2 votes
0 answers
2k views

Iterative Reweighted Least Squares in python

I am trying to manually implement the irls logistic regression (Chapter 4.3.3 in Bishop - Pattern Recognition And Machine Learning) in python. For updating the weights, I am using $w' = w-(\Phi^TR\...
adriankroeger's user avatar
2 votes
0 answers
32 views

How do I plot between 2 variables in a summation equation?

I am new to Python and using Jupyter notebook. Following is the summation equation that I have: $$y(t) = \sum_{i=1}^{t-1} a_{i}y(t-i)$$ How can I plot between variables y and t by formulating this ...
Ak001's user avatar
  • 21
2 votes
1 answer
577 views

Integration of NLP and Angular application

I'm doing a small POC in which I've trained my Machine Learning model (Naive Bayes) and is saved in ".pkl" (pickle) format. Now my next task is to develop a web application which asks the user to ...
Ravi's user avatar
  • 183
2 votes
0 answers
38 views

Varying strength of prior for MCMC hierarchical linear model

I am training an MCMC model in using Pymc3. My aim is to build a series of linear regression models which will predict the time to unload a truck, based on the number of crates to unload. I have ...
Tom's user avatar
  • 141
2 votes
1 answer
1k views

Keras intermediate layer (attention model) output

I have a model with this summary: ...
opyate's user avatar
  • 131
2 votes
0 answers
3k views

Keras LSTM: use weights from Keras model to replicate predictions using numpy

I'm trying to understand what's going on under the hood in Keras' LSTM using the approach taken by https://github.com/greydanus/mr_london/blob/master/app/model/textgen.py. I have a sequential model ...
A S's user avatar
  • 21
1 vote
0 answers
14 views

Efficiently Implement a Data Transformation || Pytorch || coding advice

I have created the following class and function to create a 'custom' dataset. The use case was to sample every nth image from a data set to reduce the size of the data set while still maintaining ...
James's user avatar
  • 21
1 vote
0 answers
273 views

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

I know this question has answers, but they are not working. why this fails ? (and why tensorflow has troubles in reading numpy!!) ...
user305883's user avatar
1 vote
0 answers
99 views

Unsupported object type int Error where array is already in float32

I am learning DL. For the following dataset:: spam.csv can be found here::Click here to see. I am trying to implement a simple NN to detect spam email. For the following code:: ...
Ishrat Hossain's user avatar
1 vote
0 answers
591 views

logistic regression,machine learning

I just started learning ML, so I tried to implement logistic regression on my own in 2 ways (the first code and the second code), but they aren't working, I cross-checked by using sklearn (third code ...
Prathvik G S's user avatar
1 vote
1 answer
41 views

Tensor dot product with rank one tensor from vector

I'm trying to compute an inner product between tensors in numpy. I have a vector $x$ of shape (n,) and a tensor $y$ of shape ...
fabio's user avatar
  • 11
1 vote
0 answers
31 views

Find the right balance between price of a property and agent fee

I would like to know when buying a property when is better for an estate agent to get a higher fee from me compared to the seller if we get a deal with a lower amount. As an example, let's say that: ...
TPPZ's user avatar
  • 111
1 vote
0 answers
23 views

Is there a way to create a continuous distribution graph from discrete percentiles?

I have an underlying distribution that I know is 1-tailed (Packet Response time), but the service that runs the benchmark is opaque to me. It only returns a percentile table up to some number of nines ...
knowads's user avatar
  • 11
1 vote
0 answers
105 views

TypeError: only size-1 arrays can be converted to Python scalars

I am doing multiple linear regression using gradient descent and am getting this type-error ...
Alifiya Batterywala's user avatar
1 vote
1 answer
640 views

Vectorize scipy.stats.norm.logpdf

I am tryint to trying to train a Bayesian NN and at some point I need to compute log-likelihoods for some data points, according to a multivariate diagonal gaussian distribution with parameters (mu, ...
Vellyxenya's user avatar
1 vote
0 answers
18 views

Problem with FFT in Python for smaller df

...
Subhadip Saha's user avatar
1 vote
0 answers
55 views

Predict pixels in optdigits data set

I'm using this dataset : https://archive.ics.uci.edu/ml/datasets/optical+recognition+of+handwritten+digits a dataset that consists of 65 columns , the last column is the label for 10 classes i.e 0,1,2,...
Engineering12's user avatar
1 vote
0 answers
932 views

Py error could not broadcast input array from shape (244,244,3) into shape (224,224,3) arrays have the same shape (224, 224, 3)

this similar to other questions where there is an error related to "broadcasting" a np array with a shape of (244, 244, 3) and a np array with a shape of (244, 244, 4) but in this case both ...
guest's user avatar
  • 11
1 vote
1 answer
64 views

How does time needed for training differ between different batch sizes?

I've constructed a CNN in Python using Numpy, which is trained with mini batch gradient descent for MNIST digit classification. When training with a batch size of 1, the time needed for 5 epochs is ...
dontloseyourgoalie's user avatar
1 vote
0 answers
112 views

Using numpy.ndarray in machine learning sklearn.preprocessing model

I'm having a problem storing and using an array on one model that I'm building in sklearn, Here is what I'm doing: I'm converting an image to numpy and storing as numpy.ndarray in my dataframe (there ...
Mateus Oliveira Cabral's user avatar
1 vote
0 answers
1k views

"Failed to find data adapter that can handle input" when working with mixed data

I have been trying to make my own generator that would handle an [image, float] value for the x (input), while the y is an int (linear output). My data is compiled into a ...
Poofy38's user avatar
  • 11
1 vote
2 answers
55 views

How can ANN handle varied sized inputs?

I have a dataset with a message (string) and an associated mood. I am trying to use an ANN to predict one of the 6 moods using the encoded inputs. This is how my X_train looks like: ...
ChaoS Adm's user avatar
  • 141
1 vote
0 answers
48 views

pandas memory issues

What are some good "best practices" for dealing with large datasets in pandas and numpy? Typically i read data from csv files and use numpy and pandas to prepare them for machine learning and AI ...
Donald S's user avatar
  • 1,959
1 vote
0 answers
21 views

Fit model function out defined data range

I have asked this on SO but it has not been well accepted because it seems to be more about data science than programming. Let's say I have a set of data ...
Py-ser's user avatar
  • 111
1 vote
2 answers
454 views

Reshaping Numpy arrays

I am having a problem trying to reshape my numpy array. i have a 2 dimensional array and i want to make it a 3D array. I have looked everywhere but even if i find some answering my question they just ...
Thembekile Mkhombo's user avatar
1 vote
0 answers
58 views

Parallelization of a MIMO linear filter

I would like to implement a Multi Input Multi Output filtering operation, acting as fast as possible on batches of data. Here is my current implementation: ...
marco's user avatar
  • 11
1 vote
1 answer
420 views

How to find average lag time with variance & confidence of two time series

I have two variables as time series, one a consequent of the other, I would like to find the average time delay it takes the dependent variable to act on the independent variable. Additionally, I ...
Ramy Saad's user avatar
1 vote
0 answers
145 views

Stratified K fold same index present in both test and valid set

I am trying to do a stratified k fold cross validation for my dataset and want to keep an isolated 10% test set from the dataset and use the remaining for training and validation. Below is the code ...
Arjun's user avatar
  • 23
1 vote
0 answers
41 views

How to do Back Propagation Updation for below code?

Below is the code by Siraj Raval for implementing Neural Networks from Scratch. I have some doubts regarding the Code: Why during updation he did W2 = W2 + L1.T.dot(L2_Delta). I Mean shouldn't it be ...
Gopal's user avatar
  • 31
1 vote
0 answers
235 views

Reshape Time series data for Conv2d Block

I am modelling my time series data into a supervised learning problem for the input to a conv2d block in pytorch from this tutorial. ...
Scrappy Coco's user avatar
1 vote
1 answer
492 views

Handling a large dataset consisting of npy files

I have a high number of npy files (448 files) each consisting of around 12k frames (150x150 RGB images) which together make the input to my neural network (X). However, since it is impossible to load ...
Amin Marshal's user avatar
1 vote
0 answers
117 views

Method for 'Simple' Clustering?

In a recent adult education class I took the prof shared a spreadsheet that was written in VBA code and takes ages to execute, I'm sure ...
Programming_Learner_DK's user avatar
1 vote
0 answers
99 views

ValueError when reshaping to 4 dim array for the Keras API

DL beginner here. I'm trying to implement LeNet using Keras and apply it on good ol' MNIST. ...
Tarun Narayanan's user avatar
1 vote
0 answers
43 views

Get right shape of numpy array - (4112, 20, 28, 28)

I'm trying to create an numpy array that resembles = (flattened images, number of examples per class, width, height) This is the original code: ...
Bia Calico Cat's user avatar
1 vote
0 answers
24 views

Confusion with initialising weights in a neural network

Here is some code that initialises weights for an RNN: ...
Finn Williams's user avatar
1 vote
0 answers
158 views

Email clustering using numpy and pandas

Im trying to cluster my raw email data using numpy and pandas only. Hence Im Trying to create an email dataframe from raw emails that I have. However the issue that I have is that I keep getting an ...
King's user avatar
  • 21
1 vote
0 answers
1k views

How to fix setting an array element with a sequence error?

I am trying to make a keras functional model that solves Sentiment Analysis through the amazon database. I am trying to split the input data into 4 different tensors that can be individual feed in to ...
Dylan Sheils's user avatar
1 vote
0 answers
355 views

Two-sample K–S test Kolmogorov–Smirnov test in Python

For my evaluation, I have three different time-series data of the following format with different characterstics where the first column is timestamp and the second column is the value. ...
Brown's user avatar
  • 207
1 vote
0 answers
359 views

Backpropagation using only numpy

I've been trying to implement the backpropagation algorithm using only numpy, I've already done the Keras version, but when implementing the numpy version, the loss is diverging as seen in the image ...
Lucas's user avatar
  • 77
1 vote
0 answers
266 views

Numpy: how to add zeros while reshaping the array

I have a scenario where I have three numpy arrays - indices = np.array([1,2,3], [4,2,3]) distances = np.array([0.2, 0.3, 0.4], [0.3, 0.4, 0.5]) weights = np.array([...
Shivam Srivastava's user avatar
1 vote
0 answers
901 views

Find partial derivative of softmax w.r.t logits in python

I have trouble implementing back propogation for multi class classification My neural network has 2 layers Forward propagation X -> L1 -> L2 weights W are initialized as random ...
Ajmal Rasi's user avatar
1 vote
0 answers
3k views

Keras CNN TypeError: float() argument must be a string or a number, not 'JpegImageFile'

I try to set up a multiclass CNN with Keras which relies on ImageDataGenerator and flow_from_directory. Unfortunately I ...
TorbenL's user avatar
  • 147
1 vote
0 answers
4k views

Matrix multiplication issue (shapes not alligned)

I am building an RNN using numpy only and have started on the forward propagation section. However i am having some issues aligning my matrices. The issue is on this line: ...
Finn Williams's user avatar