-
Notifications
You must be signed in to change notification settings - Fork 3
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
3 changed files
with
51 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,5 @@ | ||
#!/usr/bin/env python | ||
# Created by "Thieu" at 15:45, 15/08/2023 ----------% | ||
# Email: nguyenthieu2102@gmail.com % | ||
# Github: https://github.com/thieu1995 % | ||
# --------------------------------------------------% |
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,22 @@ | ||
#!/usr/bin/env python | ||
# Created by "Thieu" at 15:45, 15/08/2023 ----------% | ||
# Email: nguyenthieu2102@gmail.com % | ||
# Github: https://github.com/thieu1995 % | ||
# --------------------------------------------------% | ||
|
||
import numpy as np | ||
from intelelm import MhaElmClassifier | ||
|
||
np.random.seed(41) | ||
|
||
|
||
def test_MhaElmClassifier_class(): | ||
X = np.random.rand(100, 6) | ||
y = np.random.randint(0, 2, size=100) | ||
|
||
opt_paras = {"name": "GA", "epoch": 10, "pop_size": 30} | ||
model = MhaElmClassifier(hidden_size=10, act_name="elu", obj_name="AS", optimizer="BaseGA", optimizer_paras=opt_paras, verbose=False) | ||
model.fit(X, y) | ||
pred = model.predict(X) | ||
assert MhaElmClassifier.SUPPORTED_CLS_OBJECTIVES == model.SUPPORTED_CLS_OBJECTIVES | ||
assert pred[0] in (0, 1) |
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,24 @@ | ||
#!/usr/bin/env python | ||
# Created by "Thieu" at 15:45, 15/08/2023 ----------% | ||
# Email: nguyenthieu2102@gmail.com % | ||
# Github: https://github.com/thieu1995 % | ||
# --------------------------------------------------% | ||
|
||
import numpy as np | ||
from intelelm import MhaElmRegressor | ||
|
||
np.random.seed(42) | ||
|
||
|
||
def test_MhaElmRegressor_class(): | ||
X = np.random.uniform(low=0.0, high=1.0, size=(100, 5)) | ||
noise = np.random.normal(loc=0.0, scale=0.1, size=(100, 5)) | ||
y = 2 * X + 1 + noise | ||
|
||
opt_paras = {"name": "GA", "epoch": 10, "pop_size": 30} | ||
model = MhaElmRegressor(hidden_size=10, act_name="elu", obj_name="RMSE", optimizer="BaseGA", optimizer_paras=opt_paras, verbose=False) | ||
model.fit(X, y) | ||
|
||
pred = model.predict(X) | ||
assert MhaElmRegressor.SUPPORTED_REG_OBJECTIVES == model.SUPPORTED_REG_OBJECTIVES | ||
assert len(pred) == X.shape[0] |