-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Алгоритм search_features и заполнение списка фич
- Loading branch information
1 parent
27432e4
commit 07e291d
Showing
6 changed files
with
103 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
controller/core_logic/lapshin_algorithm/service/vector_operations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
|
||
|
||
class VectorOperations: | ||
|
||
@staticmethod | ||
def calc_vectors_to_neighbors(current_center: tuple, neighbors_center: list) -> np.ndarray: | ||
vectors = np.array([[0, 0]], dtype='int8') | ||
for center in neighbors_center: | ||
vectors = np.append(vectors, [ | ||
[ | ||
center[0] - current_center[0], | ||
center[1] - current_center[1] | ||
] | ||
], axis=0) | ||
return np.delete(vectors, 0, 0) | ||
|
||
@staticmethod | ||
def calc_vectors_cos_angle(v1: np.ndarray, v2: np.ndarray) -> float: | ||
dot_pr = v1.dot(v2) | ||
norms = np.linalg.norm(v1) * np.linalg.norm(v2) | ||
|
||
return dot_pr / norms |