Closed ganow closed 8 months ago
Moved /test/test_ml.py
to /test/ml/test_learning.py
and prepared the model parameter files for testing ModelTest
class.
commit hash: 4ce8a2f
Current problem
Since *.mat
is specified in .gitignore
, we cannot commit the data files. (how should we do?)
Moved
/test/test_ml.py
to/test/ml/test_learning.py
and prepared the model parameter files for testingModelTest
class. commit hash: 4ce8a2fCurrent problem Since
*.mat
is specified in.gitignore
, we cannot commit the data files. (how should we do?)
I have used the script as follows to prepare model parameter files:
import os
import numpy as np
from sklearn.linear_model import LinearRegression
from fastl2lir import FastL2LiR
from bdpy.ml import ModelTraining
X = np.random.rand(100, 500)
Y1dim = np.random.rand(100, 50)
Y4dim = np.random.rand(100, 8, 4, 4)
def run(model_type, format_, chunked):
key = f'{model_type}-{"chunk" if chunked else "nochunk"}-{format_}'
if model_type == 'lir':
model = LinearRegression()
elif model_type == 'fastl2lir':
model = FastL2LiR()
else:
raise ValueError(f'Unknown model type: {model_type}')
Y = Y4dim if chunked else Y1dim
train = ModelTraining(model, X, Y)
train.id = key
if model_type == 'fastl2lir':
train.model_parameters = {'alpha': 100, 'n_feat': 100}
train.dtype = np.float32
if chunked:
train.chunk_axis = 1
train.save_format = 'bdmodel' if format_ == 'bd' else 'pickle'
train.save_path = os.path.join('test/data/test_models', key)
train.run()
run('lir', 'pkl', False)
model_formats = ['pkl', 'bd']
chunked_options = [False, True]
for model_format in model_formats:
for chunked in chunked_options:
run('fastl2lir', model_format, chunked)
Coverage Report
Tests | Skipped | Failures | Errors | Time |
---|---|---|---|---|
114 | 0 :zzz: | 5 :x: | 0 :fire: | 9.859s :stopwatch: |
The following four files were not found in the current bdpy repository.
data/array_jl_dense_v1.mat
data/testdata-2d.pkl.gz
data/testdata-2d-nan.pkl.gz
./data/mri/epi.mat
@ShuntaroAoki Could you commit them to this branch (or could you tell me how to create these files)? I can handle the modifications to make the current test codes work with the files you commit.
==================================================================== short test summary info =====================================================================
FAILED tests/dataform/test_sparse.py::TestSparse::test_load_array_jl - FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = 'data/array_jl_dense_v1.mat', errno = 2, error message = 'No such file or direc...
FAILED tests/evals/test_metrics.py::TestMetrics::test_2d - FileNotFoundError: [Errno 2] No such file or directory: 'data/testdata-2d.pkl.gz'
FAILED tests/evals/test_metrics.py::TestMetrics::test_2d_nan - FileNotFoundError: [Errno 2] No such file or directory: 'data/testdata-2d-nan.pkl.gz'
ERROR tests/test_mri.py::TestMri::test_add_load_epi_pass0001 - FileNotFoundError: [Errno 2] No such file or directory: './data/mri/epi.mat'
ERROR tests/test_mri.py::TestMri::test_get_roiflag_pass0001 - FileNotFoundError: [Errno 2] No such file or directory: './data/mri/epi.mat'
ERROR tests/test_mri.py::TestMri::test_get_roiflag_pass0002 - FileNotFoundError: [Errno 2] No such file or directory: './data/mri/epi.mat'
===================================================== 3 failed, 104 passed, 70 warnings, 3 errors in 32.52s ======================================================
@ShuntaroAoki I've finished all of the refactoring of the test modules except the epi files. I would appreciate a review when you have time. Thank you.
Summary
model.pkl
->model.pkl.gz
)epi.mat
test
totests
tests/path/to/test_<src>.py
) are now responsible for their corresponding source file (bdpy/path/to/<src>.py
).