-
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
Showing
6 changed files
with
114 additions
and
23 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 |
---|---|---|
@@ -1 +1 @@ | ||
from clax.clax import Classifier, Regressor | ||
from clax.clax import Classifier, ConditionalClassifier, Regressor |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "clax" | ||
version = "0.0.2" | ||
version = "0.0.3" | ||
description = "Prebuilt jax classifiers" | ||
authors = ["David Yallup <[email protected]>"] | ||
readme = "README.md" | ||
|
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,37 @@ | ||
import jax.numpy as jnp | ||
import numpy as np | ||
import pytest | ||
from jax import nn | ||
|
||
from clax import Classifier, ConditionalClassifier, Regressor | ||
|
||
# @pytest.mark.parametrize("n_classes", [2, 10]) | ||
# class TestClassifier: | ||
# @pytest.fixture | ||
# def classifier(self, n_classes): | ||
# return Classifier(n_classes) | ||
|
||
# def test_fit(self, classifier, n_classes): | ||
# data_x = np.random.rand(100, 10) | ||
# data_y = np.random.randint(0, n_classes, 100) | ||
# classifier.fit(data_x, data_y) | ||
|
||
|
||
@pytest.mark.parametrize("n_classes", [2, 10]) | ||
def test_classifier(n_classes): | ||
classifier = Classifier(n_classes) | ||
data_x = np.random.rand(100, 10) | ||
data_y = np.random.randint(0, n_classes, 100) | ||
classifier.fit(data_x, data_y) | ||
y = classifier.predict(data_x) | ||
assert y.shape == (100, n_classes) | ||
assert np.isclose(nn.softmax(y).sum(axis=-1), 1).all() | ||
|
||
|
||
def test_conditional_classifier(): | ||
classifier = ConditionalClassifier() | ||
data_x = np.random.rand(100, 10) | ||
data_y = np.random.rand(100, 10) | ||
classifier.fit(data_x, data_y) | ||
y = classifier.predict(data_x) | ||
assert y.shape == (100, 1) |