Skip to content

Commit ed41c1a

Browse files
authored
Clean & fix scikit-learn testing (#419)
1 parent d1f6d3d commit ed41c1a

File tree

4 files changed

+26
-30
lines changed

4 files changed

+26
-30
lines changed

.circleci/config.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
. ~/miniconda/etc/profile.d/conda.sh
2121
conda activate bld
2222
mkdir -p /tmp/out
23-
conda build --python=37 --override-channels -c conda-forge -c intel --numpy=1.17 --output-folder /tmp/out --no-test conda-recipe
23+
conda build --python=37 --override-channels -c intel -c conda-forge --numpy=1.17 --output-folder /tmp/out --no-test conda-recipe
2424
- run:
2525
name: Testing sklearn patches
2626
no_output_timeout: 20m
@@ -62,16 +62,15 @@ jobs:
6262
. ~/miniconda/etc/profile.d/conda.sh
6363
conda activate bld
6464
mkdir -p /tmp/out
65-
conda build --python=37 --override-channels -c conda-forge -c intel --numpy=1.17 --output-folder /tmp/out --no-test conda-recipe
65+
conda build --python=37 --override-channels -c intel -c conda-forge --numpy=1.17 --output-folder /tmp/out --no-test conda-recipe
6666
- run:
6767
name: Testing sklearn patches
6868
no_output_timeout: 20m
6969
command: |
7070
export PATH=~/miniconda/bin:$PATH
7171
. ~/miniconda/etc/profile.d/conda.sh
7272
conda activate bld
73-
conda install -y --override-channels -c intel cython
74-
conda install -y -c conda-forge threadpoolctl
73+
conda install -y -c conda-forge threadpoolctl cython
7574
git clone https://github.com/scikit-learn/scikit-learn.git
7675
pushd scikit-learn && python setup.py install && popd
7776
conda install -y /tmp/out/*/daal4py-*.tar.bz2

.circleci/setup_env.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ export PATH=~/miniconda/bin:$PATH
55
hash -r
66
conda config --set always_yes yes --set changeps1 no
77
conda update -q conda
8-
conda install -q conda-build
9-
conda create -n bld --override-channels -c intel daal daal-devel
10-
conda install -q -n bld --override-channels -c defaults python=3.7 numpy scipy pytest pandas pyyaml joblib numpydoc
11-
conda install -q -n bld -c conda-forge --override-channels mpi mpich
8+
conda create -n bld python=3.7 conda-build
9+
source activate bld
10+
conda install -q --override-channels -c defaults numpy scipy pytest pandas pyyaml joblib numpydoc
11+
conda install -q --override-channels -c intel dal
1212
gcc -v
1313
g++ -v
1414
head /proc/cpuinfo

daal4py/sklearn/monkeypatch/dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ def _get_map_of_algorithms():
9797
'fin_check': [[(validation, '_assert_all_finite', _daal_assert_all_finite), None]],
9898
'tsne': [[(manifold_module, 'TSNE', TSNE_daal4py), None]],
9999
}
100-
if daal_check_version((2021,'P', 1)):
100+
if daal_check_version((2021,'P', 100)):
101101
mapping['log_reg'] = [[(linear_model_module, 'LogisticRegression', LogisticRegression_daal4py), None]]
102-
if daal_check_version((2021,'P', 2)):
102+
if daal_check_version((2021,'P', 200)):
103103
mapping['roc_auc_score'] = [[(metrics, 'roc_auc_score', _daal_roc_auc_score), None]]
104104
return mapping
105105

src/daal4py.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,17 @@ static PyObject * _make_nda_from_csr(daal::data_management::NumericTablePtr * pt
166166
size_t n = csr_ptr->getDataSize();
167167
T * data_copy = static_cast<T *>(daal::services::daal_malloc(n * sizeof(T)));
168168
DAAL4PY_CHECK_MALLOC(data_copy);
169-
daal::services::internal::daal_memcpy_s(data_ptr,
170-
sizeof(T) * n,
171-
data_copy,
172-
sizeof(T) * n);
173-
PyObject * py_data = _make_npy_from_data<T, NPTYPE>(data_copy, n);
174-
n = csr_ptr->getNumberOfColumns();
169+
daal::services::internal::daal_memcpy_s(data_ptr, sizeof(T) * n, data_copy, sizeof(T) * n);
170+
PyObject * py_data = _make_npy_from_data<T, NPTYPE>(data_copy, n);
171+
n = csr_ptr->getNumberOfColumns();
175172
size_t * col_indices_copy = static_cast<size_t *>(daal::services::daal_malloc(n * sizeof(size_t)));
176173
DAAL4PY_CHECK_MALLOC(col_indices_copy);
177174
for (size_t i = 0; i < n; ++i)
178175
{
179176
col_indices_copy[i] = col_indices_ptr[i] - 1;
180177
}
181-
PyObject * py_col = _make_npy_from_data<size_t, NPTYPE>(col_indices_copy, n);
182-
n = csr_ptr->getNumberOfRows();
178+
PyObject * py_col = _make_npy_from_data<size_t, NPTYPE>(col_indices_copy, n);
179+
n = csr_ptr->getNumberOfRows();
183180
size_t * row_offsets_copy = static_cast<size_t *>(daal::services::daal_malloc(n * sizeof(size_t)));
184181
DAAL4PY_CHECK_MALLOC(row_offsets_copy);
185182
for (size_t i = 0; i < n; ++i)
@@ -831,12 +828,12 @@ extern "C"
831828
bool c_assert_all_finite(const data_or_file & t, bool allowNaN, char dtype)
832829
{
833830
bool result = false;
834-
auto tab = get_table(t);
831+
auto tab = get_table(t);
835832
switch (dtype)
836833
{
837-
case 0: result = daal::data_management::internal::allValuesAreFinite<double>(*tab, allowNaN); break;
838-
case 1: result = daal::data_management::internal::allValuesAreFinite<float>(*tab, allowNaN); break;
839-
default: throw std::invalid_argument("Invalid data type specified.");
834+
case 0: result = daal::data_management::internal::allValuesAreFinite<double>(*tab, allowNaN); break;
835+
case 1: result = daal::data_management::internal::allValuesAreFinite<float>(*tab, allowNaN); break;
836+
default: throw std::invalid_argument("Invalid data type specified.");
840837
}
841838
return result;
842839
}
@@ -859,27 +856,27 @@ double c_roc_auc_score(data_or_file & y_true, data_or_file & y_test)
859856
const size_t col_test = y_test.table->getNumberOfColumns();
860857
const size_t row_test = y_test.table->getNumberOfRows();
861858

862-
if (row_true != 1 || row_test != 1 || col_true != col_test) {
859+
if (row_true != 1 || row_test != 1 || col_true != col_test)
860+
{
863861
PyErr_SetString(PyExc_RuntimeError, "Unknown shape data");
864862
return NULL;
865863
}
866864

867865
auto table_true = get_table(y_true);
868866
auto table_test = get_table(y_test);
869-
auto type = (*table_test->getDictionary())[0].indexType;
870-
if (type == daal::data_management::data_feature_utils::DAAL_FLOAT64 ||
871-
type == daal::data_management::data_feature_utils::DAAL_INT64_S ||
872-
type == daal::data_management::data_feature_utils::DAAL_INT64_U)
867+
auto type = (*table_test->getDictionary())[0].indexType;
868+
if (type == daal::data_management::data_feature_utils::DAAL_FLOAT64 || type == daal::data_management::data_feature_utils::DAAL_INT64_S || type == daal::data_management::data_feature_utils::DAAL_INT64_U)
873869
{
874870
return daal::data_management::internal::rocAucScore<double>(table_true, table_test);
875-
} else if (type == daal::data_management::data_feature_utils::DAAL_FLOAT32 ||
876-
type == daal::data_management::data_feature_utils::DAAL_INT32_S ||
877-
type == daal::data_management::data_feature_utils::DAAL_INT32_U)
871+
}
872+
else if (type == daal::data_management::data_feature_utils::DAAL_FLOAT32 || type == daal::data_management::data_feature_utils::DAAL_INT32_S || type == daal::data_management::data_feature_utils::DAAL_INT32_U)
878873
{
879874
return daal::data_management::internal::rocAucScore<float>(table_true, table_test);
880875
}
881876
PyErr_SetString(PyExc_RuntimeError, "Unknown shape data");
882877
return NULL;
878+
#else
879+
return NULL;
883880
#endif
884881
}
885882

0 commit comments

Comments
 (0)