Found 1204 Articles for Numpy

Python - Replace negative value with zero in numpy array

Kalyan Mishra
Updated on 03-Oct-2023 15:37:32

1K+ Views

In this article we will see method to replace negative values with zero. If we talk about data analysis then handling negative values is very crucial step to ensure meaningful calculation. So, here you will learn about various methods using which we can replace negative values with 0. Method 1. Using Traversal and List Comprehension. Example import numpy as np arr = np.array([-12, 32, -34, 42, -53, 88]) arr = [0 if x < 0 else x for x in arr] arr = np.array(arr) print("array with replaced values is: ", arr) Output array with replaced values ... Read More

What is Numpy Gradient in Descent Optimizer of Neural Networks?

Someswar Pal
Updated on 29-Sep-2023 12:04:48

87 Views

Understanding Neural Networks In the context of neural networks, the goal is to find the optimal set of weights and biases that minimize the difference between the predicted outputs of the network and the true outputs. Optimization Gradient descent optimization works by iteratively updating the network parameters in the opposite direction of the gradient of the loss function with respect to those parameters. The gradient points in the direction of the steepest increase in the loss function, so by moving in the opposite direction, the algorithm can gradually converge toward the minimum of the loss function. There are variegated variants ... Read More

Limitations of fixed basis function

Mithilesh Pradhan
Updated on 26-Sep-2023 16:00:10

112 Views

Introduction Fixed basis functions are functions that help us to extend linear models in Machine Learning, by taking linear combinations of nonlinear functions. Since Linear models depend on the linear combination of parameters, they suffer a significant limitation. The radial function thus helps model such a group of models by utilizing non-linearity in the data while keeping the parameters linear. Different linear combinations of the fixed basis functions are used within the linear regression by creating complex functions. In this article let us look into the fixed basis function and its limitations Fixed Basis function A linear regression model ... Read More

Finding the Number of Weekdays of a Given Month in NumPy

Jaisshree
Updated on 23-Aug-2023 09:18:04

92 Views

Numpy is an open-source library in Python used for numerical computing, scientific computing, data analysis, and machine learning applications. This library has powerful array methods and tools to perform vector and matrix operations. You must install the NumPy module manually since it is not a component of the default Python library. The Python package manager pip can be used to accomplish this by executing the following command − pip install numpy We will use NumPy’s busday_count() function to calculate the required count of weekdays. This will calculate the number of business days (Monday to Friday) between 2 specific dates. ... Read More

Find the size of numpy Array

Jaisshree
Updated on 23-Aug-2023 09:15:27

123 Views

Numpy is often used along with packages such as SciPy and matplotlib in python. Additionally, arrays in Numpy are faster compared to lists in Python due to which this module is extensively used for complex mathematical algorithms and problems. It has various functions, and methods, to make our task easy and simple for matrix operations. In Numpy arrays there are two types of array − Single Dimensional Array Multi-Dimensional Array Single Dimensional Array (1D array) The datatypes of the elements stored in the array are - strings, integers, boolean or floating points. These arrays are called single or ... Read More

Find the maximum and minimum element in a NumPy array

Jaisshree
Updated on 23-Aug-2023 09:09:43

584 Views

The well-known open-source Python library NumPy is used for numerical computing. Large, multi-dimensional arrays and matrices are supported, along with a sizable number of sophisticated mathematical operations that can be used to work effectively on these arrays. When working with NumPy arrays, finding the maximum and minimum elements is often necessary. Method 1:Using max() and min() Functions The following code demonstrates creating an array of integers. We then use the max() and min() functions to find the highest and lowest value elements in the array, respectively. Algorithm Import the desired Numpy library. Create a 1D numpy array with integer ... Read More

Generate a Hermite_e series with given roots using NumPy in Python

Atharva Shah
Updated on 22-Aug-2023 18:17:34

98 Views

Hermite polynomials are a set of orthogonal polynomials that are useful in a variety of mathematical applications. They are commonly used in the solution of differential equations, probability theory, and quantum mechanics. The Hermite_e series is a variation of the Hermite polynomial that is used to represent a function in terms of its roots. In this article, we will discuss how to generate a Hermite_e series with given roots using NumPy in Python. Installation and Syntax NumPy is a Python library that provides support for numerical operations and it can be installed using pip and imported into Python using the ... Read More

Finding the k smallest values of a NumPy array

Atharva Shah
Updated on 21-Aug-2023 16:29:49

211 Views

Finding the k smallest values of a NumPy arra Installation and Syntax Pip, Python's package installer, is often used to install NumPy. pip install numpy The following function may be used to identify the k NumPy array elements with the smallest values − np.sort(array)[:k] This returns the first k items of the sorted array after sorting it in ascending order. The array may be be sorted using the alternative syntax shown below, which will retrieve the last k entries and sort the array in descending order − np.sort(array)[::-1][:k] Algorithm The algorithm for finding the k smallest ... Read More

Find unique rows in a NumPy array

Atharva Shah
Updated on 21-Aug-2023 16:13:53

404 Views

Duplicate rows in a dataset must frequently be found and removed in data science and machine learning and to solve this issue, a well-liked Python toolkit for numerical computation called NumPy offers a number of methods for manipulating arrays. In this tutorial, we'll go through how to use Python to locate unique rows in a NumPy array. Installation and Setup NumPy must first be installed using pip before it can be used in Python. pip install numpy Once installed, we can import the NumPy library in Python using the following statement − import numpy as np Syntax The ... Read More

Find the union of two NumPy arrays

Atharva Shah
Updated on 21-Aug-2023 16:12:37

181 Views

NumPy is a popular Python library that provides support for numerical computations. It is widely used for array and matrix operations in scientific computing, data analysis, and machine learning. One of the most common tasks in NumPy is finding the union of two arrays. A new array that contains all the distinct elements from both arrays is created when two arrays are joined. In this article, we will explore different ways to find the union of two NumPy arrays. Installation and Syntax NumPy is usually installed with Anaconda or Miniconda distribution. If you don't have it installed, you can install ... Read More

Advertisements