Found 1204 Articles for Numpy

Find the sum and product of a NumPy array elements

Atharva Shah
Updated on 21-Aug-2023 15:13:05

217 Views

A Python package called NumPy is employed in scientific computing and to handle large-scale numerical data. It provides support for multi-dimensional arrays and matrices, as well as a large library of mathematical functions to manipulate them. In this tutorial, we will focus on two of the most commonly used NumPy functions: sum() and prod(). These functions are used to calculate the sum and product of all the elements in a NumPy array, respectively. Installation Get the numpy package installed using pip inside your terminal pip install numpy Import it as highlighted after successful installation − import numpy as np ... Read More

What does -1 Mean in Numpy Reshape?

Aditya Varma
Updated on 17-Aug-2023 20:31:03

178 Views

NumPy is a Python library for numerical computing that provides efficient array operations, and numpy.reshape() is a function used to change the shape of an array, with -1 indicating an inferred dimension. When working with arrays, we frequently get into instances where we need to modify the shape of the array, but doing so requires copying the data first, then arranging it into the required shape which is time taking. Fortunately, Python has a function called reshape() that may help with this. Example 1: Find Unknown Dimensions in Numpy We are only allowed to have one "unknown" dimension while we ... Read More

What is Convolution in Computer Vision

Parth Shukla
Updated on 17-Aug-2023 16:56:18

168 Views

Introduction In machine learning, computer vision is a field where image datasets are used and analyzed to perform several complex tasks related to the same. Here different algorithms and techniques are used related to handling and analyzing the images in order to use the data and train high-performing models. Convolution is a very important term or a phenomenon that occurs in the name of Convolutional neural networks, which is the most famous technique used for handling and dealing with image datasets in machine learning. In this article, we will discuss convolution, what are convolutional operations, and other important ... Read More

How to Conduct a Paired Samples T-Test

Parth Shukla
Updated on 17-Aug-2023 16:53:46

161 Views

Introduction In machine learning and data science, many statistical tests are used to compare and find the differences between variables or the features of the data. These tests are mainly hypothesis tests where the conditions are defined, and according to the different tests being conducted, the relationship between variables is assumed. The t-test is also a type of statistical test that is used to compare the means of different groups of the categorical variable. In this article, we will discuss the paired t-test, which is an extension or a type of t-test used in statistics, and we will ... Read More

How to iterate over Columns in Numpy

Tapas Kumar Ghosh
Updated on 16-Aug-2023 16:15:40

778 Views

The name Numpy stands for Numerical Python. It helps to solve the mathematical operation on an array. In Python, we have some built-in functions such as nditor(), T(), array(), shape[], and apply_along_axis() that will be used to iterate over columns in Numpy. Syntax The following syntax is used in the examples- nditer() The NumPy module contains this built-in function for iterator objects. T() This function refers to transposing of the index in a column dataframe. array() This is a built-in function in Python that creates the array. An array is defined by collecting the items of ... Read More

Structured Array in Numpy

Priya Sharma
Updated on 14-Aug-2023 15:35:24

1K+ Views

NumPy, the fundamental package for scientific computing in Python, provides powerful tools for working with homogeneous multidimensional arrays. While NumPy arrays excel at handling uniform data types efficiently, there are cases where we need to work with structured data containing heterogeneous types. This is where structured arrays come into play. Structured arrays in NumPy allow us to work with tabular or structured data, where each element of the array can have multiple fields with different data types. This capability makes NumPy a versatile library for handling a wide range of data, including CSV files, database tables, and more. Creating Structured ... Read More

Python - Operations on Numpy Arrays

Priya Sharma
Updated on 14-Aug-2023 15:44:52

89 Views

NumPy (Numerical Python) is a powerful library in Python for scientific computing. It provides a high-performance multidimensional array object and tools for working with these arrays. NumPy provides flexible ways to access elements within arrays. You can use indexing and slicing operations to retrieve specific elements or sections of an array. Indexing In NumPy, indexing starts at 0, similar to Python lists. You can access individual elements of an array by specifying their indices within square brackets. For example, given an array arr, you can access the element at index i using arr[i]. Slicing NumPy arrays also support slicing, ... Read More

How to choose elements from the list with different probability using NumPy?

Niharika Aitam
Updated on 09-Aug-2023 14:55:24

550 Views

There are multiple ways to choose elements from the list with the different probability using the numpy library. In python, NumPy library provides a module named random, which has several functions such as choice(), multinomial() etc., which are used to choose elements from an array with different probabilities. The sum of all probability values defined in the list should be equal to 1. Let’s see each way one by one. Using the random.choice() function The random module provides the function choice(), which is used to calculate a random sample from the given 1-d array with the specified probability distribution. ... Read More

How to check whether the element of a given NumPy array is non-zero?

Niharika Aitam
Updated on 09-Aug-2023 14:53:33

93 Views

There are multiple ways to check whether the element of a given Numpy array is Non-zero. Here are few common ways that we can apply. Using Boolean indexing Boolean Indexing is a technique in Numpy library, that allows for the selection of specific elements from the array based on the Boolean condition. This creates a Boolean mask containing True or False values, which have the same shape and size as per the Boolean condition. Example Following example how to use Boolean indexing to check whether the element of a given numpy array is non-zero. import numpy as np arr = ... Read More

How to check whether specified values are present in NumPy array?

Niharika Aitam
Updated on 09-Aug-2023 14:47:20

4K+ Views

We have different modules and functions available in python language to check whether specified values are present in the given Numpy array. Numpy is abbreviated as Numerical Python, which is a python library used to perform the mathematical, statistical and scientific calculations. The result of the numpy array is returned in the format of array. The arrays can be created in one dimension, two dimension and so on up to 32 dimensions. The Numpy library provides a number of modules and functions which helps us to perform scientific calculations and mathematical calculations. Let’s see each way one by one to ... Read More

Advertisements