Пример #1
0
def secondsmallestNumber(array):
    minimum_element = find_min.findMin(array)
    for iterator in array:
        if minimum_element == iterator:
            array.remove(iterator)
    minimum_element = find_min.findMin(array)
    return minimum_element
def secondsmallestNumber(array):
    v = find_min.findMin(array)
    for i in array:
        if v == i:
            array.remove(i)
    maxi = find_min.findMin(array)

    return maxi
def kth_smallest_ele(array, kthele):
    smallest_ele = 1
    iterator = 1
    lenght = FindLenght.count(array)
    while (iterator != kthele):
        if lenght == kthele:
            return Max.Max(array)
        else:
            smallest_ele = find_min.findMin(array)
            for j in array:
                if (j == smallest_ele):
                    array.remove(smallest_ele)
            iterator += 1
        smallest_ele = find_min.findMin(array)
    return smallest_ele
Пример #4
0
def test_arrayretutn7():
    #arrange
    values = [5, 2, 4, 7, 3, 5]
    excepted = 2
    #act
    actual = find_min.findMin(values)
    #assert
    assert excepted == actual
Пример #5
0
def findUnique(array):
    dictionary = dictionaryOperations.built_dictionary(array)
    listValues = list(dictionary.values())
    minimum_value = find_min.findMin(listValues)
    for i in listValues:
        if i != minimum_value:
            b = (dictionaryOperations.find_key_from_dictionary(dictionary, i))
            print(b, i)
            dictionary.pop(b)
def findUnique(array):
    not_unique = []
    dictionary = dictionaryOperations.built_dictionary(array)
    listValues = list(dictionary.values())
    minimum_value = find_min.findMin(listValues)
    for i in listValues:
        if i != minimum_value:
            b = (dictionaryOperations.find_key_from_dictionary(dictionary, i))
            not_unique.append(b)
            dictionary.pop(b)
    return not_unique
def kth_largest_ele(array,kthele):
    lenght = FindLenght.count(array)
    if (lenght == kthele):
        return find_min.findMin(array)
    else:

        iterator = 1
        while(iterator!=kthele):
            Largest_ele = Max.Max(array)
            for j in array:
                if (j == Largest_ele):
                    array.remove(Largest_ele)
            iterator += 1
        Largest_ele = Max.Max(array)
    return Largest_ele
Пример #8
0
    def fit(self, X, y, maxEpochs=500):
        n, d = X.shape

        if y.ndim == 1:
            y = y[:, None]

        self.layer_sizes = [X.shape[1]
                            ] + self.hidden_layer_sizes + [y.shape[1]]
        self.classification = y.shape[
            1] > 1  # assume it's classification iff y has more than 1 column

        # random init
        scale = 0.01
        weights = list()
        for i in range(len(self.layer_sizes) - 1):
            W = scale * np.random.randn(self.layer_sizes[i + 1],
                                        self.layer_sizes[i])
            b = scale * np.random.randn(1, self.layer_sizes[i + 1])
            weights.append((W, b))
        weights_flat = flatten_weights(weights)

        for e in range(maxEpochs - 1):
            printProgressBar(self,
                             iteration=e + 1,
                             total=maxEpochs,
                             prefix='Progress:',
                             suffix='   |   Epoch #: ')
            random_indices = np.random.randint(n, size=2000)
            #Take a random sample of corresponding X and y
            X_rand = X[random_indices]
            y_rand = y[random_indices]

            weights_flat_new, f = findMin(self.funObj,
                                          weights_flat,
                                          self.max_iter,
                                          X_rand,
                                          y_rand,
                                          verbose=True,
                                          alpha=0.0001)

            weights_flat = weights_flat_new

        self.weights = unflatten_weights(weights_flat_new, self.layer_sizes)