如何解决“ IndexError:仅整数,切片(`:`),省略号(`...`),numpy.newaxis(`None`)”

时间:2019-03-26 19:54:29

标签: python-3.x pycharm

# findin eucliean distance  and showing the 5 nearest neighbours

distarr=[]
for x in range(10000):
    distarr.append(euclideanDistance(timages_array[x],images_array[x]))
    # distarr[x]=euclideanDistance(timages_array[x],images_array[x])

pracarr=[]
ksmallneigh(pracarr,distarr,5)     # k smallest neighbours in pracarr
for x in range(5):
    print(label_array[pracarr[x]])

仅按降序排列数组的功能,这样我可以取出前5个元素

def ksmallneigh(pracarr,array1, k):
    # Sort the given array arr in reverse
    # order.
    array1.sort(reverse=False)
    #Print the first kth largest elements
    for i in range(k):
        pracarr.append(array1[i])
        # pracarr[i]=array1[i]

0 个答案:

没有答案