-1

Following is the code where in caller is called first from another module, centroids is of float type (an array of numberofcluster * numberoffeatures) labels is 1d array of numberofexplanations

array is not getting updated

def caller(centroids, labels):

    number_of_features = len(centroids[0])
    one_column = [0, 0, 0, 0, 0]

    i = 0
    j = 0

    array = [[0 for x in xrange(number_of_features)] for x in xrange(5)]

    while i < number_of_features:
        j = 0
        while j < 5:
            one_column[j] = centroids[j][i]
            j += 1

        rank(one_column, i, array)
        i += 1 


    return calculatemean(number_of_features, array)


def rank(one_column, ithfeature, array):

    temp_dict = {}
    i = 0
    while i < 5:
         temp_dict[one_column[i]] = i
         i += 1

    number_of_uniquevalues = len(set(temp_dict))
    sorted_dict = OrderedDict(sorted(temp_dict.items()))

    i = 0
    keys_list = sorted_dict.keys()

    while i < 5:
        array[one_column.index(keys_list[i])][ithfeature] = sorted_dict[keys_list[i]]
        i += 1
1
  • 1
    Which Array in this python code not getting updated? Commented Mar 21, 2015 at 5:45

1 Answer 1

0

I have referred to this link

Two dimensional array in python

and the issue is resolved

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.