|
3 | 3 | from sklearn.svm import SVC |
4 | 4 | from sklearn.model_selection import cross_val_score, train_test_split, KFold |
5 | 5 |
|
| 6 | + |
6 | 7 | def perform(train_data, estimator, cv, predict_data=np.array(0)): |
7 | 8 | X, y = train_data.iloc[:, :-1], train_data.iloc[:, -1] |
8 | 9 | if not predict_data.shape: |
9 | 10 | return cross_val_score(estimator, X, y, cv=cv) |
10 | 11 | else: |
11 | 12 | return estimator.fit(X, y).predict(predict_data) |
12 | 13 |
|
| 14 | +""" |
| 15 | +def execute_graph(): |
| 16 | + queue = deque() |
| 17 | + seen = {} |
| 18 | + queue.append(self.blocks[0]) |
| 19 | + while queue: |
| 20 | + queque, seen = self.explore_graph(queue.popleft(), queue, seen) |
| 21 | +
|
| 22 | +def explore_graph(graph, block, queue: deque, seen: dict) -> (deque, dict): |
| 23 | + args = [] |
| 24 | + for in_pin in graph[block].inputs: |
| 25 | + if in_pin not in seen: |
| 26 | + dependency = in_pin |
| 27 | + if dependency in queue: |
| 28 | + queue.remove(dependency) |
| 29 | + queue, seen = self.explore_graph(dependency, queue, seen) |
| 30 | + args.append(seen[pin_uid]) |
| 31 | + result = graph[block].function(*args) |
| 32 | + for out_pin in graph[block].outputs: |
| 33 | + seen[out_pin] = result[i] |
| 34 | + for future_block in map(lambda x: x.block, out_pin.destinations): |
| 35 | + if future_block not in queue: |
| 36 | + queue.append(future_block) |
| 37 | +
|
| 38 | + return queue, seen |
| 39 | +""" |
13 | 40 |
|
14 | 41 | if __name__ == '__main__': |
15 | 42 | est = SVC() |
|
0 commit comments