Questions tagged [numpy]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
11 views

What is the formula used by np.dot?

Dot products are pretty simple for 1- or 2-dimensional arrays, but anything beyond that is incomprehensible to me. I tried looking into numpy‘s dot function but the ...
0
votes
2answers
26 views

How match output (pred value) to input value

I'm working with data(with 4 columns which are p(product), M(name of the store)), I want predict the demand of store for that I sued SVR on the data by theses formulation: ...
0
votes
0answers
19 views

What are the use-cases for heapsort option in numpy.sort()?

Could anybody share experience about use cases of the heapsort option in numpy.sort() (or pandas.DataFrame.sort_values()) in the data science field? I mean if the <...
0
votes
1answer
27 views

How to show two pictures in one cell in Jupyter Notebook? (matplotlib) (python) [closed]

As a beginner, can someone please help me with this? Is there any way to show both pictures in a single cell's output? My output could only display one picture. Thank you for your time and attention! ...
1
vote
1answer
33 views

Replace values in dataframe with another dataframes values based on condition [closed]

I have 2 dataframes with the same columns names and rows number but the elements' values are different. I need to change the value of each element in the first dataframe to 1 if its value in the the ...
0
votes
0answers
19 views

Keras RetinaNet implementation and width, height order

I'm trying to use the excellent open source implementation of RetinaNet with keras (https://github.com/fizyr/keras-retinanet) and I've noticed a little detail that I would like to clarify. In the ...
0
votes
1answer
21 views

Why is np.where not returning '1'? Only returns '0'

This code should return a new column called orc_4 with the value of 1 if the value of the row in ...
0
votes
2answers
27 views

Filenotfounderror: [errno 2] no such file or directory: 'nsr001.ecg'

I am trying to save contents of physiobank Normal Sinus Rhythm RR Interval Database into a numpy array but I keep getting an error: ...
1
vote
2answers
30 views

numpy array quirks: does A.T return a view?

I am trying to understand the numpy array object, and a little mystified by the following: ...
1
vote
1answer
37 views

Numpy nan value [closed]

np.nan == np.nan False BUT WHY ? -I expect the inequality statement as False if the above equality statement is False- ...
0
votes
0answers
20 views

How does the below calculation help to create a PNG from a floating point depth map?

What is the effect of max_val * (depth - depth_min) / (depth_max - depth_min) in the below function? ...
1
vote
1answer
16 views

Input changing row count matrices in an MLP

I want to input a numpy 2d array into MLP but I have an array of 50395 rows that contains many 2d array of shape (x, 129). x ...
0
votes
1answer
236 views

ValueError: Shapes (None, 7, 7) and (None, 7) are incompatible [closed]

I am new to deep learning. I have been trying to train a VGG16 model to detect different emotional categories from a CSV Dataset. However, When I run the code for fitting the model below ...
0
votes
0answers
62 views

ValueError: array length 13996092 does not match index length 214200 for Kaggle submission

My model is based on the model linked here on Kaggle. Specifically, the following lines of code to generate an uploadable table to make my submission: ...
1
vote
0answers
32 views

Using numpy.ndarray in machine learning sklearn.preprocessing model

I'm having a problem storing and using an array on one model that I'm building in sklearn, Here is what I'm doing: I'm converting an image to numpy and storing as numpy.ndarray in my dataframe (there ...
0
votes
0answers
10 views

Rating Sports Teams: How to perform least squares minimization with a constraint?

I am trying to rate NFL teams by minimizing the sum of squared errors subject to a constraint. My data looks like: ...
0
votes
1answer
59 views

How to replace values in a numpy array?

I'm learning how to implement and evaluate a Logistic Regression Model, for this I need to change the values of my array from strings to 0 & 1. I have the following numpy ndarray as a result of a <...
1
vote
1answer
445 views

AttributeError: 'numpy.ndarray' object has no attribute 'nan_to_num'

I'm trying to run a Random Forest model from sklearn but I keep getting an error: ValueError: Input contains NaN, infinity or a value too large for dtype('float32')....
1
vote
0answers
152 views

“Failed to find data adapter that can handle input” when working with mixed data

I have been trying to make my own generator that would handle an [image, float] value for the x (input), while the y is an int (linear output). My data is compiled into a ...
0
votes
0answers
13 views

How to escape 'na' and '-' value in a dataset (Can only use Numpy and Matplotlib for this project)

I have imported csv file and this is the link to get the data set CSV file https://data.gov.sg/dataset/median-rent-by-town-and-flat-type My problem is how to escape the value of "na" and &...
0
votes
2answers
63 views

Bad results in Logistic Regression from-scratch Python implementation on sample gender data

I am quite a newbie to Machine Learning, now trying to implement from scratch in Python (using numpy) a logistic regression algorithm. I took the gender/height/weight data from here. Then I did the ...
0
votes
0answers
12 views

Will disparity in image format/quality between binary classifications affect training of Convolutional Neural Network?

I have an image dataset containing two classes. One of the classes has many images and they are all JPG images with the following format: ...
0
votes
0answers
13 views

how to vertical integration along specific levels

I know it will sound silly but I have got a small question to ask. I want to do vertical integration for atmospheric data. Suppose say, my data contains dimensions as (time, level, long, lat). Now the ...
0
votes
2answers
40 views

How to apply Geomertic mean in python

I am trying to built a function to calculate the Geometric mean for Growth column and Avg_growth. Year Company Name FH_PBIDT ...
0
votes
1answer
98 views

How to solve ValueError: Negative dimension size caused by subtracting 3 from 1 for '{{node model/Conv1/Conv2D}} = Conv2D… in mobilenet_v2

I'm trying to apply a retrained model of mobilenet_v2 presented in https://github.com/balajisrinivas/Face-Mask-Detection The ...
0
votes
0answers
21 views

Convert TFIDF Values to Vector Space Model

I'm working on a project using tf-idf values and cosine similarity for clustering. As my database (elasticsearch) provides tfidf values out of the box (term_freq & doc_freq), my code involves ...
0
votes
0answers
31 views

Multivariable linear gradient descent resulting in inf

I am trying to implement a multivariable gradient descent algorithm, it seems to start working fine, and works on smaller datasets, but applying it to larger datasets the variables overflow and cause ...
0
votes
0answers
20 views

Fast ways to multiply small matrices?

Context: I'm trying to optimize a portfolio of assets for some arbitrary goal. Currently, I'm multiplying the matrix representing the different assets with the matrix representing the weights (taken ...
1
vote
1answer
29 views

np.unique() explanation? [closed]

What happends in this numpy function: https://numpy.org/doc/stable/reference/generated/numpy.unique.html ...
0
votes
2answers
28 views

Query relating to Pandas Rows manipulation

I have a query regarding Pandas data manipulation. Let's say I have a dataframe, df with following structure. A B C 1 1 7 5 3 3 3 3 2 7 5 2 5 NaN 2 We have 3 ...
1
vote
2answers
31 views

28x28 mnist image unrolling to concatenate using numpy.vstack. Why is numpy.vstack so slow?

I'm trying to do a simple reshape of a 60000,28,28 list of mnist digits into a 60000,784 numpy array where the digits have been unrolled. To do this the code is this: ...
0
votes
1answer
41 views

Scaling continuous data to discrete range [closed]

Edit: the context is as follows: I've trained some ML model that predicts some feature vector. Thats a. But I know that a can take some values from discrete range, ...
1
vote
1answer
72 views

Running scikit-learn with large volume

I need to run a Random Forest process with scikit-learn. To train the model, I have a database table with 10 million rows of features. The question is: what is the ...
0
votes
0answers
12 views

time syncronisation

Introduction Given is a vehicle which is moving past a station. If the vehicle passes the station (for simplicity determined by GPS) it sends RF-signals, to the station saying "Hello I am here ...
3
votes
0answers
45 views

Detecting pushups based on pose data

I've been playing with Google's MLKit, and decided to detect push ups. As a quick test, I took the position of the left shoulder, and plotted the Y Axis. Here's how a variety of trials look: Five ...
0
votes
1answer
35 views

finding the mean for each of the channels (RGB) across an array of images [closed]

How can I find the mean for each of the channels (RGB) across an array of images? For example train_dataset[0]['image'].shape is ...
1
vote
2answers
28 views

How can ANN handle varied sized inputs?

I have a dataset with a message (string) and an associated mood. I am trying to use an ANN to predict one of the 6 moods using the encoded inputs. This is how my X_train looks like: ...
1
vote
1answer
288 views

My corr() function in Python keeps resulting in an “ValueError: The truth value of a Series is ambiguous…” [closed]

I am a very inexperienced programmer, this is my first question on the Data Science StackExchange, I sorry if it is formatted poorly or comes across as basic. For some strange reason, in Python, ...
1
vote
1answer
1k views

ValueError: cannot reshape array of size 136415664 into shape (2734,132,126,1)

I have a data set I loaded with cv2 but when I try to format it I get the above error. I start by moving the data into X_train and X_test (the loaded data is in x_train and x_test). ...
1
vote
2answers
3k views

ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int) in Python

I have written the following code for a neural network to perform regression on a dataset, but I am getting a ValueError. I have looked up to different answers and ...
0
votes
1answer
24 views

Python make_scorer giving incorrect outputs for Root Mean Square Logarithmic Error

I want to generate a grid search for which I need the scoring parameter based on which the search will take place. I have defined the following function to provide ...
-2
votes
1answer
13 views

Numpy failing in subtraction even after same dimensions of arrays [closed]

When I subtract these two arrays, it returns a (354,354) shaped array because as per the documentation there is a mismatch in the shape of the arrays. Why does it happen and what else can I do for ...
0
votes
0answers
322 views

Load numpy data from directory to keras image generator

I have two folders of hyperspectral data with five channels which are converted to numpy array. Each folder depicts the respective label. Example : ...
0
votes
1answer
34 views

How to get used to matricial/vectorial operations?

I came to data science/machine learning from another background in computer science and i feel that i'm lacking of experience with matricial/vectorial operations. Python or Matlab, for instance, ...
0
votes
1answer
38 views

Replacing value not in list in Pandas [closed]

Say I have a data frame in Python. If I want to replace all values in the say, the Size column that are not 'M' or 'S' or 'L' with nan, how do I do so? Thanks in advance
-3
votes
1answer
33 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
12 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 ...
3
votes
2answers
74 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
25 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
58 views

Numpy array value error

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

1
2 3 4 5 6