There is a big difference when working with numpy arrays as is the result of clf.predict_proba(X_test)[:,1]
and a list
:
As it has been mentioned in the comments, lists can be sliced with single values, not comma separated because of their structure, whereas a numpy array with might be n-dimensional, can be sliced within with the comma separated value to indicate number of rows and columns, just like pd.DataFrame.iloc[] does.
np.array([1,1],[2,3],[4,3])
ex_list = [[1,1],[2,3],[4,3]]
But how does this actually look like? Well in the case of lists, they are 1-dimensial or flat
whereas this array is not.
1 arr_example
Has 3 rows and 2 columns:
array([[1, 1],
[2, 3],
[4, 3]])
2 ex_list
:
[[1,1],[2,3],[4,3]]
If you want to access the inner value of the nested list, then the indexing must be done outside the first slicer as you can see in the example below:
arr_example[:1,0] # arr_example[rows,columns]
list_example[:1][0][0]
In this case in arr_example
we are selecting the rows from start up to,but not including 1 (position 1, therefore only the first row) and the first column (position 0). Looking at the the structure of the data and understanding how the slicing works, the following outputs make sense:
array([1])
1