WHT

Argmax() | 38. Argmax And Argmin In Numpy

Priyang Bhatt

Subscribe Here

Likes

53

Views

2,749

38. Argmax And Argmin In Numpy

Transcript:

Hello, coders in this video. I am going to explain you very important. Functions Arc, Max and Arcmain Arcmax returns indices of the MAX element of the array in a particular axis. If Axis is not given, then array is straightened into 1d array. Next argument returns indices of the mean element of the array in a particular axis. If Axis is not given, then array is splitted into 1d array. Now, as you know in the multi-dimensional array, we can pass axis values, either 0 or 1 so X is 0 means that the operation is performed down. The columns of a 2d array axis is equal to 1 means. The operation is performed down the rows of a 2d array. Now here you can see axis value is not given, so please note that index starts with zero. So now here you can see 2d array as I said. If axis value is not given then our array is converted into 1d array. If you apply Arc Max on it without axis value that you can see. Output is 1 because maximum element or maximum value available at index Number 1 so output is one so next argument without axis value. Now you can see so it consider our array as a 1d array flatten. Now you can see. Output is 2. Because minimum number is available on index Number 2. So please remember, our index starts with 0 so here. Output is 2. Next as I said. X is 0 means that the operation is performed down the columns of a 2d array again. Please note that index starts with 0 so now here you can see 2d array now. First, what will be the output of arc? Max with X is 0 Now you can see output. Is 2. 0 2. 2. Means here. We have to consider the column so total. How many columns are there here? 1 2. 3 and 4 but index starts with 0 So so here column is 0 1 2. And 3 so now that’s why here output is four values because we have how many columns four columns, one two three and four but index starts with zero so zero one, two and three so now you can see two because 0 1 and 2. So maximum value available at index 2. Of the first column. Likewise, you can see 2. Then 0 then 34 and 45 so please, remember, X is 0 means that the operation is performed down the columns of 2d array. Same output of argmin with axis is equal to 0 column wise. Now you can see here again. Output four values because here, in this example. How many columns are there? Four columns, one two three and four but index starts with zero so first minimum value available at index 1 of column 0 Likewise, 1 0 and 0 next X is equal to 1 So axis is equal to 1 means that the operation is performed down the rows of a 2d array again. Please note that index starts with 0 so here you can see again. I have used 2d array now. Our output of arc Max with Axis is equal to 1 Then here you can see output, three values. Why because here how many rows three rows one two and three but index starts with zero so row zero row, one and row two. So now here you can see 1 because maximum value available at index number 1 of row. 0 Now here. You can see 20 maximum value available at index 0 1 and 2. Of row 1 Now here you can see 56 next output of arg. Min output is three values because here how many rows, three rows one two and three but index starts with zero so zero one and two. So now here you can see two because minimum value available at index, two of Row Zero, then minimum value available at Index 0 of Row 1 minimum value available at index 1 of row 2. 0 1 and 2. Now let me show you this practically in the jupyter notebook. Now here you can see. I have imported numpy as np. Now first, Argmax returns the indices of the MAX element of the array in a particular axis. If access is not given then the array is splitted into 1d array, argmin returns the indices of the mean element of the array in a particular axis. If Axis is not given, then array is splitter into 1d array. X is 0 means that the operation is performed down. The columns of a 2d array Axis 1 means the operation is performed down the rows of a 2d array. Now you can see in this first case. Axis value is not given then our array is considered as a 1d array that you can see. Are the array dot arc. Max Output is one because maximum value available at index number one same for our main two because minimum value available at index number two zero one and 2. This one. So output is 2. Index. Number 2. X is 0 means that the operation is performed down the columns of a 2d array. Please note that index starts with 0 again. I have used the same 2d array, but nparcmax here. I have passed this array with Axis 0 means column wise, so Output 4 values because how many columns are there 4 columns, 1 2. 3 and 4 but please remember index start with 0 so 0 1 2. And 3 output is 2. Because 0 1 and 2. Maximum number available at Index 2. Of column 1 0 this 0 because maximum number available at index 0 of column 1 2. Here you can see 0 1 and 2. Maximum number available at Index 2. Of Column 2. Because index start with 0 0 1 and 2. Now again 2. 0 1 and 2. Maximum number available at Index 2. Of Column 3 Likewise, same for the arc. Main output is four values because here. How many columns are there? Four columns, one two, three and four but index start with zero, so we have to consider zero one two and three same one zero and one minimum number available at Index 1 of column 0 likewise, now let me consider for the Axis 1 Axis 1 means that the operation is performed down the rows of a 2d array again. Please note that index start with 0 again. I have used the same 2d array, but now with X is equal to 1 so np dot arc. Max, here I have passed. This array with axis is equal to 1 means row wise output, three values. Why, because here how many rows are there? Three rows, one two and three again index start with Zero Zero One and two first is one because zero and one row wise maximum number available at index 1 of row 0 2. 0 1 and 2. Maximum number available at index 2. Of row 1 0 maximum number available at Index 0 of Row 2. Same You can perform for our main with Axis is equal to 1 again output 3 values because how many rows are there 3 rows 1 two and three index start with zero zero one and two two. So here you can see zero one and two minimum number available at index two row zero zero minimum number available at index zero row 1 1 0 and 1 here minimum number available at Index 1 row 2. 0 1 and 2. Still. If you have any doubt, please write in the comment section. I will try to solve it. Thank you, thank you for watching.

0.3.0 | Wor Build 0.3.0 Installation Guide

Transcript: [MUSIC] Okay, so in this video? I want to take a look at the new windows on Raspberry Pi build 0.3.0 and this is the latest version. It's just been released today and this version you have to build by yourself. You have to get your own whim, and then you...

read more