Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [numpy]

NumPy is a scientific and numerical computing extension to the Python programming language.

0
votes
0answers
13 views

Saving multiple numpy arrays to multiple image files

I have some CSV data that I have extracted in chunks of 375. Since I have 20 columns of data (7500 elements total), I have then reshaped these chunks into an image in the form of (3,50,50) to ...
0
votes
1answer
18 views

Decovolution function

I have an image (for example (7x7x3) and a filter (3x3x3)). I convolved the image with the filter and it became a (3x3) output. If I want to do the inverse operation and want it to become the image ...
2
votes
1answer
41 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, ...
1
vote
1answer
36 views

What kind of algorithm should I choose for this music classification system?

I have in mind a program for analyzing short fragments of music, categorizing them as "good" or "bad". This would be part of a larger program that searches for larger good phrases and whole pieces. ...
1
vote
1answer
30 views

How to “reshape” into square matrix for numpy.linalg.solve()?

I'm trying to find the intersection of lines $y=a_1x+b_1$ and $y=a_2x+b_2$ using numpy.linalg.solve(). What I can't get my head around is how to correctly make $A$ ...
0
votes
1answer
20 views

implementing conv2d in fourier domain using np.einsum --> ValueError: einstein sum subscripts string contains too many subscripts for operand 0

According to the convolution theorem, convolution operation changes to pointwise multiplication in fourier domain - here I have 'fft_x' of shape (batchsize, height, width, in_channels) which is the ...
4
votes
2answers
61 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 &...
0
votes
1answer
29 views

Machine learning with sklearn vs. scipy stats

I've created 50 random x and y points (with slope of y = 2x-1). First, I used Linear Regression from sklearn to fit the model onto my dataset where I got a slope of ...
0
votes
0answers
30 views

Convolution and Deconvolution Image with Filter

I tried deconvolving the result of the convolution of an image 100x100x3 (hight, width, number of channels) with filter 3x3x3x5 (filter hight, filter width, number of channels, number of filters) then ...
1
vote
0answers
31 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 ...
0
votes
1answer
30 views

Having difficult interpreting the eigenvectors for a simple 3x2 matrix

I calculated the eigenvectors and eigenvalues from a covariance matrix given a data matrix of 3 columns and 2 rows. I am trying to interpret results but I can't understand on how to interpret them. ...
1
vote
1answer
67 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], [...
0
votes
1answer
41 views

How to create new feature based on clustering result

I'm still a beginner in machine learning and I want to know how to code this situation based on python and machine learning (clustering). I have data like: ...
0
votes
1answer
51 views

Keras exception: Error when checking input: expected dense_input to have shape (2,) but got array with shape (1,)

I have an understanding of this error, it means that the input that I'm passing to the model is of a different dimension that what was expected. The error also states that the input that I'm passing ...
0
votes
0answers
29 views

Error in Calculating the z Score for Normality Detection using numpy and scipy

Calculate the z Score for the Normal pdf plot I am not getting the correct values for the z score. For example, the z score for 0.025 comes out as -1.64750894. In the Normal Distribution Table, the ...
0
votes
1answer
41 views

How to get a dataframe values in one single column for the following dataset?

m38 m78 alpha 4.4717 4.8745 4.4569 4.6491 4.5101 4.7262 4.4407 4.8234 4.1184 4.3862 3.8448 4.2816 3.7246 4.6183 3.2857 4.6744 For the above sample data (actually 8000 rows) i ...
1
vote
1answer
45 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)...
2
votes
1answer
37 views

Fast way of computing covariance matrix of nonstationary kernel in Python

Suppose I have symmetric positive definite covariance function $k:\mathbb{R}\times\mathbb{R}\rightarrow \mathbb{R}$ that is non-stationary (i.e. $k(x,y) \neq g(|x-y|)$ for any function $g$). Is there ...
1
vote
2answers
63 views

How can I find similarities in two graphs?

Let's say that I have two 1 dimensional arrays, and when I plot the two arrays they look like this: If you look at the top and bottom graphs, then you can see that the highlighted parts are very ...
1
vote
0answers
15 views

How to do non arithmetic operation in python 3 [closed]

lets say a=3 b=4 and c is an unknown constant. a=3 b=4 F=0 F=a*b*c print(F) Its an error. I want 12*c or 12c
2
votes
1answer
87 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: ...
2
votes
2answers
55 views

MAE,MSE and MAPE aren't comparable?

I'm a newbie in data science. I'm working on a regression problem. I'm getting 2.5 MAPE. 400 MAE 437000 MSE. As my MAPE is quite low but why I'm getting high MSE and MAE? This is the link to my data ...
1
vote
0answers
43 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. ...
0
votes
1answer
18 views

Sequence to sequence RNN model, maximum number of training size

So when running this example script from Keras repo (https://github.com/keras-team/keras/blob/master/examples/lstm_seq2seq.py), I found that we can easily run into out of memory for the input or ...
1
vote
2answers
132 views

Numpy array from pandas dataframe

I am new in using python for data science. What is the difference between selecting a a column with: df['name'].values and ...
2
votes
1answer
53 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
0
votes
1answer
20 views

Faster 3D Matrix Operation - Python

I am working with 3D matrix in Python, for example, given matrix like this with size of 2x3x4: ...
0
votes
0answers
37 views

Numpy Python deep learning framework

Does there exist a deep learning framework that is implemented only in Python and Numpy and supports 2D convolution, concatenation, ReLU activation function, max pooling, and global average pooling? ...
1
vote
0answers
234 views

IQR Score outliers detection in Python [closed]

I have a large dataset "train" incl. a column ClientFreeSource from which I want to exclude an outliers. For that purpose I decide to use IQR score. I've tried: ...
0
votes
0answers
81 views

How to create a complex Gaussian random noise with a specific covariance matrix

I am trying to generate a complex Gaussian white noise, with zero mean and the covariance matrix of them is going to be a specific matrix which is assumed to be given. Assume i to be a point on the ...
0
votes
0answers
11 views

Spatially encoding textual data

Imagine we have a textual data that must be passed to convolutional neural network. Generally we know that for natural language processing, textual data is embedded into vector space, but in this ...
0
votes
1answer
41 views

Machine Learning library in Python, list or numpy or pandas

Background: We are trying to build a customized ML library in Python 3 to tackle analysis we often repeat, in a general fashion. But it would not be nearly as general as ...
1
vote
3answers
42 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 ...
1
vote
0answers
36 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 ...
2
votes
2answers
69 views

Running out of memory while processing csv file data

I'm getting an error while processing 0.2 million of text data. I'm using CNN text classification in tensorflow. Output raw data shape is 204177x22000. while passing to numpy.array(out_raw), here it ...
1
vote
0answers
35 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([...
1
vote
1answer
41 views

How to make a numpy ndarray from several numpy arrays

I am not to figure out how to form a ndarray from existing numpy arrays. Suppose I have three arrays - index, distA, and distB. ...
0
votes
1answer
34 views

LSTM : Bad Data or Low preparation

I have three features {feature1, feature2, feature3} the middle have negative sign for some values and i am trying to predict the middle one using LSTM with window size of 10 but i get very high RMS ...
2
votes
0answers
15 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 ...
0
votes
0answers
13 views

Efficient Similarity Indexing and Searching in High Dimensions

I found this recent document, containing simple algorithm that properly indexes high dimensional vectors for binary search later. Algorithm basically uses random partition forest that randomly ...
3
votes
1answer
154 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 ...
0
votes
1answer
190 views

keras Sequential CNN for image data reshaping data issues

I am new at keras and CNN and am working on building at CNN for sequential analysis of movement in a image. What I am having issues with is the reshaping the data and the labels that go into the ...
1
vote
1answer
121 views

How to save a Numpy array output of an autoencoder as an image [closed]

I have a 256*256*3 numpy array "SP" out of an autoencoder decoder layer which I want to save and open as an .jpg image. I used something like the following python code snippets: ...
1
vote
0answers
374 views

The truth value of an array with more than one element is ambiguous

I was trying to print the index of each of the maximum probability of the probability Array, While Executing the following code I get the error " The truth value of an array with more than one ...
0
votes
1answer
51 views

Why my perceptron doesn't train well and produces bad results on test data?

I am a newbie in Machine learning and I am writing a small code for Perceptron. This is the first time I am writing code in Python. I have four training data points (X). As they are used for ...
1
vote
1answer
6k views

TypeError: unhashable type: 'numpy.ndarray' [closed]

I'm trying to do a majority voting of the predictions of two deep learning models.The shape of both y_pred and vgg16_y_pred are (200,1) and type 'int64'. ...
0
votes
1answer
263 views

pandas: How to impute the categorical column by the nearest neighbors?

I've a categorical column with values such as right('r'), left('l') and straight('s'). I expect these to have a continuum periods in the data and want to impute nans with the most plausible value in ...
-1
votes
2answers
118 views

how to transformation of row to column and column to row in python pandas? [closed]

I have a large dataset I want to transform this dataset into this format I have try it through transpose but i couldn't figure out
2
votes
1answer
166 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)?
4
votes
2answers
8k views

Normalize matrix in Python numpy

I've an array like this: ...