# Questions tagged [numpy]

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

248 questions
Filter by
Sorted by
Tagged with
12 views

### getting Index Error while accessing numpy array values using slicing [closed]

import numpy as np demo_matrix=np.array(([13,35.74,48],[23,37,37,38],[73,39,93,39])) demo_matrix[2,3] I'm getting Index Error when I tried to run this code. Can ...
9 views

### ValueError: output_type='binary', but y.shape = (30, 3)

I have a custom estimator that i implemented myself and i am not able to use cross_val_score(), which i believe it has something to do with my ...
40 views

### How to smooth data in given array

I have an input array like this: a = [4, 4, 4, 4, 4, 4, 4, 0, 5, 5, 4, 4, 4, 5, 5, 5, 4, 0, 4, 4, 0, 0, 0, 0, 0, 0] I need to remove outlier values that makes ...
56 views

### How can I determine the relationship between spam and weekdays?

I am trying to check if there is a correlation between spam emails and weekdays. My dataset looks like as follows: ...
23 views

### How to limit a function's cosine value as it approaches 0 [closed]

How do I get a cosine to peak up to a certain value as it hits 0? With the above code, the y-value peaks to infinity as it approaches 0. ...
34 views

### Numpy array value error

This is my code to train a sigmoid neuron for Iris dataset . ...
25 views

### Logistic Regression from scratch in numpy - Is data normalization needed?

I was trying to implement Logistic Regression from scratch in python to learn better how it works under the hood. In particular I am following this video tutorial from Andrew Ng. This is the dataset I ...
25 views

23 views

### Efficient Dataframe Transformation

So I'm trying to transform a pandas dataframe where I have multiple duplicates of a "user" value (my index being a user ID number), demographic info (which shouldn't change) and various purchase ...
34 views

### ReLU/Sigmoid Backpropagation Implementation

I've written a 2 layer Neural Network in Python for binary classification. The first layer uses ReLU activation, and the output layer is sigmoid activation. I'm using cross entropy to calculate loss. ...
36 views

### find monthly climatology for a particular month

I have a 10-year sst monthly data. I want to plot the interannual monthly climatology for the month of October. By using the code I have for python with me I am able to plot the interannual monthly ...
465 views

### Python Numpy: TypeError ufunc 'isfinite' not supported for the input types

I'm new to data science, I'm using to ARIMA to analysis the time-series data of energy production. i'm following this tutorial. my code after few tweaks is: ...
56 views

### value error of incompatible wrong dimension during training a model

i was implementing a decision tree on a dataset. Before that i wanted to transform a particular column with CountVectorizer. For this, i am using pipeline to make it simpler. But there is an error ...
6 views

### spatially constrained multivariate clustering for demographics

What's the current methodology for clustering geospatial data by features? Example: I have some demographic dataset. Let's say this contains average home price and population density. So, an example ...
62 views

### How to find the average over an area of center for a given radius

folks, I have an excel file which contains the lat and long values of the center of a Tropical Cyclone(TC). The excel file is as given below: Also, I have an NC(NetCDF) file which is of that of ...
134 views

### Set value of a column based on values of other columns (Pandas)

The last time I used Python is some time ago so some things have faded away. I have a given dataset, with multiple columns. I want to create a new column and set the values based on multiple values (...
35 views

### Implementing single variable Linear Regression in python

I'm trying to implement LMS algorithm in python. I have the following code: ...
6 views

I have written a dataloader for segmentation pipeline. The dataloader loads images and segmentation masks perfectly but the dataloader execution never stops such as it keeps running forever. My code ...
10 views

### How to use “transposing” for more efficient list comprehensions?

How can I use transposing to execute operations faster, than i currently do in list comprehensions, like: ...
20 views

### Laplacian Matrix Has Negative Eigenvalues

I am trying to implement a simple version of spectral clustering using the normalized (random walk) Laplacian matrix in Python. After testing my function with a toy dataset, I found that my Laplacian ...
225 views

### Trying to understand the result provided by np.linalg.norm function in numpy (normalisation)

I'm new to data science with a moderate math background. I'm playing around with numpy and can across the following: So after reading np.linalg.norm, to my ...
30 views

### How to run list comprehensions on GPU?

Is there a way to run complex list comprehensions like the following on GPU? ...
17 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 ...
229 views

### Matplotlib Bar graph -ValueError: shape mismatch:(x,y)

While plotting the bar graph for number of attempt on x-aixs and time-taken on y-axis as per below code, getting Value error.Trace of error is included below. ...
17 views

### Why is my LSTM, stateful network getting 0 accuracy

I'm building a NN to predict stock prices but I'm getting an accuracy of 0, I really don't know what hyper parameters to play with anymore but it seems to always get this accuracy Build LSTM model <...
16 views

### Numpy ndarray holding string with unknown data type

I ran the following code in a jupyter notebook cell ndarrs=np.array(["1.2","1.5","1.6"], dtype=np.string_) print(ndarrs.dtype) It returned ...
67 views

### How to perform a Post Hoc Chi-square Test of Independence with more than two categories in the two variables, on python (pandas)?

I am new to data science and I am exploring a data set. Doing this I stumbled on a problem that I can't find the solution online. So, I need your help. The dataframe is the following: ...
28 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 ...
10 views

### averaging non-aligned vectors or lists of numbers

I have two lists of vectors: x, and y. Each x,y vector forms a function that can be plotted (see figure). The values in x do not all match, which you can see from the plot. Also, each x vector may ...
17 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: ...
67 views

### np.loadtxt function showing error, could not convert string to float

This is my data file : I am trying to read this file with loadtxt() and the geometry points get loaded into one NumPy array, so I separate the data into two arrays:...
60 views

### fastai - using 'untar_data' function in kaggle kernel

I have recently started with fastai lesson 1 and I am using kaggle to run the course notebooks. While going through the ‘lesson1-pets’ notebook we use ...
59 views

### Building a gradient descent linear regression model from scratch on Python

I am trying to build a liner regression model using batch gradient descent to minimize the cost function. However, I am clearly doing something wrong because when I try to plot my cost history after ...
77 views

### Convert a pandas df with text to embedding matrix efficiently

What is the most efficient way of converting a pandas data frame with approx 5 000 000 rows, where there exists short texts in one of the columns to an embedding matrix? I am using the HuggingFace ...