Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/p test #46

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ jobs:
pip install --no-cache-dir Cython
pip install -r requirements.txt
pip install .
- name: Install extra dependencies for dataset
run: |
pip install torch
pip install torchvision
- name: Test with pytest
run: |
pytest
8 changes: 7 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ jobs:
pip install --no-cache-dir Cython
pip install -r requirements.txt
pip install .

- name: Install extra dependencies for dataset
run: |
pip install torch
pip install torchvision
- name: Test with pytest
run: |
pytest
# steps:
# - uses: actions/checkout@v3
# - name: Install miniconda
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
"""Unit test package for prosemble."""
1 change: 1 addition & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""prosemble core test suite"""
81 changes: 81 additions & 0 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""prosemble dataset test suite"""

import unittest
import numpy as np
from prosemble import datasets


class TestWDBC(unittest.TestCase):
def setUp(self):
self.data,self.labels = datasets.DATA().breast_cancer

def test_size(self):
self.assertEqual(len(self.data), 569)
self.assertEqual(len(self.labels), 569)

def test_dimensions(self):
self.assertEqual(self.data.shape[1], 30)

def test_unique_labels(self):
self.assertEqual(len(np.unique(self.labels)), 2)

def test_dims_selection(self):
self.input_features = self.data[:, [0, 1]]
self.assertEqual(self.input_features.shape[1], 2)


class TestS1(unittest.TestCase):
def setUp(self):
self.data,self.labels = datasets.DATA().S_1

def test_size(self):
self.assertEqual(len(self.data), 150)
self.assertEqual(len(self.labels), 150)

def test_dimensions(self):
self.assertEqual(self.data.shape[1], 2)

def test_unique_labels(self):
self.assertEqual(len(np.unique(self.labels)), 2)

def test_dims_selection(self):
self.input_features = self.data[:, [0, 1]]
self.assertEqual(self.data.shape[1], 2)




class TestS2(unittest.TestCase):
def setUp(self):
self.data,self.labels = datasets.DATA().S_2

def test_size(self):
self.assertEqual(len(self.data), 200)
self.assertEqual(len(self.labels), 200)

def test_dimensions(self):
self.assertEqual(self.data.shape[1], 2)

def test_unique_labels(self):
self.assertEqual(len(np.unique(self.labels)), 2)

def test_dims_selection(self):
self.input_features = self.data[:, [0, 1]]
self.assertEqual(self.data.shape[1], 2)



class TestMnits(unittest.TestCase):
def setUp(self):
self.data,self.labels = datasets.DATA().mnist

def test_size(self):
self.assertEqual(len(self.data), 70000)
self.assertEqual(len(self.labels), 70000)

def test_dimensions(self):
self.assertEqual(self.data.shape[1], 28)

def test_unique_labels(self):
self.assertEqual(len(np.unique(self.labels)), 10)

247 changes: 247 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
"""prosemble.models test suite. """

import numpy as np
import prosemble.models as ps


input_data = np.array(
[
[1, 2, 3, 4, 1, 3],
[1, 0, 3, 4, 1, 3],
[1, 2, 3, 9, 1, 3],
[6, 2, 5, 4, 1, 3],
[1, 0, 3, 2, 1, 7],
[9, 2, 6, 4, 8, 3],
[2, 2, 1, 4, 7, 3],
[2, 2, 0, 4, 7, 3],
[0, 2, 1, 4, 7, 3],
[2, 2, 3, 4, 7, 3],
[1, 2, 1, 4, 7, 3],
[1, 5, 1, 4, 1, 3],
[3, 1, 1, 2, 6, 1],
[9, 1, 3, 1, 6, 4],
]
)




def test_hcm_model_build():
model = ps.Kmeans(
data=input_data,
c=3,
num_inter=100,
epsilon=0.00001,
ord='fro',
plot_steps=True
)

def test_afcm_model_build():
model = ps.AFCM(
data=input_data,
c=3,
num_iter=1000,
epsilon=0.00001,
ord='fro',
m=2,
a=2,
b=2,
k=1,
set_U_matrix='fcm',
plot_steps=True
)

def test_bgpc_model_build():
model = ps.BGPC(
data=input_data,
c=3,
a_f=2,
b_f=0.5,
num_iter=100,
epsilon=0.00001,
ord='fro',
set_U_matrix='fcm',
plot_steps=True
)

def test_fcm_model_build():
model = ps.FCM(
data=input_data,
c=3,
m=2,
num_iter=100,
epsilon=0.00001,
ord='fro',
set_U_matrix=None,
plot_steps=True
)


def test_fpcm_model_build():
model = ps.FPCM(
data=input_data,
c=3,
m=2,
eta=2,
num_iter=1000,
epsilon=0.00001,
ord='fro',
set_U_matrix='fcm',
plot_steps=True
)

def test_ipcm_model_build():
model= ps.IPCM1(
data=input_data,
c=3,
m_f=2,
m_p=2,
k=1,
num_iter=None,
epsilon=0.00001,
ord='fro',
set_U_matrix='fcm',
plot_steps=True
)

def test_ipcm_2_model_build():
model = ps.IPCM2(
data=input_data,
c=3,
m_f=2,
m_p=2,
num_iter=None,
epsilon=0.00001,
ord='fro',
set_U_matrix='fcm',
plot_steps=True
)


def test_kafcm_model_build():
model = ps.KAFCM(
data=input_data,
c=3,
num_iter=1000,
epsilon=0.00001,
ord='fro',
m=2,
a=3,
b=3,
k=1,
sigma=1,
set_centroids='kfcm',
set_U_matrix='kfcm',
plot_steps=True
)


def test_kfcm_model_build():
model = ps.KFCM(
data=input_data,
c=3,
num_iter=1000,
epsilon=0.001,
ord='fro',
set_prototypes=None,
m=2,
sigma=1,
set_U_matrix=None,
plot_steps=True
)


def test_kpfcm_model_build():
model = ps.KFPCM(
data=input_data,
c=3,
num_iter=100,
epsilon=0.0001,
ord='fro',
m=2,
sigma=1,
eta=2,
set_centroids=None,
set_U_matrix='kfcm',
plot_steps=True
)


def test_kipcm_model_build():
model = ps.KIPCM(
data=input_data,
c=3,
num_iter=1000,
epsilon=0.001,
ord='fro',
m_f=2,
m_p=2,
k=1,
sigma=10,
set_centroids='fcm',
set_U_matrix='fcm',
plot_steps=True
)



def test_kipcm2_model_build():
model = ps.KIPCM2(
data=input_data,
c=3,
num_iter=100,
epsilon=0.0001,
ord='fro',
m=2,
k=2,
sigma=10,
set_centroids='fcm',
set_U_matrix='fcm',
plot_steps=True
)

def test_kpcm_model_build():
model = ps.KPCM(
data=input_data,
c=3,
num_iter=100,
epsilon=0.001,
ord='fro',
m=2,
k=0.06,
sigma=1,
set_centroids=None,
set_U_matrix='kfcm',
plot_steps=True
)


def test_pcm_model_build():
model= ps.PCM(
data=input_data,
c=3,
m=2,
k=0.001,
num_iter=1000,
epsilon=0.00001,
ord='fro',
set_U_matrix='fcm',
plot_steps=True
)

def test_pfcm_model_buidl():
model= ps.PFCM(
data=input_data,
c=3,
m=2,
eta=2,
k=1,
a=2,
b=2,
num_iter=1000,
epsilon=0.00001,
ord='fro',
set_U_matrix='fcm',
plot_steps=True
)

21 changes: 0 additions & 21 deletions tests/test_prosemble.py

This file was deleted.

Loading