Question: TODO 12 Use X and y defined below to complete the following TODOs. Using np.where and the label array y, find all the indexes whose
TODO 12
Use X and y defined below to complete the following TODOs.
Using np.where and the label array y, find all the indexes whose labels are equal to 2. Store the output into two_class_idx.
Hint: Don't forget to index np.where() at 0 like we did above! Otherwise, you might not pass the todo check!
# TODO 12.1 two_class_idx = np.where(y == 1)[0]
print(f"two_class_idx output: {two_class_idx}") try: print(f"two_class_idx shape: {two_class_idx.shape}") except Exception: pass
todo_check([ (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') ])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
