Find all the indexes whose labels equal 2 using np.where and the label array y. The output should be saved in two class idx. Reminder: Remember to index np.where() at zero   # TODO  two_class_idx = np.where(y == 2 )[0] print(f"two_class_idx output: \n {two_class_idx}") try: print(f"two_class_idx shape: {two_class_idx.shape}") except Exception: pass ([ (isinstance(two_class_idx, np.ndarray),f'two_class_idx is not an NumPy array! two_class_idx is currently a {type(two_class_idx)}'), (np.all(two_class_idx == np.array([3,9,11,12,16])),'two_class_idx does not contain the correct location values') ])

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter6: Using Arrays
Section: Chapter Questions
Problem 17RQ
icon
Related questions
Question

 

Find all the indexes whose labels equal 2 using np.where and the label array y. The output should be saved in two class idx.
Reminder: Remember to index np.where() at zero

 

# TODO 
two_class_idx = np.where(y == 2 )[0]

print(f"two_class_idx output: \n {two_class_idx}")
try:
print(f"two_class_idx shape: {two_class_idx.shape}")
except Exception:
pass

([
(isinstance(two_class_idx, np.ndarray),f'two_class_idx is not an NumPy array! two_class_idx is currently a {type(two_class_idx)}'),
(np.all(two_class_idx == np.array([3,9,11,12,16])),'two_class_idx does not contain the correct location values')
])
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT