Пример #1
0
 def run(V, in_data):
     D = in_data
     L, K = D.no_tasks, D.no_machines
     C = D.tasks
     E = []
     F = [A for A in B(L)]
     G = [0 for A in B(K)]
     P = Q([A.weight for A in C])
     F.sort(key=lambda idx: C[idx].weight / Q(C[idx].duration))
     for W in B(L):
         X = J(F)
         H = []
         for A in F:
             if G[2] >= C[A].due_date: H.append(A)
         if J(H) == 0: H = F
         I = H[0]
         for A in H[1:]:
             if V.first_wins(I, A, C, P, G) == False: I = A
         S = C[I]
         E.append(I)
         F.remove(I)
         P -= S.weight
         T = 0
         for A in B(K):
             G[A] = R(G[A], T) + S.duration[A]
             T = G[A]
     E = [A + 1 for A in E]
     return U().s(D, M(score=O(E, C, K), schedule=N(D.no_tasks, E)))
Пример #2
0
    def __getitem__(self, item):
        """
        Get item
        :param item:
        :return:
        """
        # Get target set
        start_index = self.fold * self.k
        test_set = self.indexes[start_index:start_index + self.fold_length]
        train_set = np.remove(self.indexes, test_set)

        # Train/test
        if self.train:
            return self.dataset[train_set[item]]
        else:
            return self.dataset[test_set[item]]
Пример #3
0
    def predict(self, k, X):
        #initiate the variables
        num_test = X.shape[0]
        Ypred = np.zeros(num_test, dtype=self.ytr.dtype)
        min_indexes = np.array([])

        for i in range(k):
            for j in xrange(num_test):
                distances = np.sum(np.abs(self.Xtr - X[i, :]), axis=1)
                min_index = np.argmin(distances)
                # add the minimum indexes
                min_indexes = min_indexes.append(min_indexes, min_index)
                distances = np.remove(distances, min_index)

        # find the mode of the minimum indexes
        min_index = stats.mode(min_indexes)
        Ypred[i] = self.ytr[min_index]
        return Ypred
Пример #4
0
	def otherEdges(self, edge):
		return np.remove(self.edges, edge)
Пример #5
0
 def otherEdges(self, edge):
     return np.remove(self.edges, edge)
Пример #6
0
	# augmentation
	if augmentation:
		print("Augmentation flipping")
		X, Y = augmentation_flip(X, Y)

	# preprocess
	# am I messing up with the first dim here?
	if preprocess:
		print("Preprocessing: feature normalization")
		X /= 255.0
		X -= np.mean(X, axis=0)
        
    if remove:
        while i < X.shape[0]:
            if Y[i] > limit or Y[i] < -limit:
                Y = np.remove(Y, i)
                X = np.remove(X, i)
            else:
                i+=1

	# move channel axis
	X = X.transpose(0, 3, 1, 2)

	# subsample
	totalSamples = X.shape[0]
	num_train = int(totalSamples * (num_training_percentage / 100))
	num_validation = int(totalSamples * (num_validation_percentage / 100))

	mask = range(num_train)
	X_train = X[mask]
	y_train = Y[mask]
Пример #7
0
def _read_train_file(filename):
  data=pd.read_csv(filename).as_matrix()
  for i in range(data.shape[1]-2):
    data=np.remove(data,1,0)
  print("example data:",data[0])
  return data
Пример #8
0
#3. sorting data
data5=np.array([100,75,30,120,130,90])
np.sort(data5)

#class challenge question
# how to get descending order sorting ?
-np.sort(-data5)

#4. how to add new value
# add new value 110 to data5
np.append(data5,110)

#5. how to remove value from array
# remove 30 from data5
np.remove(data5[2])  # syntax error, reason remove is part
# of list function, not array function
np.delete(data5,[2])

#6. replace value inside array
# replace 75 to 80
data5[1]=80

print(data5)
# =============================================================================
# Test date - 14th Aug 2019
# topics - till 12th Aug 2019 topics
# 13th Aug 2019 - practice and doubt session
# =============================================================================