Python: Array Masks

Описание к видео Python: Array Masks

Descargar el Código: patreon.com/pythonmaraton

Join Patreon: patreon.com/pythonmaraton
^Downloadable code & more! This video goes through numpy array masking by showing you how to do it on a random matrix. A mask creates a matrix that has boolean values that match the mask statement. You can use the mask to examine specific parts of a matrix. Here is some syntax: np.random.random(()) and mask = A greater than 0.

Comment for any questions.

This is a Python anaconda tutorial for help with coding, programming, or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.

✅Subscribe:    / @pythonmaraton  

📺Channel:    / @pythonmaraton  

▶️Python Arrays:    • Python Tutorial - Python Numpy Array ...  

▶️Array VstacK:    • Python Tutorial - Numpy Vstack  

▶️Array Hstack:    • Python Tutorial - Numpy Hstack  

▶️Watch Latest Python Content:    • Python String Slice and List Slice  

▶️Watch Latest Other Content:    • Видео  





ARRAY MASKING

array masking is a powerful coding tool and I will show you how it works here.

First, so we can make matrices we import numpy as np

And today I’ll show you with a random matrix so we will import random.

First we will make a random 5x5 matrix with entries between -5 and 5.

To create a random matrix we type np.random.random(()) and insert a tuple with the size of the desired matrix

Normally np.random.random will automatically create random numbers between 0 and 1, so we will just multiply by 10 and subtract 5 to make this between -5, 5

So here is our random 5x5 matrix A

And now we will create the mask. Let’s call this mask, though you can name it anything.

We will do a mask that is anywhere A is greater than 0

When we print out the mask it will be a matrix the same size as A with boolean values in every spot. True where the value is greater than 0 and False where the value is less than 0

Once we have this mask we can type A[mask]

This will be all the values of A that satisfy the mask.

So here it is, all the positive numbers in A

And Let’s show you A again.

There you have it, that is how you do numpy array masking

#PythonMarathon #LearnPython #PythonTutorial Learn Python:
Python Book (English): https://amzn.to/3HcwgLd
Libro de Python (Español): https://amzn.to/47woAhQ
Affordable Laptop: https://amzn.to/48L30Hb
Machine Learning Book: https://amzn.to/3RNmwfs
Libro de Aprendizaje automatico: https://amzn.to/3RVAFXU
Neural Networks for Babies: https://amzn.to/41SELoi

Video Equipment:
Background Color Light: https://amzn.to/3SgBDzG
Key Light: https://amzn.to/3NYwXLZ
Microphone: https://amzn.to/3H9UK89

Other:
Underrated Cheap Basketball: https://amzn.to/3RVzJTo
Amazing Basketball shorts: https://amzn.to/3vyRDUM

Комментарии

Информация по комментариям в разработке