Questions tagged [numpy]

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

Filter by
Sorted by
Tagged with
-3
votes
1answer
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 ...
0
votes
0answers
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 ...
0
votes
0answers
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 ...
3
votes
2answers
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: ...
0
votes
1answer
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. ...
0
votes
0answers
34 views

Numpy array value error

This is my code to train a sigmoid neuron for Iris dataset . ...
1
vote
1answer
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 ...
-1
votes
1answer
25 views

Matrix of pairwise cosine similarities from matrix of vectors [closed]

I have a matrix of 200d vectors stored as follows: $ X = \begin{pmatrix} \text{id}_1 & 0.5 & -2 & \dots & 10 \\ \text{id}_2 & -4 & 6 & \dots & -0.3 ...
1
vote
1answer
21 views

Why can't I specify the correct NumPy size? [closed]

In the network (model of Keras, Sequential), the input layer must have 4 neurons. The input must be 1 list, the length of which is 4, each element is a number. ...
1
vote
3answers
121 views

Count the max number of consecutive 1 and 0 in Pandas Dataframe [closed]

Hey I have the following Dataset import pandas as pd df = pd.DataFrame({ 'column1': [0,0,1,0,1,0,0,1,1,0,1,1,1]}) I want to be able to count the number of ...
1
vote
1answer
27 views

Is it valid to use numpy.gradient to find slope of line as well as slope of curve at any point?

what is the difference between slope of line and slope of curve ? Is it valid to use numpy.gradient to find slope of line and slope of curve at any point ? ...
1
vote
1answer
23 views

How to find slope of curve at certain points

how to find slope at certain points circled in blue in below curve ? Are these below 2 approaches valid ? though they give different results . How to automatically find the points where the slope ...
2
votes
1answer
157 views

How can I count the number of matching zero elements between two numpy arrays?

I have a function that returns the predicted accuracy of a time-series model. I have two equally-sized numpy arrays, one for the actual direction and one for the predicted direction. I'm classifying ...
0
votes
0answers
15 views

Transfer learning by using vgg in pytorch

I am using vgg16 for image classification. I want to test my transfered model with the following code: ...
3
votes
1answer
37 views

Expectation Maximization Algorithm (EM) for Gaussian Mixture Models (GMMs)

I'm trying to apply the Expectation Maximization algorithm (EM) to a Gaussian Mixture Model (GMM) using Python and NumPy. The PDF document I am basing my implementation on can be found here. Below are ...
-1
votes
1answer
21 views

How can I reshape this array?

I have few difficulties in picking values from an array. Here is a simplified version of the concerned part of the code. (If you would like to put the whole code please mention it) ...
0
votes
1answer
19 views

Transform large pd.Series into a DataFrame of n columns

I have a pd.Series with, for instance, n lines. I would like to transform this series in a ...
0
votes
1answer
18 views

What is the use of the np.ndarray() function and how is it used?

I just started Data Science and I want to know what the np.ndarray() function's use is, and in which scenario(s) it is used in. Thanks for the help.
-1
votes
1answer
26 views

How do I view my K features with SelectKBest? [closed]

I am getting an error for "no attribute columns". Because of this, I can't see the selected K features and can't build plots: First occurrence of error: Second occurrence of error: I'm also ...
1
vote
0answers
21 views

pandas memory issues

What are some good "best practices" for dealing with large datasets in pandas and numpy? Typically i read data from csv files and use numpy and pandas to prepare them for machine learning and AI ...
1
vote
0answers
153 views

Iterative Reweighted Least Squares in python

I am trying to manually implement the irls logistic regression (Chapter 4.3.3 in Bishop - Pattern Recognition And Machine Learning) in python. For updating the weights, I am using $w' = w-(\Phi^TR\...
0
votes
1answer
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 ...
0
votes
0answers
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. ...
0
votes
1answer
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 ...
0
votes
0answers
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: ...
0
votes
1answer
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 ...
0
votes
0answers
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 ...
0
votes
2answers
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 ...
1
vote
1answer
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 (...
0
votes
1answer
35 views

Implementing single variable Linear Regression in python

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

Segmentation DataLoader Not Stopping

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 ...
0
votes
0answers
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: ...
0
votes
0answers
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 ...
0
votes
1answer
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 ...
0
votes
0answers
30 views

How to run list comprehensions on GPU?

Is there a way to run complex list comprehensions like the following on GPU? ...
1
vote
0answers
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 ...
-1
votes
1answer
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. ...
0
votes
1answer
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 <...
0
votes
1answer
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 ...
0
votes
0answers
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: ...
0
votes
2answers
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 ...
0
votes
0answers
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 ...
0
votes
0answers
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: ...
0
votes
0answers
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:...
0
votes
1answer
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 ...
0
votes
0answers
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 ...
0
votes
0answers
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 ...
0
votes
0answers
7 views

How to find average lag time with variance & confidence of two variables

I have two variables as time series, one a consequent of the other, I would like to find the average time delay it takes the dependent variable to act on the independent variable. Additionally, I ...
1
vote
1answer
87 views

How to code a simple forward propagation of recurrent neural networks?

I know the theory behind recurrent neural networks or RNN but I am confused about its implementation. This is an rnn equation I got from the web, I tried to code the forward propagation alone in ...

1
2 3 4 5