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 votes
0 answers
8 views

Filtering or Querying Pandas MultiIndex Dataframe based on column values

I have a multi-index pandas DataFrame such as below, primarily indexed with DateTime object. ...
1 vote
1 answer
32 views

Using python AI mnist to recognize my picture, trained accuracy is 97.99%, but accuracy to my img is less than 20%

Questions like these are difficult to debug, but you'll hopefully find more help on datascience.stackexchange.com than here I see the suggestion that post in Data science is also a good option Using ...
  • 11
0 votes
0 answers
44 views

Binary classification works with softmax, but not sigmoid

I am doing a binary classification problem for seizure classification. I split the data into Training, Validation and Test with the following sizes and shapes dataset_X = ...
0 votes
1 answer
26 views

Error using sigmoid activation function in the last dense layer of a LSTN

Trying to use sigmoid as an activation function for the last dense layer of a LSTN, I get this error ...
0 votes
0 answers
13 views

a model to predict a day from other days?

I have the day of the month of 100 purchases made by a customer. Is it reasonable to use linear regression to predict the day of the month of purchase 101? Or what kind of algorithm should I use? How ...
0 votes
0 answers
13 views

Warning for input shape in LSTM model

I have timeseries data of electricity consumption per hour with length (17544, 1) in the following format: ...
  • 101
0 votes
1 answer
20 views

How can i get this way to create random data?

I need to create random data using this lines ...
1 vote
1 answer
36 views

Is it advisable to save an ML model as a Joblib/Pickle file?

Part of our thesis project is to create a Diabetes predictor web application, and I have something I like to clarify. Is it a common practice to save an ML model as a Joblib/Pickle file like this one? ...
0 votes
0 answers
41 views

Creating a scatter plot with matplotlib with large dataset

I am trying to create a scatter plot from instrument peak area data recorded every tenth of a second or so. For some reason, when I try to plot it with Matplotlib, I get a straight line, which is not ...
0 votes
0 answers
14 views

Generating image from MNIST Data

I am quite new to python and pytorch. Please review my code below. I have tried everything I know but I am not able to create a MNIST data set image out of the matrix below. I expect the image should ...
  • 1
0 votes
1 answer
34 views

How to convert Torchvision image tensor to base64 directly?

I have this code that is supposed to convert an image entry of a Torchvision dataset to a base64 string. To do that, it serializes the tensor from a Torchvision dataset to a string, modifies that ...
  • 111
0 votes
1 answer
35 views

How to convert postgresql tabular data to a numpy array?

I'm completely new to data science and I have a problem that I need help in resolving. I have time series data (with 87 million rows currently, though that will grow) with x, y coordinates, a ...
  • 101
0 votes
1 answer
21 views

Why normalized eigen values and eigen vectors can have imaginary number?

My goal is to prove why normalized eigen values and eigen vectors have imaginary number. According to this website: normalized eigen vector is just ...
0 votes
0 answers
13 views

Creating a prediction matrix for kernel regression in numpy

I need to create a rectangular matrix from timeseries data which is T time bins by L, the sum of the length of the set of events of interest occurring in the timeseries within certain times referred ...
0 votes
0 answers
107 views

Data type conversion as part of sklearn pipeline

I'm currently learning and implementing sklearn pipelines. As an early step in the pipeline, I want to convert some data types that are wrong from the import (primarily object to numerical and object ...
0 votes
0 answers
49 views

Applyingv a 2D mask onto a 3D rgb color list

Problem I have the following image data as a 3D numpy array containing rgb values of the image in a (n,n,3) shaped list (Image). I also have data of the corresponding black and white mask image in a (...
0 votes
0 answers
643 views

y_true takes value in {} and pos_label is not specified: either make y_true take value in {0, 1} or {-1, 1} or pass pos_label explicitly

I want to run "4_forgery_detection_result.ipynb" from an available code. In this cell of the code, ...
  • 1
0 votes
0 answers
19 views

Extracting meaningful information from time series data in python

The following graph shows the data (Top: Time domain ; Bottom: Frequency domain). The meaningful data in my context is the one marked by red lines. How can I extract only the meaningful data from the ...
  • 103
0 votes
0 answers
135 views

Overflow encountered in matmul while doing forward propagation

I wrote this code to do forward propagation ...
0 votes
0 answers
11 views

How to vectorize for loops with shift in time?

I am writing a program that simulates the process of ordering goods for stock. In the code below, arrival is a two-dimentional array that represents the stock that arrives at the customer on day t for ...
  • 101
1 vote
0 answers
268 views

logistic regression,machine learning

I just started learning ML, so I tried to implement logistic regression on my own in 2 ways (the first code and the second code), but they aren't working, I cross-checked by using sklearn (third code ...
0 votes
0 answers
29 views

Does the result of scipy.stats.f_oneway and sklearn.feature_selection.f_classif should be equal?

I thought that the results of both functions would be the same, but: ...
  • 1
1 vote
1 answer
70 views

Creating a grid type 3D data array from data points [closed]

I have a 3 data column $(X, Y, Z)$ ranges from $(min, max)$. For example, $X = (0, 5)$, $Y=(0, 3)$, $Z=(0, 2)$. By using them I need to create a numpy array in the form of $[(0, 0, 0), (0, 0, 1), (0, ...
  • 123
0 votes
0 answers
16 views

its posible to reshape a 1 dim with 30 values to a 2 dim (6, 5) with numpy?

I'm working with tensorflow. The run function next_state = np.reshape(next_state, [1, [self.state]) returns ValueError: Cant reshape array of size 30 into shape (...
0 votes
0 answers
10 views

Proper datashape and model architecture for recognizing highs and lows in a chart

I am using a Keras LSTM model to try to pinpoint the highs and lows (relative high points and low points) in a chart (I need the actual coordinates to those highs and lows, not just an image). The ...
  • 101
0 votes
0 answers
5 views

Identifing this dataset for sanitising

I am beginner here starting with data science for analytics. I am trying to figure out what data set this is and how to read it from python. I have an idea of the steps but not sure how to code it in ...
  • 1
-1 votes
2 answers
141 views

unable to pass X_train and y_train in my regressor variable. i got a ValueError

...
0 votes
0 answers
22 views

Slice NumPy arrays differently along axes (without looping)

I am trying to analyze a temporal signal sampled by a 2D sensor. Effectively, this means integrating the signal values for each sensor pixel (array row/column coordinate) at the times each pixel is ...
0 votes
0 answers
713 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 ...
  • 1
0 votes
0 answers
154 views

OpenCV warpAffine error during image augmentation using Albumentations

I have been trying to do image augmentation using a library called Albumentations. But I got some error from OpenCV while transforming the images. I ran the code below on Kaggle's notebook. The ...
  • 1
0 votes
1 answer
245 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 ...
  • 1
0 votes
1 answer
443 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 ...
  • 101
1 vote
1 answer
28 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 ...
  • 11
0 votes
1 answer
35 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 ...
0 votes
0 answers
158 views

How to sample a dataframe or numpy array with a particular interval?

I have the following dataframe : ...
  • 1
0 votes
0 answers
87 views

How to load several numpys in batch generator from directory

I have a deep learning model which has to be feed with a huge amount of data (200k of 256x256 images), so it runs out of memory. I have divided my data in several numpy arrays that are in an specified ...
2 votes
1 answer
80 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') - ...
0 votes
0 answers
103 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 ...
0 votes
0 answers
28 views

Pandas Dataframe Filtering based on rows

I have a dataset like this: ...
  • 1
0 votes
1 answer
94 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...
0 votes
0 answers
339 views

Add an empty row in dataframe with condition using python

i have this 2 datafram and when i compare this 2 datafram i want to add an empty row where the row is in the first one and is not in the second i write this code but is not working for the empty row <...
0 votes
0 answers
13 views

Create dataset from 3d batches of feature maps for classification model

I am trying to create dataset of batches of several volumetric features and labels. It's a nifti volumes with extracted features from brain. I am trying to create a pair of feature X and labels y for ...
1 vote
0 answers
26 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: ...
  • 111
2 votes
1 answer
91 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:...
  • 51
-1 votes
2 answers
643 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 ...
  • 161
0 votes
0 answers
17 views

Which model should I approach to classify people based on their face?

I am using shape_predictor_81_face_landmarks.dat in order to obtain facial landmarks. Here is the result: As you you can see this is the points are actually 2D numpy arrays: ...
0 votes
0 answers
73 views

How to feed NumPy arrays directly into multi-input TensorFlow Serving prediction in Python?

I'm writing a Python script to call a running TensorFlow Serving REST API with multiple inputs (both are of shape n*50): ...
  • 8,137
0 votes
0 answers
121 views

Can KAMA (Kaufman Adaptive Moving Average) be used for extracting the moving average of numpy arrays?

I'm reading about KAMA algorithm and everywhere I see it's just adopted for stocks and trading kind of things. Since the algorithm looks perfect so I was planning to use this for averaging out a 1D ...
0 votes
1 answer
380 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 ...
  • 23
0 votes
1 answer
1k views

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

...

1
2 3 4 5
7