-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04732dd
commit 7e82ef9
Showing
7 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## What's new? | ||
|
||
* **Problem**: Problem description | ||
* **Solution**: Solution description | ||
* **Related/Additional changes**: Related/Additional changes description | ||
|
||
Closes # |
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,26 @@ | ||
name: Unit tests execution | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Test with pytest | ||
run: | | ||
pip install pytest | ||
python -m pytest tests/ --disable-warnings |
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,4 @@ | ||
numpy | ||
scikit-learn | ||
pandas | ||
polars |
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,4 @@ | ||
import numpy as np | ||
|
||
def euclidean_distances(x_train: np.array, x_test_point: np.array): | ||
return np.sqrt(np.sum((x_train - x_test_point) ** 2, axis=1)) |
Empty file.
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,20 @@ | ||
from unittest import TestCase | ||
import numpy as np | ||
from sklearn.metrics.pairwise import euclidean_distances as sk_ed | ||
from src.core.distances import euclidean_distances | ||
|
||
class TestDistances(TestCase): | ||
def test_should_calculate_euclidean_distance(self): | ||
x = np.array([ | ||
[0.5, 0.3, 0.23], | ||
[0.4, 0.4, 0.43], | ||
[0.3, 0.5, 0.33] | ||
]) | ||
|
||
target = np.array([0.3, 0.5, 0.33]) | ||
|
||
distances = euclidean_distances(x, target) | ||
expected_distances = sk_ed(x, [target]) | ||
|
||
for distance_actual, distance_expected in zip(distances, expected_distances): | ||
assert round(distance_actual, 4) == round(distance_expected[0], 4) |
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,4 @@ | ||
import unittest | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |