Skip to content

Tag: numpy

Simple Linear Regression not converging

In my attempt to dig deeper in the math behind machine learning models, I’m implementing a Ordinary Least Square algorithm in Python, using vectorization. My references are: https://github.com/paulaceccon/courses/blob/main/machine_learning_specialization/supervisioned_regression/2_multiple_regression.pd…

How to access items from ndarray with dtype=object

How can I access data inside a numpy array with dtype=object? The following raises an IndexError. Answer Since you passed in the dict to numpy.array() without putting it in a list, this is a zero-dimensional array. To index into a zero-dimensional array, you can use b.item() to access the element inside. For …

Count how often values in a 2D array appear in a 3D array

I have one 2-dimensional numpy array and another 3D-dimensional array. For each number in the first array I would like to count how often this value or an extremer one appears in the second array (taking the 3rd dimension as comparison vector for each element in the first array). For 0 values the function sho…