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
1
vote
0answers
15 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 ...
0
votes
1answer
18 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: ...
0
votes
1answer
14 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 ...
0
votes
1answer
13 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 ...
1
vote
0answers
13 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 ...
0
votes
0answers
34 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 ...
0
votes
1answer
27 views

Not in index Error

xtrain is a numpy array ...
0
votes
1answer
24 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 ...
2
votes
1answer
18 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%: ...
0
votes
2answers
64 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 ...
1
vote
1answer
22 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 ...
0
votes
1answer
70 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 ...
1
vote
0answers
22 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 ...
1
vote
1answer
56 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, ...
0
votes
0answers
29 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 ...
0
votes
0answers
19 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 ...
1
vote
1answer
24 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. ...
1
vote
1answer
79 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. ...
1
vote
0answers
16 views

Problem with FFT in Python for smaller df

...
1
vote
2answers
85 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,...
0
votes
1answer
48 views

Generate max likelyhood masks in numpy [closed]

We have several "in_arrays" like in_1=np.array([0.4,0.7,0.8,0.3]) in_2=np.array([0.9,0.8,0.6,0.4]) I need to create two outputs like ...
0
votes
1answer
15 views

Where are the predicted results located in this model?

I am new at this and am pretty sure this is a stupid question, but here it goes: Where can I see the results of a model's prediction? I did this course about deep learning, followed the tutorial, ran ...
0
votes
0answers
7 views

Invalid value encountered in double_scalars and UndefinedMetricWarning: Precision is ill-defined

This question I asked in stack overflow but didn't receive any comments yet Question Link
0
votes
0answers
28 views

Calculating all near-tangential lines for inflection points of a time series

I have been thinking about this problem for a while and I'm curious if anyone knows of a good paper on this, has any ideas for algorithms or improvements to the framework. The task is to store the ...
0
votes
0answers
33 views

Numpy-like reduction of particular dimensions in Pandas DataFrame?

With a numpy multidimensional arrays, it is easy to reduce particular axes with functions such as np.mean or np.sum. For example,...
0
votes
0answers
227 views

ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following input: RaggedTensor

I have following inputs to be trained on a CNN: x = np.array(Images) y = [ [[0]], [[76., 5., 9., 1., 0., 0.], [54., 4., 10., 51.]] ] Since the ...
0
votes
0answers
10 views

pandas reduce time for na checks (is_valid_na_for_dtype / is_na)

I have a small project that I iterate over a dataframe and do stuff with this data.. I know that if I can I should avoid iterate the rows but I'm afraid that I must so I use itertuples. Now I want to ...
0
votes
0answers
67 views

Logistic Regression Model returning same output for all inputs

I made a simple linear regression model with a simple .csv dataset that had 2 categories. For reference, the dataset looks like a larger version of this Basically, it is a hobby classification ...
1
vote
0answers
10 views

How to compute similarity matrix for strings efficiently? [duplicate]

Here I'm trying to compute similarity between 1000 cross 10000 strings (using Levenshtein distance), I'm using a dataframe approach where you just need to compare n(n-1)/2 comparisons instead of n*n. ...
0
votes
1answer
19 views

How to convert post-padded sequence to pre-padded sequence?

I have numpy array as follows: train_x = [[1,2,3,0,0], [2,5,0,0,0], [2,3,0,0,0], [0,0,0,0,0], [0,0,0,0,0,0]] Now, I would like to transform it to as shown below: <...
3
votes
2answers
2k 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: ...
3
votes
2answers
769 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 ...
0
votes
1answer
30 views

Sub-word tokenization preprocessing to use transformer

I'm stacked with executing the sub-word tokenization preprocessing to use transformer. According to the tutorial on the article, I have executed the sample code. However, one function was not defined ...
0
votes
1answer
28 views
0
votes
0answers
12 views

Model on non-iid data performing badly

I am on this lecture about non-iid data where we generated a timeseries data using the function below: ...
0
votes
0answers
22 views

How can I get dark, median-brightness and bright distribution histograms from an image?

I'm trying to replicate an augmentation technique used in this paper. This is how they explain the procedure: [...] the augmentation technique was used to adjust the histogram because the intensity ...
0
votes
1answer
14 views

How to compare error metrics for model with and without Seasonality?

I am aiming to guage the difference in my model performance from using data with and without Sesonality removal. My approach to Seasonality removal is taking the log of the column data and then ...
0
votes
0answers
28 views

How to solve incompatibility between DeepPavlov, Tensorflow and Numpy in a Python script?

I am trying to run a script in Python 3.7 that makes use of DeepPavlov and Tensorflow==2.4.1. It seems that there is an incompatibility, because: DeepPavlov can work only with Numpy==1.18 Tensorflow==...
0
votes
1answer
30 views

What is the fastest way to run predictions on a big dataset using pandas, numpy and keras?

I am a bit new to the field of data science and could really use some help. I used a natural language dictionary to train and test an ml model using keras and tensorflow. It detects the sentiments in ...
0
votes
1answer
42 views

How to group by one column and find second occurance of values greater than a threshold

The Problem I have a pandas dataframe that contains series of people, the week number that a visit occurred, and their systolic and diastolic blood pressures. ...
1
vote
0answers
10 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,...
2
votes
1answer
39 views

SGDClassifier - Why do I need to use argmax instead of argmin to find the lowest threshold satisfying given precision?

I am an experienced programmer, but new to Python and data science. I am following Aurelien Gerone's book and I don't understand one thing. I create SGDClassifier and calculate its ...
2
votes
0answers
26 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 : ...
1
vote
1answer
3k views

Big array and MemoryError: Unable to allocate memory (in Python)

I am trying to create a predictive model using linear regression with a dataset that has 157673 entries. The data (in a csv file) is in such format: ...
1
vote
0answers
452 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 ...
1
vote
1answer
63 views

Computing SVD through Eigendecomposition of correlation matrix

I am following the excellent series on SVD by Steve Brunton from the University of Washington, on YouTube, but I have trouble interpreting his 4th video on the subject. If I understand correctly, he ...
0
votes
1answer
41 views

Is it possible to implement a vectorized version of a Maxout activation function?

I want to implement an efficient and vectorized Maxout activation function using python numpy. Here is the paper in which "Maxout Network" was introduced (by Goodfellow et al). For example, ...

1
2 3 4 5
7