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
0 votes
0 answers
6 views

Does the result of scipy.stats.f_oneway and sklearn.feature_selection.f_classif should be equal?

I thought that the results of both functions would be the same, but: ...
user avatar
  • 1
0 votes
1 answer
9 views

Creating a grid type 3D data array from data points

I have a 3 data column $(X, Y, Z)$ ranges from $(min, max)$. For example, $X = (0, 5)$, $Y=(0, 3)$, $Z=(0, 2)$. By using them I need to create a numpy array in the form of $[(0, 0, 0), (0, 0, 1), (0, ...
user avatar
  • 113
0 votes
0 answers
11 views

its posible to reshape a 1 dim with 30 values to a 2 dim (6, 5) with numpy?

I'm working with tensorflow. The run function next_state = np.reshape(next_state, [1, [self.state]) returns ValueError: Cant reshape array of size 30 into shape (...
user avatar
0 votes
0 answers
10 views

Proper datashape and model architecture for recognizing highs and lows in a chart

I am using a Keras LSTM model to try to pinpoint the highs and lows (relative high points and low points) in a chart (I need the actual coordinates to those highs and lows, not just an image). The ...
user avatar
  • 101
0 votes
0 answers
4 views

Identifing this dataset for sanitising

I am beginner here starting with data science for analytics. I am trying to figure out what data set this is and how to read it from python. I have an idea of the steps but not sure how to code it in ...
user avatar
  • 1
-1 votes
2 answers
35 views

unable to pass X_train and y_train in my regressor variable. i got a ValueError

...
user avatar
0 votes
0 answers
19 views

Slice NumPy arrays differently along axes (without looping)

I am trying to analyze a temporal signal sampled by a 2D sensor. Effectively, this means integrating the signal values for each sensor pixel (array row/column coordinate) at the times each pixel is ...
user avatar
0 votes
0 answers
87 views

How to solve this ValueError: Dimensions must be equal

I'm trying to train an autoencoder model with colored image samples but I got this error ...
user avatar
  • 1
0 votes
0 answers
27 views

OpenCV warpAffine error during image augmentation using Albumentations

I have been trying to do image augmentation using a library called Albumentations. But I got some error from OpenCV while transforming the images. I ran the code below on Kaggle's notebook. The ...
user avatar
  • 1
0 votes
1 answer
36 views

How to solve MemoryError problem

I've created and normalized my colored image dataset of 3716 sample and size 493*491 as x_train, its type is list I'm tring to convert it into numpy array as follows ...
user avatar
  • 1
0 votes
1 answer
86 views

Python: calculate the weighted average correlation coefficient

I am calculating the volatility (standard deviation) of returns of a portfolio of assets using the variance-covariance approach. Correlation coefficients and asset volatilities have been estimated ...
user avatar
  • 101
1 vote
1 answer
25 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 ...
user avatar
  • 11
0 votes
1 answer
22 views

Why fourier transform extrapolation goes to extreme on edges but not in the middle, how to fix it

Why fourier transform extrapolation goes to extreme on edges but not in the middle, how to fix it with python ...
user avatar
0 votes
0 answers
23 views

How to sample a dataframe or numpy array with a particular interval?

I have the following dataframe : ...
user avatar
  • 1
0 votes
0 answers
17 views

How to load several numpys in batch generator from directory

I have a deep learning model which has to be feed with a huge amount of data (200k of 256x256 images), so it runs out of memory. I have divided my data in several numpy arrays that are in an specified ...
user avatar
2 votes
0 answers
22 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') - ...
user avatar
0 votes
0 answers
41 views

regression.fit(x_train, y_train) is not working on python

I try to deal with my homework. The Job is to take the Achievement data and perform a multi-linear regression on it. The code is published here. I am quite new to programming in Python and in data ...
user avatar
0 votes
0 answers
24 views

Pandas Dataframe Filtering based on rows

I have a dataset like this: ...
user avatar
  • 1
0 votes
1 answer
30 views

How do I import and export more than one numpy arrays?

I have four numpy arrays X_train, y_train, X_test, y_test...
user avatar
0 votes
0 answers
63 views

Add an empty row in dataframe with condition using python

i have this 2 datafram and when i compare this 2 datafram i want to add an empty row where the row is in the first one and is not in the second i write this code but is not working for the empty row <...
user avatar
0 votes
0 answers
8 views

Create dataset from 3d batches of feature maps for classification model

I am trying to create dataset of batches of several volumetric features and labels. It's a nifti volumes with extracted features from brain. I am trying to create a pair of feature X and labels y for ...
user avatar
1 vote
0 answers
26 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: ...
user avatar
  • 111
2 votes
1 answer
69 views

Generating a random numpy ndarray of 0 and 1 with a specific range of 1 values

I want to generate a random numpy ndarray of 0 and 1. I want that the number of occurrences of 1 in every specific rowto range between 2 and 5. I tried:...
user avatar
  • 51
-1 votes
2 answers
243 views

Vectorized String Distance

I am looking for a way to calculate the string distance between two Pandas dataframe columns in a vectorized way. I tried distance and textdistance libraries but they require to use df.apply which is ...
user avatar
  • 121
0 votes
0 answers
10 views

Which model should I approach to classify people based on their face?

I am using shape_predictor_81_face_landmarks.dat in order to obtain facial landmarks. Here is the result: As you you can see this is the points are actually 2D numpy arrays: ...
user avatar
0 votes
0 answers
47 views

How to feed NumPy arrays directly into multi-input TensorFlow Serving prediction in Python?

I'm writing a Python script to call a running TensorFlow Serving REST API with multiple inputs (both are of shape n*50): ...
user avatar
  • 7,917
0 votes
0 answers
45 views

Can KAMA (Kaufman Adaptive Moving Average) be used for extracting the moving average of numpy arrays?

I'm reading about KAMA algorithm and everywhere I see it's just adopted for stocks and trading kind of things. Since the algorithm looks perfect so I was planning to use this for averaging out a 1D ...
user avatar
0 votes
1 answer
186 views

Trying to convert a .txt file into .npy file to split and use for train/validation/test

I have a large data set in .txt form, and was trying to split it into three for testing, validation, and training by transforming the data into a ...
user avatar
  • 23
0 votes
1 answer
539 views

"AttributeError: 'str' object has no attribute 'predict'". I am developing garbage detector model and this is the error

...
user avatar
1 vote
0 answers
18 views

Is there a reduced form of the dot product in numpy? [closed]

I am trying to find a numpy operation that gives me the scalar products between all vectors of a 2d array at index i of a 3d array and the vector at index i of a 2d array. Let me give you an example ...
user avatar
0 votes
1 answer
525 views

ValueError: Found input variables with inconsistent numbers of samples: [6, 366]

I'm trying to split my x and y into train and test data for my ML model but it's giving me this error: ...
user avatar
0 votes
1 answer
26 views

Cross Validation with One Class Classification in Python

I'm trying to do cross-validation with One Class Classification - I'm using the PyOD lib - but I don't know if I'm doing it right. The precision is too low and I'm also not able to bring up the mean ...
user avatar
0 votes
1 answer
56 views

How can I change shape of the input image array as per my trained TensorFlow model input?

I have a Tensorflow model weight file that I am using to make the prediction on test images. These test images are in NumPy array format and the shapes of the images are (720, 1280, 3). I am getting ...
user avatar
  • 3
1 vote
2 answers
55 views

I was trying to plot a 3d plot using mplt3d but i got a value error for the following code:

...
user avatar
  • 11
1 vote
0 answers
14 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 ...
user avatar
  • 11
0 votes
0 answers
105 views

Dual Optimization SVM in Python using Numpy

I need to implement the dual function of SVMs optimization problem with numpy in Python and I am pretty stuck since I am not a Python or a numpy pro at all. Dual function evaluation What I want to ...
user avatar
0 votes
1 answer
254 views

Not in index Error

xtrain is a numpy array ...
user avatar
0 votes
1 answer
119 views

How to revert np.log(data) and data.diff()?

I have used np.log(data) and then applied data.diff() to transform my data in timeseries model. I have the predictions. How do I ...
user avatar
2 votes
1 answer
32 views

Generate fake model predictions according to desired precision/recall values

Lets assume I generate a random set of target labels for a binary classification with N elements and a certain frequency of the positive class (1), e.g. 10%: ...
user avatar
0 votes
2 answers
72 views

Can I impute with median if median = 0?

I want to impute a numerical feature using the median, but the median for that feature is 0 and mean = 106. Should I go ahead and impute or is there anything else I can do? PS: I don't want to create ...
user avatar
  • 1,261
1 vote
1 answer
32 views

Merging Multidimensional Features in Python

I am trying to do 10-fold cross-validation on an audio dataset. The audio is clipped into small segments, so we have multiple clips from the same file. To avoid overfitting, each audio is assigned to ...
user avatar
0 votes
1 answer
238 views

Encoding with OrdinalEncoder: TypeError: unhashable type: 'numpy.ndarray'

I am trying to do a Random Forest in a dataset with numerical and categorical variables in order to obtain a categorical result (two possible classes, column name "predicción"). I am using ...
user avatar
1 vote
0 answers
45 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 ...
user avatar
1 vote
1 answer
137 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, ...
user avatar
0 votes
0 answers
63 views

How to compute gradient of Softmax in backward pass of a neural network?

I am trying to implement the backward pass of a Softmax layer. As an input to my backward-function, I receive the gradient from the next upper layer and I have to ...
user avatar
0 votes
0 answers
28 views

MNIST trained network tested with my own samples

I trained a Dense Neural Network with MNIST dataset in order to classify 28x28 images of numbers. Now I was trying to make it work with my own samples (I draw the image of a "7" in paint and ...
user avatar
1 vote
1 answer
48 views

When should we use jaccard score?

I am a newbie in Machine Learning, I trained a binary classifier for bank loan prediction through Logistic Regression. I measured the accuracy of it with two methods: accuracy score and jaccard index. ...
user avatar
1 vote
1 answer
179 views

Numpy array vs Pandas DataFrame when training [closed]

https://towardsdatascience.com/speed-testing-pandas-vs-numpy-ffbf80070ee7 (You can open the link in incognito if its locked). Numpy arrays are faster than DataFrame on normal mathematical operations. ...
user avatar
1 vote
0 answers
18 views

Problem with FFT in Python for smaller df

...
user avatar
1 vote
2 answers
2k views

ML : Found input variable with inconsistent numbers [closed]

I am trying an Retail ML project, but am stuck on the Error "Found input variables with inconsistent numbers of samples: [982644, 911]". I tired many thing & I know why this error occurs,...
user avatar

1
2 3 4 5
7