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
0 votes
0 answers
2k 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 ...
nmorsi's user avatar
  • 1
0 votes
1 answer
838 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 ...
nmorsi's user avatar
  • 1
0 votes
1 answer
1k 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 ...
Richard H's user avatar
  • 101
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
0 votes
1 answer
244 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 ...
Shimon Doodkin's user avatar
2 votes
1 answer
288 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
0 votes
0 answers
197 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 ...
Tan Andrew's user avatar
1 vote
1 answer
281 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...
mehant_kr's user avatar
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
2 votes
1 answer
479 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:...
I Sui's user avatar
  • 57
0 votes
2 answers
1k 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 ...
Anatole's user avatar
  • 181
1 vote
2 answers
1k 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 ...
besa's user avatar
  • 33
0 votes
1 answer
4k views

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

...
Parth Ankolikar's user avatar
1 vote
0 answers
50 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 ...
WodkaWhatElse's user avatar
0 votes
1 answer
1k 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: ...
geogeek's user avatar
0 votes
1 answer
213 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 ...
StaLLoNe_CoBRa's user avatar
0 votes
2 answers
1k 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 ...
Hitman's user avatar
  • 3
1 vote
2 answers
258 views

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

...
Dev13's user avatar
  • 11
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
0 votes
1 answer
2k views

Not in index Error

xtrain is a numpy array ...
Parth Sharma's user avatar
0 votes
1 answer
1k 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 ...
Sandhya Indurkar's user avatar
2 votes
1 answer
146 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%: ...
UnboundPrinciple's user avatar
0 votes
2 answers
163 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 ...
spectre's user avatar
  • 2,115
1 vote
1 answer
93 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 ...
rise of a phoenix's user avatar
0 votes
1 answer
717 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 ...
Jose Cle's user avatar
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
642 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
2 answers
397 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. ...
Shaurya Singh's user avatar
1 vote
1 answer
715 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. ...
Ayazzia01's user avatar
  • 103
1 vote
0 answers
18 views

Problem with FFT in Python for smaller df

...
Subhadip Saha's user avatar
2 votes
2 answers
10k 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,...
Parikshit Bharadwaj's user avatar
0 votes
1 answer
53 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 ...
sixtytrees's user avatar
0 votes
1 answer
25 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 ...
Thiago Rocha's user avatar
0 votes
0 answers
94 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,...
Trisoloriansunscreen's user avatar
0 votes
0 answers
1k 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 ...
Saravanakumar Gopalakrishnan's user avatar
0 votes
0 answers
99 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 ...
Adit Magotra's user avatar
1 vote
0 answers
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. ...
David Gladson's user avatar
0 votes
1 answer
29 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: <...
Abc1729's user avatar
  • 15
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
3 votes
2 answers
889 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
0 votes
1 answer
90 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 ...
user avatar
0 votes
1 answer
461 views

Calculating accuracy score of isolation forest model returning error

My code is as follows: ...
Niko's user avatar
  • 1
0 votes
0 answers
44 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 ...
Juan Pablo S. G.'s user avatar
0 votes
1 answer
23 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 ...
frantic oreo's user avatar
1 vote
1 answer
227 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 ...
Glad's user avatar
  • 111
0 votes
1 answer
659 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. ...
RLB's user avatar
  • 23
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
2 votes
1 answer
238 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 ...
Michał Powłoka'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
1 vote
2 answers
31k 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 157,673 entries. The data (in a csv file) is in such format: ...
Zerox's user avatar
  • 111

1
2
3 4 5
8