C1W3 UNQ_C6 Issue

In UNQ_C6 of the C1W3 lab assignment, the function arguments are defined to follow the following dimensionality: (num classes, height, width, depth).

However, in test case 3 when running the “compute_class_sens_spec_test” function, it appears that the label and prediction inputs will be singular columns from a dataframe. The test cell fails due to a lack of dimensions on these inputs. Is this a bug? Or should the function be flexible to handle such an input?

Below is an excerpt of the code output of the cell (removing the line that references my exact solution per Discourse guidelines)

----------------------

Test Case 3:
y_test	preds_test	category
0	1	1	TP
1	1	1	TP
2	0	0	TN
3	0	0	TN
4	0	0	TN
5	0	1	FP
6	0	1	FP
7	0	1	FP
8	0	1	FP
9	1	0	FN
10	1	0	FN
11	1	0	FN
12	1	0	FN
13	1	0	FN
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-28-49c4567a99ff> in <module>()
      1 ### test cell ex6 - do not modify this test cell
----> 2 compute_class_sens_spec_test(compute_class_sens_spec)

~/work/W3A1/public_tests.py in compute_class_sens_spec_test(target)
    446     pred_3 = np.array( [df['preds_test']])
    447     label_3 = np.array( [df['y_test']])
--> 448     sensitivity_3, specificity_3 = target(pred_3, label_3, 0)
    449     print("\nSensitivity: ", sensitivity_3)
    450     print("Specificity: ", specificity_3, "\n")

<ipython-input-27-a26bf38fdec1> in compute_class_sens_spec(pred, label, class_num)
     28 
     29     # true positives
---> 30     tp = *CENSORING MY SOLUTION*
     31 
     32     # true negatives

IndexError: too many indices for array

Hi @Digipath,

Were you able to pass the assignment or is the cell still giving you an error?

Also, did you change anything but “None” in the assignment?

Hi @sivanola ,
Thank you for responding. I have not modified anything besides the “None” placeholders. I have not tried submitting the assignment yet given this code block was failing.

I did some more investigating into the test cases by adding some print commands. This is confirming that test case 3 used by the “compute_class_sens_spec_test” function is a 2D dataframe and not a 4 dimensional array as prescribed in the input argument definitions of the UNQ_C6 function.

Test Case 1:
input pred shape:
(1, 2, 2, 1)
input label shape:
(1, 2, 2, 1)

Test Case 2:
input pred shape:
(1, 2, 2, 1)
input label shape:
(1, 2, 2, 1)

Test Case 3:
input pred shape:
(1, 14)
input label shape:
(1, 14)

So I modified my solution to handle arrays of arbitrary dimensions to pass the “compute_class_sens_spec_test” evaluation. I would recommend changing the supplied input arg definitions of the function so that the user is not told the input data is of a specific dimensionality when it is in fact arbitrary/variable dimensions.

Hi @Digipath,

Thank you for your detailed report. I hope one of the course creators will look into this issue soon.

Best of luck with the rest of the course!