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
1 vote
1 answer
98 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. ...
Phagocytosis's user avatar
4 votes
3 answers
7k 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 ...
Myles Collier's user avatar
-1 votes
1 answer
6k views

Attribute Error: 'numpy.ndarray' object has no attribute 'transform' [closed]

...
Manan Nawal's user avatar
3 votes
1 answer
8k 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 the line and slope of the curve? Is it valid to use numpy.gradient to find the slope of the line and slope of the curve at ...
star's user avatar
  • 1,481
2 votes
1 answer
14k 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 ...
star's user avatar
  • 1,481
2 votes
1 answer
875 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 ...
brohjoe's user avatar
  • 135
3 votes
1 answer
160 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 ...
Blg Khalil's user avatar
-1 votes
1 answer
37 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) ...
Giselle's user avatar
0 votes
1 answer
72 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 ...
heresthebuzz's user avatar
0 votes
1 answer
73 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.
Sriswaroop Koundinya's user avatar
0 votes
1 answer
3k 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 ...
Felipe Oliveira's user avatar
1 vote
0 answers
48 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 ...
Donald S's user avatar
  • 1,959
2 votes
0 answers
2k 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\...
adriankroeger's user avatar
0 votes
1 answer
433 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 ...
Debashis Paul's user avatar
2 votes
1 answer
2k 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 of ...
teddcp's user avatar
  • 165
0 votes
2 answers
829 views

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

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: ...
Debashis Paul's user avatar
1 vote
1 answer
8k 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 (...
Olivier123's user avatar
0 votes
1 answer
116 views

Implementing single variable Linear Regression in python

I'm trying to implement LMS algorithm in python. I have the following code: ...
Omri Shneor's user avatar
0 votes
1 answer
2k 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 ...
Nanoboss's user avatar
  • 103
0 votes
0 answers
489 views

How to run list comprehensions on GPU?

Is there a way to run complex list comprehensions like the following on GPU? ...
Ishmael89's user avatar
1 vote
0 answers
21 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 ...
Py-ser's user avatar
  • 111
-1 votes
1 answer
3k 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. ...
Monil's user avatar
  • 1
0 votes
1 answer
96 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 <...
Thembekile Mkhombo's user avatar
0 votes
1 answer
625 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 ...
user582621's user avatar
1 vote
2 answers
454 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 ...
Thembekile Mkhombo's user avatar
1 vote
0 answers
58 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: ...
marco's user avatar
  • 11
1 vote
1 answer
499 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 ...
boredaf's user avatar
  • 161
1 vote
1 answer
420 views

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

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 ...
Ramy Saad's user avatar
1 vote
1 answer
1k 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 ...
Eka's user avatar
  • 301
1 vote
1 answer
44 views

Why does averaging over vector values cause errors?

As a way to improve my model, I want to average GloVe vectors over a sentence. However, I can't get np.mean to work. The following code works when not averaging over words. (copied from other code) <...
Krijn's user avatar
  • 135
0 votes
1 answer
248 views

Getting the leave-one-out error on least square regression to fit polynomials

I need to implement least square regression to fit polynomials of degree 1-27. I then need to get the leave-one-out error (kfold cross validation where k = n). After doing a lot of research it seems ...
Matthew Spahr's user avatar
-1 votes
1 answer
165 views

Error in numpy array assignment

I'm trying to upload 17 images into a 4d numpy array, each image size is (256,256,1), so basically I'm using the 0th dimension for collection of different images. Following is my code: ...
DiamondDust's user avatar
0 votes
2 answers
69 views

Replace Values with corresponding numbers in the same dataframe

Please help me to replace NR values with corresponding values as in the dataframe.
phani437's user avatar
0 votes
1 answer
361 views

Neural network does not work on XOR

So, I am trying to implement a neural network in Python by only using NumPy. I have tried to do this by following 3Blue1Brown's video's about the topic, however, when testing my implementation, the ...
KeenBit's user avatar
  • 11
2 votes
1 answer
1k views

Assign a unique cluster based on a dataframe column with KMeans Algorithm [closed]

I have the following df ...
Andrea Ciufo's user avatar
1 vote
0 answers
145 views

Stratified K fold same index present in both test and valid set

I am trying to do a stratified k fold cross validation for my dataset and want to keep an isolated 10% test set from the dataset and use the remaining for training and validation. Below is the code ...
Arjun's user avatar
  • 23
1 vote
1 answer
303 views

Random Parameters to fix in ML to perform controlled experiments

Many algorithms and methods in modern Machine Learning techniques contain randomness, and because of that, running the same ML script several times can result in different outputs, therefore accuracy ...
meliksahturker's user avatar
3 votes
1 answer
234 views

tensorflow pseudo inverse doesn't work for complex matrices!

The Tensorflow documentation here says that: tf.linalg.pinv is ''analogous to numpy.linalg.pinv. It differs only in default value of rcond''. However, tf.linalg.pinv requires the matrix to ...
eMichel's user avatar
  • 33
3 votes
0 answers
2k views

How to apply a groupby rolling function to create multiple columns in the dataframe

I am setting up a volume profile series over a stock data. I have implemented the market profile code from this github repo and the link to the data is here and the example here. Some Sample of data ...
Scrappy Coco's user avatar
2 votes
1 answer
6k views

Combine 100 2D arrays into one 3D array

I have 100 2D lists a0 to a99, it is easy to convert them into arrays (I verified already): ...
TJCLK's user avatar
  • 291
2 votes
2 answers
2k views

Ways to simulate weather data over several periods (Python or R)?

I have a time series dataset that has several variables for a state/province for fixed periods of time. That is for state A, there are samples from April 2017 to July 2019. Of course, I thought adding ...
Shiv_90's user avatar
  • 265
1 vote
1 answer
284 views

Implementing "full convolution" to find gradient w.r.t the convolution layer inputs

I've been trying to implement "full convolution" w.r.t to convolution layer inputs. According to this article, it looks like this: So, I wrote this function: ...
Jim's user avatar
  • 125
7 votes
4 answers
4k views

Convert Numpy array with 'n' and 'y' into integer array of 0 and 1

I have a NumPy array of strings: 'n', 'y', wanna convert it into integer array of 0, 1, how to convert it? ...
JL1829's user avatar
  • 81
2 votes
1 answer
75 views

Machine learning dataframe dimension concept vs NumPy dimension

From Machine Learning for Absolute Beginners: A Plain English Introduction: Contained in each column is a feature. A feature is also known as variable, a dimension or an attribute - but they all ...
vasili111's user avatar
  • 157
-1 votes
1 answer
1k views

NumPy -- ImportError: PyInit__multiarray_umath [closed]

I'm facing the below error while importing NumPy library. I have tried all of the suggestions advised by Python in its error log, but no luck. Strangely, when I use Python's OS library and print the "...
ranit.b's user avatar
  • 451
1 vote
1 answer
230 views

Pandas dataframe with multiple observations per model

I currently have a pandas dataframe with the following format ...
Joost vd Putten's user avatar
0 votes
1 answer
1k views

Trouble in calculating the covariance matrix

I'm trying to calculate the covariance matrix for a dummy dataset using the following formula, but it's not matching with the actual result. Let's say the dummy dataset contains three features, #...
Bitswazsky's user avatar
1 vote
0 answers
41 views

How to do Back Propagation Updation for below code?

Below is the code by Siraj Raval for implementing Neural Networks from Scratch. I have some doubts regarding the Code: Why during updation he did W2 = W2 + L1.T.dot(L2_Delta). I Mean shouldn't it be ...
Gopal's user avatar
  • 31
2 votes
1 answer
77 views

How should I improve my Vectorized Gradient descent linear regression model?

I wrote a vectorized Gradient descent implementation of the linear regression model. The Dataset looks something like: It's Not Working properly as I am getting negative R Squared error I don't ...
Gopal's user avatar
  • 31
0 votes
0 answers
38 views

How the Pandas Dataframe and Numpy masking technique works

I'm trying to understand how the masking technique works. I've a dataframe with some values (say one_row_incidents) some of the are not unique. By grouping them .by the duplicate index, I can get the ...
Andrea Moro's user avatar

1 2 3
4
5
8