From 532dbf02209ab872bf1c3831354a0032f0ae0dd7 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Fri, 14 Jul 2023 07:19:59 -0700 Subject: [PATCH 01/18] initial --- doc/daal4py/algorithms.rst | 126 +++++++++--------- doc/daal4py/examples.rst | 80 +++++------ .../{adaboost_batch.py => adaboost.py} | 0 .../{adagrad_mse_batch.py => adagrad_mse.py} | 0 ...on_rules_batch.py => association_rules.py} | 0 ...acon_outlier_batch.py => bacon_outlier.py} | 0 ...tion_batch.py => bf_knn_classification.py} | 0 .../{brownboost_batch.py => brownboost.py} | 0 .../{cholesky_batch.py => cholesky.py} | 0 ...tance_batch.py => correlation_distance.py} | 0 ...e_distance_batch.py => cosine_distance.py} | 0 .../{covariance_batch.py => covariance.py} | 0 .../daal4py/{dbscan_batch.py => dbscan.py} | 0 ...on_forest_classification_default_dense.py} | 0 ...=> decision_forest_classification_hist.py} | 0 ...ecision_forest_classification_traverse.py} | 0 ...cision_forest_regression_default_dense.py} | 0 ....py => decision_forest_regression_hist.py} | 0 ...=> decision_forest_regression_traverse.py} | 0 ...tch.py => decision_tree_classification.py} | 0 ... decision_tree_classification_traverse.py} | 0 ...n_batch.py => decision_tree_regression.py} | 0 ...y => decision_tree_regression_traverse.py} | 2 +- ...li_batch.py => distributions_bernoulli.py} | 0 ...ormal_batch.py => distributions_normal.py} | 0 ...form_batch.py => distributions_uniform.py} | 0 .../{elastic_net_batch.py => elastic_net.py} | 0 .../daal4py/{em_gmm_batch.py => em_gmm.py} | 0 ....py => gradient_boosted_classification.py} | 0 ...adient_boosted_classification_traverse.py} | 0 ...atch.py => gradient_boosted_regression.py} | 0 ...> gradient_boosted_regression_traverse.py} | 0 ...{implicit_als_batch.py => implicit_als.py} | 0 ..._batch.py => kdtree_knn_classification.py} | 0 .../daal4py/{kmeans_batch.py => kmeans.py} | 0 ...egression_batch.py => lasso_regression.py} | 0 ...tr_loss_batch.py => lbfgs_cr_entr_loss.py} | 0 .../{lbfgs_mse_batch.py => lbfgs_mse.py} | 0 ...gression_batch.py => linear_regression.py} | 0 ...dense_batch.py => log_reg_binary_dense.py} | 0 ...og_reg_dense_batch.py => log_reg_dense.py} | 0 .../{logitboost_batch.py => logitboost.py} | 0 ...dense_batch.py => low_order_moms_dense.py} | 0 ...tlier_batch.py => multivariate_outlier.py} | 0 .../{naive_bayes_batch.py => naive_bayes.py} | 0 ...inmax_batch.py => normalization_minmax.py} | 0 ...score_batch.py => normalization_zscore.py} | 0 examples/daal4py/{pca_batch.py => pca.py} | 0 ...ca_transform_batch.py => pca_transform.py} | 0 .../{pivoted_qr_batch.py => pivoted_qr.py} | 0 examples/daal4py/{qr_batch.py => qr.py} | 0 .../{quantiles_batch.py => quantiles.py} | 0 ...egression_batch.py => ridge_regression.py} | 0 examples/daal4py/{saga_batch.py => saga.py} | 0 ...tic_loss_batch.py => sgd_logistic_loss.py} | 0 .../daal4py/{sgd_mse_batch.py => sgd_mse.py} | 0 .../daal4py/{sorting_batch.py => sorting.py} | 0 ...ation_batch.py => stump_classification.py} | 0 ...egression_batch.py => stump_regression.py} | 0 examples/daal4py/{svd_batch.py => svd.py} | 0 examples/daal4py/{svm_batch.py => svm.py} | 0 ..._multiclass_batch.py => svm_multiclass.py} | 0 ...outlier_batch.py => univariate_outlier.py} | 0 tests/run_examples.py | 35 +++-- 64 files changed, 120 insertions(+), 123 deletions(-) rename examples/daal4py/{adaboost_batch.py => adaboost.py} (100%) rename examples/daal4py/{adagrad_mse_batch.py => adagrad_mse.py} (100%) rename examples/daal4py/{association_rules_batch.py => association_rules.py} (100%) rename examples/daal4py/{bacon_outlier_batch.py => bacon_outlier.py} (100%) rename examples/daal4py/{bf_knn_classification_batch.py => bf_knn_classification.py} (100%) rename examples/daal4py/{brownboost_batch.py => brownboost.py} (100%) rename examples/daal4py/{cholesky_batch.py => cholesky.py} (100%) rename examples/daal4py/{correlation_distance_batch.py => correlation_distance.py} (100%) rename examples/daal4py/{cosine_distance_batch.py => cosine_distance.py} (100%) rename examples/daal4py/{covariance_batch.py => covariance.py} (100%) rename examples/daal4py/{dbscan_batch.py => dbscan.py} (100%) rename examples/daal4py/{decision_forest_classification_default_dense_batch.py => decision_forest_classification_default_dense.py} (100%) rename examples/daal4py/{decision_forest_classification_hist_batch.py => decision_forest_classification_hist.py} (100%) rename examples/daal4py/{decision_forest_classification_traverse_batch.py => decision_forest_classification_traverse.py} (100%) rename examples/daal4py/{decision_forest_regression_default_dense_batch.py => decision_forest_regression_default_dense.py} (100%) rename examples/daal4py/{decision_forest_regression_hist_batch.py => decision_forest_regression_hist.py} (100%) rename examples/daal4py/{decision_forest_regression_traverse_batch.py => decision_forest_regression_traverse.py} (100%) rename examples/daal4py/{decision_tree_classification_batch.py => decision_tree_classification.py} (100%) rename examples/daal4py/{decision_tree_classification_traverse_batch.py => decision_tree_classification_traverse.py} (100%) rename examples/daal4py/{decision_tree_regression_batch.py => decision_tree_regression.py} (100%) rename examples/daal4py/{decision_tree_regression_traverse_batch.py => decision_tree_regression_traverse.py} (96%) rename examples/daal4py/{distributions_bernoulli_batch.py => distributions_bernoulli.py} (100%) rename examples/daal4py/{distributions_normal_batch.py => distributions_normal.py} (100%) rename examples/daal4py/{distributions_uniform_batch.py => distributions_uniform.py} (100%) rename examples/daal4py/{elastic_net_batch.py => elastic_net.py} (100%) rename examples/daal4py/{em_gmm_batch.py => em_gmm.py} (100%) rename examples/daal4py/{gradient_boosted_classification_batch.py => gradient_boosted_classification.py} (100%) rename examples/daal4py/{gradient_boosted_classification_traverse_batch.py => gradient_boosted_classification_traverse.py} (100%) rename examples/daal4py/{gradient_boosted_regression_batch.py => gradient_boosted_regression.py} (100%) rename examples/daal4py/{gradient_boosted_regression_traverse_batch.py => gradient_boosted_regression_traverse.py} (100%) rename examples/daal4py/{implicit_als_batch.py => implicit_als.py} (100%) rename examples/daal4py/{kdtree_knn_classification_batch.py => kdtree_knn_classification.py} (100%) rename examples/daal4py/{kmeans_batch.py => kmeans.py} (100%) rename examples/daal4py/{lasso_regression_batch.py => lasso_regression.py} (100%) rename examples/daal4py/{lbfgs_cr_entr_loss_batch.py => lbfgs_cr_entr_loss.py} (100%) rename examples/daal4py/{lbfgs_mse_batch.py => lbfgs_mse.py} (100%) rename examples/daal4py/{linear_regression_batch.py => linear_regression.py} (100%) rename examples/daal4py/{log_reg_binary_dense_batch.py => log_reg_binary_dense.py} (100%) rename examples/daal4py/{log_reg_dense_batch.py => log_reg_dense.py} (100%) rename examples/daal4py/{logitboost_batch.py => logitboost.py} (100%) rename examples/daal4py/{low_order_moms_dense_batch.py => low_order_moms_dense.py} (100%) rename examples/daal4py/{multivariate_outlier_batch.py => multivariate_outlier.py} (100%) rename examples/daal4py/{naive_bayes_batch.py => naive_bayes.py} (100%) rename examples/daal4py/{normalization_minmax_batch.py => normalization_minmax.py} (100%) rename examples/daal4py/{normalization_zscore_batch.py => normalization_zscore.py} (100%) rename examples/daal4py/{pca_batch.py => pca.py} (100%) rename examples/daal4py/{pca_transform_batch.py => pca_transform.py} (100%) rename examples/daal4py/{pivoted_qr_batch.py => pivoted_qr.py} (100%) rename examples/daal4py/{qr_batch.py => qr.py} (100%) rename examples/daal4py/{quantiles_batch.py => quantiles.py} (100%) rename examples/daal4py/{ridge_regression_batch.py => ridge_regression.py} (100%) rename examples/daal4py/{saga_batch.py => saga.py} (100%) rename examples/daal4py/{sgd_logistic_loss_batch.py => sgd_logistic_loss.py} (100%) rename examples/daal4py/{sgd_mse_batch.py => sgd_mse.py} (100%) rename examples/daal4py/{sorting_batch.py => sorting.py} (100%) rename examples/daal4py/{stump_classification_batch.py => stump_classification.py} (100%) rename examples/daal4py/{stump_regression_batch.py => stump_regression.py} (100%) rename examples/daal4py/{svd_batch.py => svd.py} (100%) rename examples/daal4py/{svm_batch.py => svm.py} (100%) rename examples/daal4py/{svm_multiclass_batch.py => svm_multiclass.py} (100%) rename examples/daal4py/{univariate_outlier_batch.py => univariate_outlier.py} (100%) diff --git a/doc/daal4py/algorithms.rst b/doc/daal4py/algorithms.rst index 7698d1d224..3e96f12239 100755 --- a/doc/daal4py/algorithms.rst +++ b/doc/daal4py/algorithms.rst @@ -29,9 +29,9 @@ Parameters and semantics are described in |onedal-dg-classification-decision-for .. rubric:: Examples: - `Single-Process Decision Forest Classification Default Dense method - `__ + `__ - `Single-Process Decision Forest Classification Histogram method - `__ + `__ .. autoclass:: daal4py.decision_forest_classification_training :members: compute @@ -51,7 +51,7 @@ Parameters and semantics are described in |onedal-dg-classification-decision-tre .. rubric:: Examples: - `Single-Process Decision Tree Classification - `__ + `__ .. autoclass:: daal4py.decision_tree_classification_training :members: compute @@ -71,7 +71,7 @@ Parameters and semantics are described in |onedal-dg-classification-gradient-boo .. rubric:: Examples: - `Single-Process Gradient Boosted Classification - `__ + `__ .. autoclass:: daal4py.gbt_classification_training :members: compute @@ -91,7 +91,7 @@ Parameters and semantics are described in |onedal-dg-k-nearest-neighbors-knn|_. .. rubric:: Examples: - `Single-Process kNN - `__ + `__ .. autoclass:: daal4py.kdtree_knn_classification_training :members: compute @@ -126,7 +126,7 @@ Parameters and semantics are described in |onedal-dg-classification-adaboost|_. .. rubric:: Examples: - `Single-Process AdaBoost Classification - `__ + `__ .. autoclass:: daal4py.adaboost_training :members: compute @@ -146,7 +146,7 @@ Parameters and semantics are described in |onedal-dg-classification-brownboost|_ .. rubric:: Examples: - `Single-Process BrownBoost Classification - `__ + `__ .. autoclass:: daal4py.brownboost_training :members: compute @@ -166,7 +166,7 @@ Parameters and semantics are described in |onedal-dg-classification-logitboost|_ .. rubric:: Examples: - `Single-Process LogitBoost Classification - `__ + `__ .. autoclass:: daal4py.logitboost_training :members: compute @@ -186,7 +186,7 @@ Parameters and semantics are described in |onedal-dg-classification-weak-learner .. rubric:: Examples: - `Single-Process Stump Weak Learner Classification - `__ + `__ .. autoclass:: daal4py.stump_classification_training :members: compute @@ -205,7 +205,7 @@ Parameters and semantics are described in |onedal-dg-naive-bayes|_. .. rubric:: Examples: -- `Single-Process Naive Bayes `__ +- `Single-Process Naive Bayes `__ - `Streaming Naive Bayes `__ - `Multi-Process Naive Bayes `__ @@ -229,7 +229,7 @@ Note: For the labels parameter, data is formatted as -1s and 1s .. rubric:: Examples: - `Single-Process SVM - `__ + `__ .. autoclass:: daal4py.svm_training :members: compute @@ -249,9 +249,9 @@ Parameters and semantics are described in |onedal-dg-logistic-regression|_. .. rubric:: Examples: - `Single-Process Binary Class Logistic Regression - `__ + `__ - `Single-Process Logistic Regression - `__ + `__ .. autoclass:: daal4py.logistic_regression_training :members: compute @@ -275,9 +275,9 @@ Parameters and semantics are described in |onedal-dg-regression-decision-forest| .. rubric:: Examples: - `Single-Process Decision Forest Regression Default Dense method - `__ + `__ - `Single-Process Decision Forest Regression Histogram method - `__ + `__ .. autoclass:: daal4py.decision_forest_regression_training :members: compute @@ -297,7 +297,7 @@ Parameters and semantics are described in |onedal-dg-regression-decision-tree|_. .. rubric:: Examples: - `Single-Process Decision Tree Regression - `__ + `__ .. autoclass:: daal4py.decision_tree_regression_training :members: compute @@ -317,7 +317,7 @@ Parameters and semantics are described in |onedal-dg-regression-gradient-boosted .. rubric:: Examples: - `Single-Process Boosted Regression Regression - `__ + `__ .. autoclass:: daal4py.gbt_regression_training :members: compute @@ -336,7 +336,7 @@ Parameters and semantics are described in |onedal-dg-linear-regression|_. .. rubric:: Examples: -- `Single-Process Linear Regression `__ +- `Single-Process Linear Regression `__ - `Streaming Linear Regression `__ - `Multi-Process Linear Regression `__ @@ -357,7 +357,7 @@ Parameters and semantics are described in |onedal-dg-least-absolute-shrinkage-an .. rubric:: Examples: -- `Single-Process LASSO Regression `__ +- `Single-Process LASSO Regression `__ .. autoclass:: daal4py.lasso_regression_training :members: compute @@ -376,7 +376,7 @@ Parameters and semantics are described in |onedal-dg-ridge-regression|_. .. rubric:: Examples: -- `Single-Process Ridge Regression `__ +- `Single-Process Ridge Regression `__ - `Streaming Ridge Regression `__ - `Multi-Process Ridge Regression `__ @@ -398,7 +398,7 @@ Parameters and semantics are described in |onedal-dg-regression-stump|_. .. rubric:: Examples: - `Single-Process Stump Regression - `__ + `__ .. autoclass:: daal4py.stump_regression_training :members: compute @@ -417,7 +417,7 @@ Parameters and semantics are described in |onedal-dg-pca|_. .. rubric:: Examples: -- `Single-Process PCA `__ +- `Single-Process PCA `__ - `Multi-Process PCA `__ .. autoclass:: daal4py.pca @@ -431,7 +431,7 @@ Parameters and semantics are described in |onedal-dg-pca-transform|_. .. rubric:: Examples: -- `Single-Process PCA Transform `__ +- `Single-Process PCA Transform `__ .. autoclass:: daal4py.pca_transform :members: compute @@ -444,7 +444,7 @@ Parameters and semantics are described in |onedal-dg-k-means-clustering|_. .. rubric:: Examples: -- `Single-Process K-Means `__ +- `Single-Process K-Means `__ - `Multi-Process K-Means `__ K-Means Initialization @@ -471,7 +471,7 @@ Parameters and semantics are described in |onedal-dg-density-based-spatial-clust .. rubric:: Examples: -- `Single-Process DBSCAN `__ +- `Single-Process DBSCAN `__ .. autoclass:: daal4py.dbscan :members: compute @@ -486,7 +486,7 @@ Parameters and semantics are described in |onedal-dg-multivariate-outlier-detect .. rubric:: Examples: -- `Single-Process Multivariate Outlier Detection `__ +- `Single-Process Multivariate Outlier Detection `__ .. autoclass:: daal4py.multivariate_outlier_detection :members: compute @@ -499,7 +499,7 @@ Parameters and semantics are described in |onedal-dg-univariate-outlier-detectio .. rubric:: Examples: -- `Single-Process Univariate Outlier Detection `__ +- `Single-Process Univariate Outlier Detection `__ .. autoclass:: daal4py.univariate_outlier_detection :members: compute @@ -512,7 +512,7 @@ Parameters and semantics are described in |onedal-dg-multivariate-bacon-outlier- .. rubric:: Examples: -- `Single-Process Bacon Outlier Detection `__ +- `Single-Process Bacon Outlier Detection `__ .. autoclass:: daal4py.bacon_outlier_detection :members: compute @@ -528,9 +528,9 @@ Mean Squared Error Algorithm (MSE) Parameters and semantics are described in |onedal-dg-mse|_. .. rubric:: Examples: -- `In Adagrad `__ -- `In LBFGS `__ -- `In SGD `__ +- `In Adagrad `__ +- `In LBFGS `__ +- `In SGD `__ .. autoclass:: daal4py.optimization_solver_mse :members: compute, setup @@ -542,7 +542,7 @@ Logistic Loss Parameters and semantics are described in |onedal-dg-logistic-loss|_. .. rubric:: Examples: -- `In SGD `__ +- `In SGD `__ .. autoclass:: daal4py.optimization_solver_logistic_loss :members: compute, setup @@ -554,7 +554,7 @@ Cross-entropy Loss Parameters and semantics are described in |onedal-dg-cross-entropy-loss|_. .. rubric:: Examples: -- `In LBFGS `__ +- `In LBFGS `__ .. autoclass:: daal4py.optimization_solver_cross_entropy_loss :members: compute, setup @@ -568,8 +568,8 @@ Stochastic Gradient Descent Algorithm Parameters and semantics are described in |onedal-dg-sgd|_. .. rubric:: Examples: -- `Using Logistic Loss `__ -- `Using MSE `__ +- `Using Logistic Loss `__ +- `Using MSE `__ .. autoclass:: daal4py.optimization_solver_sgd :members: compute @@ -581,7 +581,7 @@ Limited-Memory Broyden-Fletcher-Goldfarb-Shanno Algorithm Parameters and semantics are described in |onedal-dg-lbfgs|_. .. rubric:: Examples: -- `Using MSE `__ +- `Using MSE `__ .. autoclass:: daal4py.optimization_solver_lbfgs :members: compute @@ -593,7 +593,7 @@ Adaptive Subgradient Method Parameters and semantics are described in |onedal-dg-adagrad|_. .. rubric:: Examples: -- `Using MSE `__ +- `Using MSE `__ .. autoclass:: daal4py.optimization_solver_adagrad :members: compute @@ -605,7 +605,7 @@ Stochastic Average Gradient Descent Parameters and semantics are described in |onedal-dg-stochastic-average-gradient-descent-saga|_. .. rubric:: Examples: -- `Single Proces saga-logistc_loss `__ +- `Single Proces saga-logistc_loss `__ .. autoclass:: daal4py.optimization_solver_saga :members: compute @@ -620,7 +620,7 @@ Parameters and semantics are described in |onedal-dg-cosine-distance|_. .. rubric:: Examples: -- `Single-Process Cosine Distance `__ +- `Single-Process Cosine Distance `__ .. autoclass:: daal4py.cosine_distance :members: compute @@ -633,7 +633,7 @@ Parameters and semantics are described in |onedal-dg-correlation-distance|_. .. rubric:: Examples: -- `Single-Process Correlation Distance `__ +- `Single-Process Correlation Distance `__ .. autoclass:: daal4py.correlation_distance :members: compute @@ -650,7 +650,7 @@ Parameters and semantics are described in |onedal-dg-expectation-maximization-in .. rubric:: Examples: -- `Single-Process Expectation-Maximization `__ +- `Single-Process Expectation-Maximization `__ .. autoclass:: daal4py.em_gmm_init :members: compute @@ -663,7 +663,7 @@ Parameters and semantics are described in |onedal-dg-expectation-maximization-fo .. rubric:: Examples: -- `Single-Process Expectation-Maximization `__ +- `Single-Process Expectation-Maximization `__ .. autoclass:: daal4py.em_gmm :members: compute @@ -680,7 +680,7 @@ Parameters and semantics are described in |onedal-dg-qr-decomposition-without-pi .. rubric:: Examples: -- `Single-Process QR `__ +- `Single-Process QR `__ - `Streaming QR `__ .. autoclass:: daal4py.qr @@ -694,7 +694,7 @@ Parameters and semantics are described in |onedal-dg-pivoted-qr-decomposition|_. .. rubric:: Examples: -- `Single-Process Pivoted QR `__ +- `Single-Process Pivoted QR `__ .. autoclass:: daal4py.pivoted_qr :members: compute @@ -711,7 +711,7 @@ Parameters and semantics are described in |onedal-dg-z-score|_. .. rubric:: Examples: -- `Single-Process Z-Score Normalization `__ +- `Single-Process Z-Score Normalization `__ .. autoclass:: daal4py.normalization_zscore :members: compute @@ -724,7 +724,7 @@ Parameters and semantics are described in |onedal-dg-min-max|_. .. rubric:: Examples: -- `Single-Process Min-Max Normalization `__ +- `Single-Process Min-Max Normalization `__ .. autoclass:: daal4py.normalization_minmax :members: compute @@ -775,7 +775,7 @@ Parameters and semantics are described in |onedal-dg-bernoulli-distribution|_. .. rubric:: Examples: -- `Single-Process Bernoulli Distribution `__ +- `Single-Process Bernoulli Distribution `__ .. autoclass:: daal4py.distributions_bernoulli :members: compute @@ -788,7 +788,7 @@ Parameters and semantics are described in |onedal-dg-normal-distribution|_. .. rubric:: Examples: -- `Single-Process Normal Distribution `__ +- `Single-Process Normal Distribution `__ .. autoclass:: daal4py.distributions_normal :members: compute @@ -801,7 +801,7 @@ Parameters and semantics are described in |onedal-dg-uniform-distribution|_. .. rubric:: Examples: -- `Single-Process Uniform Distribution `__ +- `Single-Process Uniform Distribution `__ .. autoclass:: daal4py.distributions_uniform :members: compute @@ -814,7 +814,7 @@ Parameters and semantics are described in |onedal-dg-association-rules|_. .. rubric:: Examples: -- `Single-Process Association Rules `__ +- `Single-Process Association Rules `__ .. autoclass:: daal4py.association_rules :members: compute @@ -827,7 +827,7 @@ Parameters and semantics are described in |onedal-dg-cholesky-decomposition|_. .. rubric:: Examples: -- `Single-Process Cholesky `__ +- `Single-Process Cholesky `__ .. autoclass:: daal4py.cholesky :members: compute @@ -840,7 +840,7 @@ Parameters and semantics are described in |onedal-dg-correlation-and-variance-co .. rubric:: Examples: -- `Single-Process Covariance `__ +- `Single-Process Covariance `__ - `Streaming Covariance `__ - `Multi-Process Covariance `__ @@ -855,7 +855,7 @@ Parameters and semantics are described in |onedal-dg-implicit-alternating-least- .. rubric:: Examples: -- `Single-Process implicit ALS `__ +- `Single-Process implicit ALS `__ .. autoclass:: daal4py.implicit_als_training :members: compute @@ -874,7 +874,7 @@ Parameters and semantics are described in |onedal-dg-moments-of-low-order|_. .. rubric:: Examples: -- `Single-Process Low Order Moments `__ +- `Single-Process Low Order Moments `__ - `Streaming Low Order Moments `__ - `Multi-Process Low Order Moments `__ @@ -889,7 +889,7 @@ Parameters and semantics are described in |onedal-dg-quantiles|_. .. rubric:: Examples: -- `Single-Process Quantiles `__ +- `Single-Process Quantiles `__ .. autoclass:: daal4py.quantiles :members: compute @@ -902,7 +902,7 @@ Parameters and semantics are described in |onedal-dg-svd|_. .. rubric:: Examples: -- `Single-Process SVD `__ +- `Single-Process SVD `__ - `Streaming SVD `__ - `Multi-Process SVD `__ @@ -917,7 +917,7 @@ Parameters and semantics are described in |onedal-dg-sorting|_. .. rubric:: Examples: -- `Single-Process Sorting `__ +- `Single-Process Sorting `__ .. autoclass:: daal4py.sorting :members: compute @@ -930,12 +930,12 @@ Trees .. rubric:: Examples: -- `Decision Forest Regression `__ -- `Decision Forest Classification `__ -- `Decision Tree Regression `__ -- `Decision Tree Classification `__ -- `Gradient Boosted Trees Regression `__ -- `Gradient Boosted Trees Classification `__ +- `Decision Forest Regression `__ +- `Decision Forest Classification `__ +- `Decision Tree Regression `__ +- `Decision Tree Classification `__ +- `Gradient Boosted Trees Regression `__ +- `Gradient Boosted Trees Classification `__ .. Link replacements diff --git a/doc/daal4py/examples.rst b/doc/daal4py/examples.rst index 792c15a138..bc7bfbfef0 100755 --- a/doc/daal4py/examples.rst +++ b/doc/daal4py/examples.rst @@ -32,148 +32,148 @@ Building models from Gradient Boosting frameworks Principal Component Analysis (PCA) Transform -- `Single-Process PCA `_ +- `Single-Process PCA `_ - `Multi-Process PCA `_ Singular Value Decomposition (SVD) -- `Single-Process PCA Transform `_ +- `Single-Process PCA Transform `_ -- `Single-Process SVD `_ +- `Single-Process SVD `_ - `Streaming SVD `_ - `Multi-Process SVD `_ Moments of Low Order -- `Single-Process Low Order Moments `_ +- `Single-Process Low Order Moments `_ - `Streaming Low Order Moments `_ - `Multi-Process Low Order Moments `_ Correlation and Variance-Covariance Matrices -- `Single-Process Covariance `_ +- `Single-Process Covariance `_ - `Streaming Covariance `_ - `Multi-Process Covariance `_ Decision Forest Classification - `Single-Process Decision Forest Classification Default Dense method - `_ + `_ - `Single-Process Decision Forest Classification Histogram method - `_ + `_ Decision Tree Classification - `Single-Process Decision Tree Classification - `_ + `_ Gradient Boosted Classification - `Single-Process Gradient Boosted Classification - `_ + `_ k-Nearest Neighbors (kNN) - `Single-Process kNN - `_ + `_ Multinomial Naive Bayes -- `Single-Process Naive Bayes `_ +- `Single-Process Naive Bayes `_ - `Streaming Naive Bayes `_ - `Multi-Process Naive Bayes `_ Support Vector Machine (SVM) - `Single-Process Binary SVM - `_ + `_ - `Single-Process Muticlass SVM - `_ + `_ Logistic Regression - `Single-Process Binary Class Logistic Regression - `_ + `_ - `Single-Process Logistic Regression - `_ + `_ Decision Forest Regression - `Single-Process Decision Forest Regression Default Dense method - `_ + `_ - `Single-Process Decision Forest Regression Histogram method - `_ + `_ - `Single-Process Decision Tree Regression - `_ + `_ Gradient Boosted Regression - `Single-Process Boosted Regression - `_ + `_ Linear Regression -- `Single-Process Linear Regression `_ +- `Single-Process Linear Regression `_ - `Streaming Linear Regression `_ - `Multi-Process Linear Regression `_ Ridge Regression -- `Single-Process Ridge Regression `_ +- `Single-Process Ridge Regression `_ - `Streaming Ridge Regression `_ - `Multi-Process Ridge Regression `_ K-Means Clustering -- `Single-Process K-Means `_ +- `Single-Process K-Means `_ - `Multi-Process K-Means `_ Multivariate Outlier Detection -- `Single-Process Multivariate Outlier Detection `_ +- `Single-Process Multivariate Outlier Detection `_ Univariate Outlier Detection -- `Single-Process Univariate Outlier Detection `_ +- `Single-Process Univariate Outlier Detection `_ Optimization Solvers-Mean Squared Error Algorithm (MSE) -- `MSE In Adagrad `_ -- `MSE In LBFGS `_ -- `MSE In SGD `_ +- `MSE In Adagrad `_ +- `MSE In LBFGS `_ +- `MSE In SGD `_ Logistic Loss -- `Logistic Loss SGD `_ +- `Logistic Loss SGD `_ Stochastic Gradient Descent Algorithm -- `Stochastic Gradient Descent Algorithm Using Logistic Loss `_ -- `Stochastic Gradient Descent Algorithm Using MSE `_ +- `Stochastic Gradient Descent Algorithm Using Logistic Loss `_ +- `Stochastic Gradient Descent Algorithm Using MSE `_ Limited-Memory Broyden-Fletcher-Goldfarb-Shanno Algorithm -- `Limited-Memory Broyden-Fletcher-Goldfarb-Shanno Algorithm - Using MSE `_ +- `Limited-Memory Broyden-Fletcher-Goldfarb-Shanno Algorithm - Using MSE `_ Adaptive Subgradient Method -- `Adaptive Subgradient Method Using MSE `_ +- `Adaptive Subgradient Method Using MSE `_ Cosine Distance Matrix -- `Single-Process Cosine Distance `_ +- `Single-Process Cosine Distance `_ Correlation Distance Matrix -- `Single-Process Correlation Distance `_ +- `Single-Process Correlation Distance `_ Trees -- `Decision Forest Regression `_ -- `Decision Forest Classification `_ -- `Decision Tree Regression `_ -- `Decision Tree Classification `_ -- `Gradient Boosted Trees Regression `_ -- `Gradient Boosted Trees Classification `_ +- `Decision Forest Regression `_ +- `Decision Forest Classification `_ +- `Decision Tree Regression `_ +- `Decision Tree Classification `_ +- `Gradient Boosted Trees Regression `_ +- `Gradient Boosted Trees Classification `_ diff --git a/examples/daal4py/adaboost_batch.py b/examples/daal4py/adaboost.py similarity index 100% rename from examples/daal4py/adaboost_batch.py rename to examples/daal4py/adaboost.py diff --git a/examples/daal4py/adagrad_mse_batch.py b/examples/daal4py/adagrad_mse.py similarity index 100% rename from examples/daal4py/adagrad_mse_batch.py rename to examples/daal4py/adagrad_mse.py diff --git a/examples/daal4py/association_rules_batch.py b/examples/daal4py/association_rules.py similarity index 100% rename from examples/daal4py/association_rules_batch.py rename to examples/daal4py/association_rules.py diff --git a/examples/daal4py/bacon_outlier_batch.py b/examples/daal4py/bacon_outlier.py similarity index 100% rename from examples/daal4py/bacon_outlier_batch.py rename to examples/daal4py/bacon_outlier.py diff --git a/examples/daal4py/bf_knn_classification_batch.py b/examples/daal4py/bf_knn_classification.py similarity index 100% rename from examples/daal4py/bf_knn_classification_batch.py rename to examples/daal4py/bf_knn_classification.py diff --git a/examples/daal4py/brownboost_batch.py b/examples/daal4py/brownboost.py similarity index 100% rename from examples/daal4py/brownboost_batch.py rename to examples/daal4py/brownboost.py diff --git a/examples/daal4py/cholesky_batch.py b/examples/daal4py/cholesky.py similarity index 100% rename from examples/daal4py/cholesky_batch.py rename to examples/daal4py/cholesky.py diff --git a/examples/daal4py/correlation_distance_batch.py b/examples/daal4py/correlation_distance.py similarity index 100% rename from examples/daal4py/correlation_distance_batch.py rename to examples/daal4py/correlation_distance.py diff --git a/examples/daal4py/cosine_distance_batch.py b/examples/daal4py/cosine_distance.py similarity index 100% rename from examples/daal4py/cosine_distance_batch.py rename to examples/daal4py/cosine_distance.py diff --git a/examples/daal4py/covariance_batch.py b/examples/daal4py/covariance.py similarity index 100% rename from examples/daal4py/covariance_batch.py rename to examples/daal4py/covariance.py diff --git a/examples/daal4py/dbscan_batch.py b/examples/daal4py/dbscan.py similarity index 100% rename from examples/daal4py/dbscan_batch.py rename to examples/daal4py/dbscan.py diff --git a/examples/daal4py/decision_forest_classification_default_dense_batch.py b/examples/daal4py/decision_forest_classification_default_dense.py similarity index 100% rename from examples/daal4py/decision_forest_classification_default_dense_batch.py rename to examples/daal4py/decision_forest_classification_default_dense.py diff --git a/examples/daal4py/decision_forest_classification_hist_batch.py b/examples/daal4py/decision_forest_classification_hist.py similarity index 100% rename from examples/daal4py/decision_forest_classification_hist_batch.py rename to examples/daal4py/decision_forest_classification_hist.py diff --git a/examples/daal4py/decision_forest_classification_traverse_batch.py b/examples/daal4py/decision_forest_classification_traverse.py similarity index 100% rename from examples/daal4py/decision_forest_classification_traverse_batch.py rename to examples/daal4py/decision_forest_classification_traverse.py diff --git a/examples/daal4py/decision_forest_regression_default_dense_batch.py b/examples/daal4py/decision_forest_regression_default_dense.py similarity index 100% rename from examples/daal4py/decision_forest_regression_default_dense_batch.py rename to examples/daal4py/decision_forest_regression_default_dense.py diff --git a/examples/daal4py/decision_forest_regression_hist_batch.py b/examples/daal4py/decision_forest_regression_hist.py similarity index 100% rename from examples/daal4py/decision_forest_regression_hist_batch.py rename to examples/daal4py/decision_forest_regression_hist.py diff --git a/examples/daal4py/decision_forest_regression_traverse_batch.py b/examples/daal4py/decision_forest_regression_traverse.py similarity index 100% rename from examples/daal4py/decision_forest_regression_traverse_batch.py rename to examples/daal4py/decision_forest_regression_traverse.py diff --git a/examples/daal4py/decision_tree_classification_batch.py b/examples/daal4py/decision_tree_classification.py similarity index 100% rename from examples/daal4py/decision_tree_classification_batch.py rename to examples/daal4py/decision_tree_classification.py diff --git a/examples/daal4py/decision_tree_classification_traverse_batch.py b/examples/daal4py/decision_tree_classification_traverse.py similarity index 100% rename from examples/daal4py/decision_tree_classification_traverse_batch.py rename to examples/daal4py/decision_tree_classification_traverse.py diff --git a/examples/daal4py/decision_tree_regression_batch.py b/examples/daal4py/decision_tree_regression.py similarity index 100% rename from examples/daal4py/decision_tree_regression_batch.py rename to examples/daal4py/decision_tree_regression.py diff --git a/examples/daal4py/decision_tree_regression_traverse_batch.py b/examples/daal4py/decision_tree_regression_traverse.py similarity index 96% rename from examples/daal4py/decision_tree_regression_traverse_batch.py rename to examples/daal4py/decision_tree_regression_traverse.py index 02cc9f3960..636b6e25e4 100644 --- a/examples/daal4py/decision_tree_regression_traverse_batch.py +++ b/examples/daal4py/decision_tree_regression_traverse.py @@ -19,7 +19,7 @@ import math import daal4py as d4p -from decision_tree_regression_batch import main as dt_regression +from decision_tree_regression import main as dt_regression def printTree(nodes, values): diff --git a/examples/daal4py/distributions_bernoulli_batch.py b/examples/daal4py/distributions_bernoulli.py similarity index 100% rename from examples/daal4py/distributions_bernoulli_batch.py rename to examples/daal4py/distributions_bernoulli.py diff --git a/examples/daal4py/distributions_normal_batch.py b/examples/daal4py/distributions_normal.py similarity index 100% rename from examples/daal4py/distributions_normal_batch.py rename to examples/daal4py/distributions_normal.py diff --git a/examples/daal4py/distributions_uniform_batch.py b/examples/daal4py/distributions_uniform.py similarity index 100% rename from examples/daal4py/distributions_uniform_batch.py rename to examples/daal4py/distributions_uniform.py diff --git a/examples/daal4py/elastic_net_batch.py b/examples/daal4py/elastic_net.py similarity index 100% rename from examples/daal4py/elastic_net_batch.py rename to examples/daal4py/elastic_net.py diff --git a/examples/daal4py/em_gmm_batch.py b/examples/daal4py/em_gmm.py similarity index 100% rename from examples/daal4py/em_gmm_batch.py rename to examples/daal4py/em_gmm.py diff --git a/examples/daal4py/gradient_boosted_classification_batch.py b/examples/daal4py/gradient_boosted_classification.py similarity index 100% rename from examples/daal4py/gradient_boosted_classification_batch.py rename to examples/daal4py/gradient_boosted_classification.py diff --git a/examples/daal4py/gradient_boosted_classification_traverse_batch.py b/examples/daal4py/gradient_boosted_classification_traverse.py similarity index 100% rename from examples/daal4py/gradient_boosted_classification_traverse_batch.py rename to examples/daal4py/gradient_boosted_classification_traverse.py diff --git a/examples/daal4py/gradient_boosted_regression_batch.py b/examples/daal4py/gradient_boosted_regression.py similarity index 100% rename from examples/daal4py/gradient_boosted_regression_batch.py rename to examples/daal4py/gradient_boosted_regression.py diff --git a/examples/daal4py/gradient_boosted_regression_traverse_batch.py b/examples/daal4py/gradient_boosted_regression_traverse.py similarity index 100% rename from examples/daal4py/gradient_boosted_regression_traverse_batch.py rename to examples/daal4py/gradient_boosted_regression_traverse.py diff --git a/examples/daal4py/implicit_als_batch.py b/examples/daal4py/implicit_als.py similarity index 100% rename from examples/daal4py/implicit_als_batch.py rename to examples/daal4py/implicit_als.py diff --git a/examples/daal4py/kdtree_knn_classification_batch.py b/examples/daal4py/kdtree_knn_classification.py similarity index 100% rename from examples/daal4py/kdtree_knn_classification_batch.py rename to examples/daal4py/kdtree_knn_classification.py diff --git a/examples/daal4py/kmeans_batch.py b/examples/daal4py/kmeans.py similarity index 100% rename from examples/daal4py/kmeans_batch.py rename to examples/daal4py/kmeans.py diff --git a/examples/daal4py/lasso_regression_batch.py b/examples/daal4py/lasso_regression.py similarity index 100% rename from examples/daal4py/lasso_regression_batch.py rename to examples/daal4py/lasso_regression.py diff --git a/examples/daal4py/lbfgs_cr_entr_loss_batch.py b/examples/daal4py/lbfgs_cr_entr_loss.py similarity index 100% rename from examples/daal4py/lbfgs_cr_entr_loss_batch.py rename to examples/daal4py/lbfgs_cr_entr_loss.py diff --git a/examples/daal4py/lbfgs_mse_batch.py b/examples/daal4py/lbfgs_mse.py similarity index 100% rename from examples/daal4py/lbfgs_mse_batch.py rename to examples/daal4py/lbfgs_mse.py diff --git a/examples/daal4py/linear_regression_batch.py b/examples/daal4py/linear_regression.py similarity index 100% rename from examples/daal4py/linear_regression_batch.py rename to examples/daal4py/linear_regression.py diff --git a/examples/daal4py/log_reg_binary_dense_batch.py b/examples/daal4py/log_reg_binary_dense.py similarity index 100% rename from examples/daal4py/log_reg_binary_dense_batch.py rename to examples/daal4py/log_reg_binary_dense.py diff --git a/examples/daal4py/log_reg_dense_batch.py b/examples/daal4py/log_reg_dense.py similarity index 100% rename from examples/daal4py/log_reg_dense_batch.py rename to examples/daal4py/log_reg_dense.py diff --git a/examples/daal4py/logitboost_batch.py b/examples/daal4py/logitboost.py similarity index 100% rename from examples/daal4py/logitboost_batch.py rename to examples/daal4py/logitboost.py diff --git a/examples/daal4py/low_order_moms_dense_batch.py b/examples/daal4py/low_order_moms_dense.py similarity index 100% rename from examples/daal4py/low_order_moms_dense_batch.py rename to examples/daal4py/low_order_moms_dense.py diff --git a/examples/daal4py/multivariate_outlier_batch.py b/examples/daal4py/multivariate_outlier.py similarity index 100% rename from examples/daal4py/multivariate_outlier_batch.py rename to examples/daal4py/multivariate_outlier.py diff --git a/examples/daal4py/naive_bayes_batch.py b/examples/daal4py/naive_bayes.py similarity index 100% rename from examples/daal4py/naive_bayes_batch.py rename to examples/daal4py/naive_bayes.py diff --git a/examples/daal4py/normalization_minmax_batch.py b/examples/daal4py/normalization_minmax.py similarity index 100% rename from examples/daal4py/normalization_minmax_batch.py rename to examples/daal4py/normalization_minmax.py diff --git a/examples/daal4py/normalization_zscore_batch.py b/examples/daal4py/normalization_zscore.py similarity index 100% rename from examples/daal4py/normalization_zscore_batch.py rename to examples/daal4py/normalization_zscore.py diff --git a/examples/daal4py/pca_batch.py b/examples/daal4py/pca.py similarity index 100% rename from examples/daal4py/pca_batch.py rename to examples/daal4py/pca.py diff --git a/examples/daal4py/pca_transform_batch.py b/examples/daal4py/pca_transform.py similarity index 100% rename from examples/daal4py/pca_transform_batch.py rename to examples/daal4py/pca_transform.py diff --git a/examples/daal4py/pivoted_qr_batch.py b/examples/daal4py/pivoted_qr.py similarity index 100% rename from examples/daal4py/pivoted_qr_batch.py rename to examples/daal4py/pivoted_qr.py diff --git a/examples/daal4py/qr_batch.py b/examples/daal4py/qr.py similarity index 100% rename from examples/daal4py/qr_batch.py rename to examples/daal4py/qr.py diff --git a/examples/daal4py/quantiles_batch.py b/examples/daal4py/quantiles.py similarity index 100% rename from examples/daal4py/quantiles_batch.py rename to examples/daal4py/quantiles.py diff --git a/examples/daal4py/ridge_regression_batch.py b/examples/daal4py/ridge_regression.py similarity index 100% rename from examples/daal4py/ridge_regression_batch.py rename to examples/daal4py/ridge_regression.py diff --git a/examples/daal4py/saga_batch.py b/examples/daal4py/saga.py similarity index 100% rename from examples/daal4py/saga_batch.py rename to examples/daal4py/saga.py diff --git a/examples/daal4py/sgd_logistic_loss_batch.py b/examples/daal4py/sgd_logistic_loss.py similarity index 100% rename from examples/daal4py/sgd_logistic_loss_batch.py rename to examples/daal4py/sgd_logistic_loss.py diff --git a/examples/daal4py/sgd_mse_batch.py b/examples/daal4py/sgd_mse.py similarity index 100% rename from examples/daal4py/sgd_mse_batch.py rename to examples/daal4py/sgd_mse.py diff --git a/examples/daal4py/sorting_batch.py b/examples/daal4py/sorting.py similarity index 100% rename from examples/daal4py/sorting_batch.py rename to examples/daal4py/sorting.py diff --git a/examples/daal4py/stump_classification_batch.py b/examples/daal4py/stump_classification.py similarity index 100% rename from examples/daal4py/stump_classification_batch.py rename to examples/daal4py/stump_classification.py diff --git a/examples/daal4py/stump_regression_batch.py b/examples/daal4py/stump_regression.py similarity index 100% rename from examples/daal4py/stump_regression_batch.py rename to examples/daal4py/stump_regression.py diff --git a/examples/daal4py/svd_batch.py b/examples/daal4py/svd.py similarity index 100% rename from examples/daal4py/svd_batch.py rename to examples/daal4py/svd.py diff --git a/examples/daal4py/svm_batch.py b/examples/daal4py/svm.py similarity index 100% rename from examples/daal4py/svm_batch.py rename to examples/daal4py/svm.py diff --git a/examples/daal4py/svm_multiclass_batch.py b/examples/daal4py/svm_multiclass.py similarity index 100% rename from examples/daal4py/svm_multiclass_batch.py rename to examples/daal4py/svm_multiclass.py diff --git a/examples/daal4py/univariate_outlier_batch.py b/examples/daal4py/univariate_outlier.py similarity index 100% rename from examples/daal4py/univariate_outlier_batch.py rename to examples/daal4py/univariate_outlier.py diff --git a/tests/run_examples.py b/tests/run_examples.py index 7f74deb23f..e9af07be8d 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -125,19 +125,19 @@ def check_library(rule): req_version = defaultdict(lambda: (2019, 'P', 0)) -req_version['sycl/dbscan_batch.py'] = \ +req_version['sycl/dbscan.py'] = \ (2021, 'P', 100) # hangs in beta08, need to be fixed -req_version['sycl/linear_regression_batch.py'] = \ +req_version['sycl/linear_regression.py'] = \ (2021, 'P', 100) # hangs in beta08, need to be fixed -req_version['sycl/kmeans_batch.py'] = \ +req_version['sycl/kmeans.py'] = \ (2021, 'P', 200) # not equal results for host and gpu runs -req_version['sycl/pca_transform_batch.py'] = (2021, 'P', 200) -req_version['sycl/decision_forest_classification_hist_batch.py'] = (2021, 'P', 200) -req_version['sycl/decision_forest_regression_hist_batch.py'] = (2021, 'P', 200) -req_version['decision_forest_classification_hist_batch.py'] = (2023, 'P', 1) -req_version['decision_forest_classification_default_dense_batch.py'] = (2023, 'P', 1) -req_version['decision_forest_classification_traverse_batch.py'] = (2023, 'P', 1) -req_version['decision_forest_regression_hist_batch.py'] = (2021, 'P', 200) +req_version['sycl/pca_transform.py'] = (2021, 'P', 200) +req_version['sycl/decision_forest_classification_hist.py'] = (2021, 'P', 200) +req_version['sycl/decision_forest_regression_hist.py'] = (2021, 'P', 200) +req_version['decision_forest_classification_hist.py'] = (2023, 'P', 1) +req_version['decision_forest_classification_default_dense.py'] = (2023, 'P', 1) +req_version['decision_forest_classification_traverse.py'] = (2023, 'P', 1) +req_version['decision_forest_regression_hist.py'] = (2021, 'P', 200) req_version['basic_statistics_spmd.py'] = (2023, 'P', 1) req_version['kmeans_spmd.py'] = (2023, 'P', 2) req_version['knn_bf_classification_spmd.py'] = (2023, 'P', 1) @@ -153,7 +153,7 @@ def check_library(rule): req_device['pca_spmd.py'] = ["gpu"] req_device['random_forest_classifier_spmd.py'] = ["gpu"] req_device['random_forest_regressor_spmd.py'] = ["gpu"] -req_device['sycl/gradient_boosted_regression_batch.py'] = ["gpu"] +req_device['sycl/gradient_boosted_regression.py'] = ["gpu"] req_library = defaultdict(lambda: []) req_library['basic_statistics_spmd.py'] = ['dpctl', 'mpi4py'] @@ -198,15 +198,15 @@ def get_exe_cmd(ex, nodist, nostream): return None if not check_library(req_library[os.path.basename(ex)]): return None - if any(ex.endswith(x) for x in ['batch.py', 'stream.py']): - return '"' + sys.executable + '" "' + ex + '"' if not nostream and ex.endswith('streaming.py'): return '"' + sys.executable + '" "' + ex + '"' - if not nodist and ex.endswith('spmd.py'): + elif not nodist and ex.endswith('spmd.py'): if IS_WIN: return 'mpiexec -localonly -n 4 "' + sys.executable + '" "' + ex + '"' return 'mpirun -n 4 "' + sys.executable + '" "' + ex + '"' - return None + else: + return '"' + sys.executable + '" "' + ex + '"' + def run(exdir, logdir, nodist=False, nostream=False): @@ -216,10 +216,7 @@ def run(exdir, logdir, nodist=False, nostream=False): os.makedirs(logdir) for (dirpath, dirnames, filenames) in os.walk(exdir): for script in filenames: - if any(script.endswith(x) for x in ['spmd.py', - 'streaming.py', - 'stream.py', - 'batch.py']): + if script.endswith('.py') and script != "__init__.py": n += 1 logfn = jp(logdir, script.replace('.py', '.res')) with open(logfn, 'w') as logfile: From 25dcd9ed92d62579169680b36f41a42be7aec961 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Fri, 14 Jul 2023 07:53:43 -0700 Subject: [PATCH 02/18] add list of skiped files --- .../daal4py/decision_forest_classification_traverse.py | 2 +- examples/daal4py/decision_forest_regression_traverse.py | 2 +- examples/daal4py/decision_tree_classification_traverse.py | 2 +- .../daal4py/gradient_boosted_classification_traverse.py | 2 +- examples/daal4py/gradient_boosted_regression_traverse.py | 2 +- tests/run_examples.py | 8 +++++++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/daal4py/decision_forest_classification_traverse.py b/examples/daal4py/decision_forest_classification_traverse.py index 9b2ffe679d..6554942d46 100755 --- a/examples/daal4py/decision_forest_classification_traverse.py +++ b/examples/daal4py/decision_forest_classification_traverse.py @@ -19,7 +19,7 @@ import math import daal4py as d4p -from decision_forest_classification_default_dense_batch import main as df_classification +from decision_forest_classification_default_dense import main as df_classification def printTree(nodes, values): diff --git a/examples/daal4py/decision_forest_regression_traverse.py b/examples/daal4py/decision_forest_regression_traverse.py index 3da6cf75f4..594d079294 100755 --- a/examples/daal4py/decision_forest_regression_traverse.py +++ b/examples/daal4py/decision_forest_regression_traverse.py @@ -19,7 +19,7 @@ import math import daal4py as d4p -from decision_forest_regression_default_dense_batch import main as df_regression +from decision_forest_regression_default_dense import main as df_regression def printTree(nodes, values): diff --git a/examples/daal4py/decision_tree_classification_traverse.py b/examples/daal4py/decision_tree_classification_traverse.py index 8aea1fe029..41743d3de0 100644 --- a/examples/daal4py/decision_tree_classification_traverse.py +++ b/examples/daal4py/decision_tree_classification_traverse.py @@ -19,7 +19,7 @@ import math import daal4py as d4p -from decision_tree_classification_batch import main as dt_classification +from decision_tree_classification import main as dt_classification def printTree(nodes, values): diff --git a/examples/daal4py/gradient_boosted_classification_traverse.py b/examples/daal4py/gradient_boosted_classification_traverse.py index 8f8c1330f4..08d638df00 100644 --- a/examples/daal4py/gradient_boosted_classification_traverse.py +++ b/examples/daal4py/gradient_boosted_classification_traverse.py @@ -19,7 +19,7 @@ import math import daal4py as d4p -from gradient_boosted_classification_batch import main as gbt_classification +from gradient_boosted_classification import main as gbt_classification def printTree(nodes, values): diff --git a/examples/daal4py/gradient_boosted_regression_traverse.py b/examples/daal4py/gradient_boosted_regression_traverse.py index 95dd718451..0e5015b32d 100644 --- a/examples/daal4py/gradient_boosted_regression_traverse.py +++ b/examples/daal4py/gradient_boosted_regression_traverse.py @@ -19,7 +19,7 @@ import math import daal4py as d4p -from gradient_boosted_regression_batch import main as gbt_regression +from gradient_boosted_regression import main as gbt_regression def printTree(nodes, values): diff --git a/tests/run_examples.py b/tests/run_examples.py index e9af07be8d..65d2807afa 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -171,6 +171,12 @@ def check_library(rule): req_os = defaultdict(lambda: []) +skiped_files = ['__init__.py', + 'spmd_utils.py', + 'log_reg_model_builder.py', + 'n_jobs.py', + 'verbose_mode.py', + 'patch_sklearn.py'] def get_exe_cmd(ex, nodist, nostream): if os.path.dirname(ex).endswith("sycl"): @@ -216,7 +222,7 @@ def run(exdir, logdir, nodist=False, nostream=False): os.makedirs(logdir) for (dirpath, dirnames, filenames) in os.walk(exdir): for script in filenames: - if script.endswith('.py') and script != "__init__.py": + if script.endswith('.py') and script not in skiped_files: n += 1 logfn = jp(logdir, script.replace('.py', '.res')) with open(logfn, 'w') as logfile: From 071a657ff0656e18982a6b3bf6980e660a24e430 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Fri, 14 Jul 2023 10:25:02 -0700 Subject: [PATCH 03/18] pep8 --- tests/run_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_examples.py b/tests/run_examples.py index 65d2807afa..a248b5a421 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -178,6 +178,7 @@ def check_library(rule): 'verbose_mode.py', 'patch_sklearn.py'] + def get_exe_cmd(ex, nodist, nostream): if os.path.dirname(ex).endswith("sycl"): if not sycl_extention_available: @@ -214,7 +215,6 @@ def get_exe_cmd(ex, nodist, nostream): return '"' + sys.executable + '" "' + ex + '"' - def run(exdir, logdir, nodist=False, nostream=False): success = 0 n = 0 From a0895ef8269ea88dfee98f65f80796f1fb17ecf3 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Wed, 19 Jul 2023 00:30:59 -0700 Subject: [PATCH 04/18] fixes for test_examples.py --- tests/test_examples.py | 140 +++++++++--------- ...{adagrad_mse_batch.csv => adagrad_mse.csv} | 0 ..._rules_batch.csv => association_rules.csv} | 0 .../{cholesky_batch.csv => cholesky.csv} | 0 ...nce_batch.csv => correlation_distance.csv} | 0 ...distance_batch.csv => cosine_distance.csv} | 0 .../{dbscan_batch.csv => dbscan.csv} | 0 ...csv => decision_forest_classification.csv} | 0 ...tch.csv => decision_forest_regression.csv} | 0 ...> decision_forest_regression_20230101.csv} | 0 ...h.csv => decision_tree_classification.csv} | 0 ...batch.csv => decision_tree_regression.csv} | 0 ...ch.csv => gradient_boosted_regression.csv} | 0 ...mplicit_als_batch.csv => implicit_als.csv} | 0 .../{kmeans_batch.csv => kmeans.csv} | 0 ..._loss_batch.csv => lbfgs_cr_entr_loss.csv} | 0 .../{lbfgs_mse_batch.csv => lbfgs_mse.csv} | 0 ...ession_batch.csv => linear_regression.csv} | 0 ...nse_batch.csv => log_reg_binary_dense.csv} | 0 ...nse_batch.csv => low_order_moms_dense.csv} | 0 ...ier_batch.csv => multivariate_outlier.csv} | 0 ...{naive_bayes_batch.csv => naive_bayes.csv} | 0 .../unittest_data/{pca_batch.csv => pca.csv} | 0 ..._transform_batch.csv => pca_transform.csv} | 0 ...ression_batch.csv => ridge_regression.csv} | 0 ...c_loss_batch.csv => sgd_logistic_loss.csv} | 0 .../{sgd_mse_batch.csv => sgd_mse.csv} | 0 .../unittest_data/{svm_batch.csv => svm.csv} | 0 ...ulticlass_batch.csv => svm_multiclass.csv} | 0 ...tlier_batch.csv => univariate_outlier.csv} | 0 30 files changed, 70 insertions(+), 70 deletions(-) rename tests/unittest_data/{adagrad_mse_batch.csv => adagrad_mse.csv} (100%) rename tests/unittest_data/{association_rules_batch.csv => association_rules.csv} (100%) rename tests/unittest_data/{cholesky_batch.csv => cholesky.csv} (100%) rename tests/unittest_data/{correlation_distance_batch.csv => correlation_distance.csv} (100%) rename tests/unittest_data/{cosine_distance_batch.csv => cosine_distance.csv} (100%) rename tests/unittest_data/{dbscan_batch.csv => dbscan.csv} (100%) rename tests/unittest_data/{decision_forest_classification_batch.csv => decision_forest_classification.csv} (100%) rename tests/unittest_data/{decision_forest_regression_batch.csv => decision_forest_regression.csv} (100%) rename tests/unittest_data/{decision_forest_regression_batch_20230101.csv => decision_forest_regression_20230101.csv} (100%) rename tests/unittest_data/{decision_tree_classification_batch.csv => decision_tree_classification.csv} (100%) rename tests/unittest_data/{decision_tree_regression_batch.csv => decision_tree_regression.csv} (100%) rename tests/unittest_data/{gradient_boosted_regression_batch.csv => gradient_boosted_regression.csv} (100%) rename tests/unittest_data/{implicit_als_batch.csv => implicit_als.csv} (100%) rename tests/unittest_data/{kmeans_batch.csv => kmeans.csv} (100%) rename tests/unittest_data/{lbfgs_cr_entr_loss_batch.csv => lbfgs_cr_entr_loss.csv} (100%) rename tests/unittest_data/{lbfgs_mse_batch.csv => lbfgs_mse.csv} (100%) rename tests/unittest_data/{linear_regression_batch.csv => linear_regression.csv} (100%) rename tests/unittest_data/{log_reg_binary_dense_batch.csv => log_reg_binary_dense.csv} (100%) rename tests/unittest_data/{low_order_moms_dense_batch.csv => low_order_moms_dense.csv} (100%) rename tests/unittest_data/{multivariate_outlier_batch.csv => multivariate_outlier.csv} (100%) rename tests/unittest_data/{naive_bayes_batch.csv => naive_bayes.csv} (100%) rename tests/unittest_data/{pca_batch.csv => pca.csv} (100%) rename tests/unittest_data/{pca_transform_batch.csv => pca_transform.csv} (100%) rename tests/unittest_data/{ridge_regression_batch.csv => ridge_regression.csv} (100%) rename tests/unittest_data/{sgd_logistic_loss_batch.csv => sgd_logistic_loss.csv} (100%) rename tests/unittest_data/{sgd_mse_batch.csv => sgd_mse.csv} (100%) rename tests/unittest_data/{svm_batch.csv => svm.csv} (100%) rename tests/unittest_data/{svm_multiclass_batch.csv => svm_multiclass.csv} (100%) rename tests/unittest_data/{univariate_outlier_batch.csv => univariate_outlier.csv} (100%) diff --git a/tests/test_examples.py b/tests/test_examples.py index d35dfdd9f2..f46251afa0 100755 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -111,8 +111,8 @@ class Base(): We also use generic functions to test these, they get added later. """ - def test_svd_batch(self): - import svd_batch as ex + def test_svd(self): + import svd as ex (data, result) = self.call(ex) self.assertTrue(np.allclose(data, np.matmul( @@ -133,8 +133,8 @@ def test_svd_stream(self): np.diag(result.singularValues[0])), result.rightSingularMatrix))) - def test_qr_batch(self): - import qr_batch as ex + def test_qr(self): + import qr as ex (data, result) = self.call(ex) self.assertTrue(np.allclose(data, np.matmul(result.matrixQ, result.matrixR))) @@ -146,10 +146,10 @@ def test_qr_stream(self): data = np.append(data, np.loadtxt(f, delimiter=','), axis=0) self.assertTrue(np.allclose(data, np.matmul(result.matrixQ, result.matrixR))) - def test_svm_batch(self): - testdata = np_read_csv(os.path.join(unittest_data_path, "svm_batch.csv"), + def test_svm(self): + testdata = np_read_csv(os.path.join(unittest_data_path, "svm.csv"), range(1)) - import svm_batch as ex + import svm as ex (decision_result, _, _) = self.call(ex) left = np.absolute(decision_result - testdata).max() right = np.absolute(decision_result.max() - decision_result.min()) * 0.05 @@ -157,103 +157,103 @@ def test_svm_batch(self): gen_examples = [ - ('adaboost_batch', None, None, (2020, 'P', 0)), - ('adagrad_mse_batch', 'adagrad_mse_batch.csv', 'minimum'), - ('association_rules_batch', 'association_rules_batch.csv', 'confidence'), - ('bacon_outlier_batch', 'multivariate_outlier_batch.csv', lambda r: r[1].weights), - ('brownboost_batch', None, None, (2020, 'P', 0)), - ('correlation_distance_batch', 'correlation_distance_batch.csv', + ('adaboost', None, None, (2020, 'P', 0)), + ('adagrad_mse', 'adagrad_mse.csv', 'minimum'), + ('association_rules', 'association_rules.csv', 'confidence'), + ('bacon_outlier', 'multivariate_outlier.csv', lambda r: r[1].weights), + ('brownboost', None, None, (2020, 'P', 0)), + ('correlation_distance', 'correlation_distance.csv', lambda r: [[np.amin(r.correlationDistance)], [np.amax(r.correlationDistance)], [np.mean(r.correlationDistance)], [np.average(r.correlationDistance)]]), - ('cosine_distance_batch', 'cosine_distance_batch.csv', + ('cosine_distance', 'cosine_distance.csv', lambda r: [[np.amin(r.cosineDistance)], [np.amax(r.cosineDistance)], [np.mean(r.cosineDistance)], [np.average(r.cosineDistance)]]), - # ('gradient_boosted_regression_batch', 'gradient_boosted_regression_batch.csv', + # ('gradient_boosted_regression', 'gradient_boosted_regression.csv', # lambda x: x[1].prediction), - ('cholesky_batch', 'cholesky_batch.csv', 'choleskyFactor'), - ('covariance_batch', 'covariance.csv', 'covariance'), + ('cholesky', 'cholesky.csv', 'choleskyFactor'), + ('covariance', 'covariance.csv', 'covariance'), ('covariance_streaming', 'covariance.csv', 'covariance'), - ('decision_forest_classification_default_dense_batch', + ('decision_forest_classification_default_dense', None, lambda r: r[1].prediction, (2023, 'P', 1)), - ('decision_forest_classification_hist_batch', + ('decision_forest_classification_hist', None, lambda r: r[1].prediction, (2023, 'P', 1)), - ('decision_forest_regression_default_dense_batch', - 'decision_forest_regression_batch.csv', lambda r: r[1].prediction, (2023, 'P', 1)), - ('decision_forest_regression_hist_batch', - 'decision_forest_regression_batch.csv', lambda r: r[1].prediction, (2023, 'P', 1)), - ('decision_forest_regression_default_dense_batch', - 'decision_forest_regression_batch_20230101.csv', + ('decision_forest_regression_default_dense', + 'decision_forest_regression.csv', lambda r: r[1].prediction, (2023, 'P', 1)), + ('decision_forest_regression_hist', + 'decision_forest_regression.csv', lambda r: r[1].prediction, (2023, 'P', 1)), + ('decision_forest_regression_default_dense', + 'decision_forest_regression_20230101.csv', lambda r: r[1].prediction, (2023, 'P', 101)), - ('decision_forest_regression_hist_batch', - 'decision_forest_regression_batch_20230101.csv', + ('decision_forest_regression_hist', + 'decision_forest_regression_20230101.csv', lambda r: r[1].prediction, (2023, 'P', 101)), - ('decision_tree_classification_batch', 'decision_tree_classification_batch.csv', + ('decision_tree_classification', 'decision_tree_classification.csv', lambda r: r[1].prediction), - ('decision_tree_regression_batch', 'decision_tree_regression_batch.csv', + ('decision_tree_regression', 'decision_tree_regression.csv', lambda r: r[1].prediction), - ('distributions_bernoulli_batch',), - ('distributions_normal_batch',), - ('distributions_uniform_batch',), - ('em_gmm_batch', 'em_gmm.csv', lambda r: r.covariances[0]), + ('distributions_bernoulli',), + ('distributions_normal',), + ('distributions_uniform',), + ('em_gmm', 'em_gmm.csv', lambda r: r.covariances[0]), ('model_builders_lightgbm', None, None, ((2020, 'P', 2), (2021, 'B', 109)), ['lightgbm']), ('model_builders_xgboost', None, None, ((2020, 'P', 2), (2021, 'B', 109)), ['xgboost']), ('model_builders_catboost', None, None, (2021, 'P', 4), ['catboost']), - ('gradient_boosted_classification_batch',), - ('gradient_boosted_regression_batch',), - ('implicit_als_batch', 'implicit_als_batch.csv', 'prediction'), - ('kdtree_knn_classification_batch', None, None), - ('kmeans_batch', 'kmeans_batch.csv', 'centroids'), - ('lbfgs_cr_entr_loss_batch', 'lbfgs_cr_entr_loss_batch.csv', 'minimum'), - ('lbfgs_mse_batch', 'lbfgs_mse_batch.csv', 'minimum'), - ('linear_regression_batch', 'linear_regression_batch.csv', + ('gradient_boosted_classification',), + ('gradient_boosted_regression',), + ('implicit_als', 'implicit_als.csv', 'prediction'), + ('kdtree_knn_classification', None, None), + ('kmeans', 'kmeans.csv', 'centroids'), + ('lbfgs_cr_entr_loss', 'lbfgs_cr_entr_loss.csv', 'minimum'), + ('lbfgs_mse', 'lbfgs_mse.csv', 'minimum'), + ('linear_regression', 'linear_regression.csv', lambda r: r[1].prediction), - ('linear_regression_streaming', 'linear_regression_batch.csv', + ('linear_regression_streaming', 'linear_regression.csv', lambda r: r[1].prediction), # return when Logistic Regression will be fixed - # ('log_reg_binary_dense_batch', 'log_reg_binary_dense_batch.csv', + # ('log_reg_binary_dense', 'log_reg_binary_dense.csv', # lambda r: r[1].prediction), - ('log_reg_binary_dense_batch', None, None), - ('log_reg_dense_batch',), - ('logitboost_batch', None, None, (2020, 'P', 0)), - ('low_order_moms_dense_batch', 'low_order_moms_dense_batch.csv', + ('log_reg_binary_dense', None, None), + ('log_reg_dense',), + ('logitboost', None, None, (2020, 'P', 0)), + ('low_order_moms_dense', 'low_order_moms_dense.csv', lambda r: np.vstack((r.minimum, r.maximum, r.sum, r.sumSquares, r.sumSquaresCentered, r.mean, r.secondOrderRawMoment, r.variance, r.standardDeviation, r.variation))), - ('low_order_moms_streaming', 'low_order_moms_dense_batch.csv', + ('low_order_moms_streaming', 'low_order_moms_dense.csv', lambda r: np.vstack((r.minimum, r.maximum, r.sum, r.sumSquares, r.sumSquaresCentered, r.mean, r.secondOrderRawMoment, r.variance, r.standardDeviation, r.variation))), - ('multivariate_outlier_batch', 'multivariate_outlier_batch.csv', + ('multivariate_outlier', 'multivariate_outlier.csv', lambda r: r[1].weights), - ('naive_bayes_batch', 'naive_bayes_batch.csv', lambda r: r[0].prediction), - ('naive_bayes_streaming', 'naive_bayes_batch.csv', lambda r: r[0].prediction), - ('normalization_minmax_batch', 'normalization_minmax.csv', 'normalizedData'), - ('normalization_zscore_batch', 'normalization_zscore.csv', 'normalizedData'), - ('pca_batch', 'pca_batch.csv', 'eigenvectors'), - ('pca_transform_batch', 'pca_transform_batch.csv', lambda r: r[1].transformedData), - ('pivoted_qr_batch', 'pivoted_qr.csv', 'matrixR'), - ('quantiles_batch', 'quantiles.csv', 'quantiles'), - ('ridge_regression_batch', 'ridge_regression_batch.csv', lambda r: r[0].prediction), - ('ridge_regression_streaming', 'ridge_regression_batch.csv', + ('naive_bayes', 'naive_bayes.csv', lambda r: r[0].prediction), + ('naive_bayes_streaming', 'naive_bayes.csv', lambda r: r[0].prediction), + ('normalization_minmax', 'normalization_minmax.csv', 'normalizedData'), + ('normalization_zscore', 'normalization_zscore.csv', 'normalizedData'), + ('pca', 'pca.csv', 'eigenvectors'), + ('pca_transform', 'pca_transform.csv', lambda r: r[1].transformedData), + ('pivoted_qr', 'pivoted_qr.csv', 'matrixR'), + ('quantiles', 'quantiles.csv', 'quantiles'), + ('ridge_regression', 'ridge_regression.csv', lambda r: r[0].prediction), + ('ridge_regression_streaming', 'ridge_regression.csv', lambda r: r[0].prediction), - ('saga_batch', None, None, (2019, 'P', 3)), - ('sgd_logistic_loss_batch', 'sgd_logistic_loss_batch.csv', 'minimum'), - ('sgd_mse_batch', 'sgd_mse_batch.csv', 'minimum'), - ('sorting_batch',), - ('stump_classification_batch', None, None, (2020, 'P', 0)), - ('stump_regression_batch', None, None, (2020, 'P', 0)), - ('svm_multiclass_batch', 'svm_multiclass_batch.csv', lambda r: r[0].prediction), - ('univariate_outlier_batch', 'univariate_outlier_batch.csv', lambda r: r[1].weights), - ('dbscan_batch', 'dbscan_batch.csv', 'assignments', (2019, 'P', 5)), - ('lasso_regression_batch', None, None, (2019, 'P', 5)), - ('elastic_net_batch', None, None, ((2020, 'P', 1), (2021, 'B', 105))), + ('saga', None, None, (2019, 'P', 3)), + ('sgd_logistic_loss', 'sgd_logistic_loss.csv', 'minimum'), + ('sgd_mse', 'sgd_mse.csv', 'minimum'), + ('sorting',), + ('stump_classification', None, None, (2020, 'P', 0)), + ('stump_regression', None, None, (2020, 'P', 0)), + ('svm_multiclass', 'svm_multiclass.csv', lambda r: r[0].prediction), + ('univariate_outlier', 'univariate_outlier.csv', lambda r: r[1].weights), + ('dbscan', 'dbscan.csv', 'assignments', (2019, 'P', 5)), + ('lasso_regression', None, None, (2019, 'P', 5)), + ('elastic_net', None, None, ((2020, 'P', 1), (2021, 'B', 105))), ] for example in gen_examples: diff --git a/tests/unittest_data/adagrad_mse_batch.csv b/tests/unittest_data/adagrad_mse.csv similarity index 100% rename from tests/unittest_data/adagrad_mse_batch.csv rename to tests/unittest_data/adagrad_mse.csv diff --git a/tests/unittest_data/association_rules_batch.csv b/tests/unittest_data/association_rules.csv similarity index 100% rename from tests/unittest_data/association_rules_batch.csv rename to tests/unittest_data/association_rules.csv diff --git a/tests/unittest_data/cholesky_batch.csv b/tests/unittest_data/cholesky.csv similarity index 100% rename from tests/unittest_data/cholesky_batch.csv rename to tests/unittest_data/cholesky.csv diff --git a/tests/unittest_data/correlation_distance_batch.csv b/tests/unittest_data/correlation_distance.csv similarity index 100% rename from tests/unittest_data/correlation_distance_batch.csv rename to tests/unittest_data/correlation_distance.csv diff --git a/tests/unittest_data/cosine_distance_batch.csv b/tests/unittest_data/cosine_distance.csv similarity index 100% rename from tests/unittest_data/cosine_distance_batch.csv rename to tests/unittest_data/cosine_distance.csv diff --git a/tests/unittest_data/dbscan_batch.csv b/tests/unittest_data/dbscan.csv similarity index 100% rename from tests/unittest_data/dbscan_batch.csv rename to tests/unittest_data/dbscan.csv diff --git a/tests/unittest_data/decision_forest_classification_batch.csv b/tests/unittest_data/decision_forest_classification.csv similarity index 100% rename from tests/unittest_data/decision_forest_classification_batch.csv rename to tests/unittest_data/decision_forest_classification.csv diff --git a/tests/unittest_data/decision_forest_regression_batch.csv b/tests/unittest_data/decision_forest_regression.csv similarity index 100% rename from tests/unittest_data/decision_forest_regression_batch.csv rename to tests/unittest_data/decision_forest_regression.csv diff --git a/tests/unittest_data/decision_forest_regression_batch_20230101.csv b/tests/unittest_data/decision_forest_regression_20230101.csv similarity index 100% rename from tests/unittest_data/decision_forest_regression_batch_20230101.csv rename to tests/unittest_data/decision_forest_regression_20230101.csv diff --git a/tests/unittest_data/decision_tree_classification_batch.csv b/tests/unittest_data/decision_tree_classification.csv similarity index 100% rename from tests/unittest_data/decision_tree_classification_batch.csv rename to tests/unittest_data/decision_tree_classification.csv diff --git a/tests/unittest_data/decision_tree_regression_batch.csv b/tests/unittest_data/decision_tree_regression.csv similarity index 100% rename from tests/unittest_data/decision_tree_regression_batch.csv rename to tests/unittest_data/decision_tree_regression.csv diff --git a/tests/unittest_data/gradient_boosted_regression_batch.csv b/tests/unittest_data/gradient_boosted_regression.csv similarity index 100% rename from tests/unittest_data/gradient_boosted_regression_batch.csv rename to tests/unittest_data/gradient_boosted_regression.csv diff --git a/tests/unittest_data/implicit_als_batch.csv b/tests/unittest_data/implicit_als.csv similarity index 100% rename from tests/unittest_data/implicit_als_batch.csv rename to tests/unittest_data/implicit_als.csv diff --git a/tests/unittest_data/kmeans_batch.csv b/tests/unittest_data/kmeans.csv similarity index 100% rename from tests/unittest_data/kmeans_batch.csv rename to tests/unittest_data/kmeans.csv diff --git a/tests/unittest_data/lbfgs_cr_entr_loss_batch.csv b/tests/unittest_data/lbfgs_cr_entr_loss.csv similarity index 100% rename from tests/unittest_data/lbfgs_cr_entr_loss_batch.csv rename to tests/unittest_data/lbfgs_cr_entr_loss.csv diff --git a/tests/unittest_data/lbfgs_mse_batch.csv b/tests/unittest_data/lbfgs_mse.csv similarity index 100% rename from tests/unittest_data/lbfgs_mse_batch.csv rename to tests/unittest_data/lbfgs_mse.csv diff --git a/tests/unittest_data/linear_regression_batch.csv b/tests/unittest_data/linear_regression.csv similarity index 100% rename from tests/unittest_data/linear_regression_batch.csv rename to tests/unittest_data/linear_regression.csv diff --git a/tests/unittest_data/log_reg_binary_dense_batch.csv b/tests/unittest_data/log_reg_binary_dense.csv similarity index 100% rename from tests/unittest_data/log_reg_binary_dense_batch.csv rename to tests/unittest_data/log_reg_binary_dense.csv diff --git a/tests/unittest_data/low_order_moms_dense_batch.csv b/tests/unittest_data/low_order_moms_dense.csv similarity index 100% rename from tests/unittest_data/low_order_moms_dense_batch.csv rename to tests/unittest_data/low_order_moms_dense.csv diff --git a/tests/unittest_data/multivariate_outlier_batch.csv b/tests/unittest_data/multivariate_outlier.csv similarity index 100% rename from tests/unittest_data/multivariate_outlier_batch.csv rename to tests/unittest_data/multivariate_outlier.csv diff --git a/tests/unittest_data/naive_bayes_batch.csv b/tests/unittest_data/naive_bayes.csv similarity index 100% rename from tests/unittest_data/naive_bayes_batch.csv rename to tests/unittest_data/naive_bayes.csv diff --git a/tests/unittest_data/pca_batch.csv b/tests/unittest_data/pca.csv similarity index 100% rename from tests/unittest_data/pca_batch.csv rename to tests/unittest_data/pca.csv diff --git a/tests/unittest_data/pca_transform_batch.csv b/tests/unittest_data/pca_transform.csv similarity index 100% rename from tests/unittest_data/pca_transform_batch.csv rename to tests/unittest_data/pca_transform.csv diff --git a/tests/unittest_data/ridge_regression_batch.csv b/tests/unittest_data/ridge_regression.csv similarity index 100% rename from tests/unittest_data/ridge_regression_batch.csv rename to tests/unittest_data/ridge_regression.csv diff --git a/tests/unittest_data/sgd_logistic_loss_batch.csv b/tests/unittest_data/sgd_logistic_loss.csv similarity index 100% rename from tests/unittest_data/sgd_logistic_loss_batch.csv rename to tests/unittest_data/sgd_logistic_loss.csv diff --git a/tests/unittest_data/sgd_mse_batch.csv b/tests/unittest_data/sgd_mse.csv similarity index 100% rename from tests/unittest_data/sgd_mse_batch.csv rename to tests/unittest_data/sgd_mse.csv diff --git a/tests/unittest_data/svm_batch.csv b/tests/unittest_data/svm.csv similarity index 100% rename from tests/unittest_data/svm_batch.csv rename to tests/unittest_data/svm.csv diff --git a/tests/unittest_data/svm_multiclass_batch.csv b/tests/unittest_data/svm_multiclass.csv similarity index 100% rename from tests/unittest_data/svm_multiclass_batch.csv rename to tests/unittest_data/svm_multiclass.csv diff --git a/tests/unittest_data/univariate_outlier_batch.csv b/tests/unittest_data/univariate_outlier.csv similarity index 100% rename from tests/unittest_data/univariate_outlier_batch.csv rename to tests/unittest_data/univariate_outlier.csv From 7f5fff1b580d736b782ff7430b6b559ac34b6a02 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Wed, 19 Jul 2023 01:22:39 -0700 Subject: [PATCH 05/18] fix for low_order_moms_dense --- tests/spmd_test_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spmd_test_examples.py b/tests/spmd_test_examples.py index c243578d2a..97e094502f 100644 --- a/tests/spmd_test_examples.py +++ b/tests/spmd_test_examples.py @@ -130,7 +130,7 @@ def test_dbscan_spmd(self): gen_examples = [ ('covariance_spmd', 'covariance.csv', 'covariance'), - ('low_order_moms_spmd', 'low_order_moms_dense_batch.csv', + ('low_order_moms_spmd', 'low_order_moms_dense.csv', lambda r: np.vstack((r.minimum, r.maximum, r.sum, r.sumSquares, r.sumSquaresCentered, r.mean, r.secondOrderRawMoment, r.variance, r.standardDeviation, r.variation))), From 90ee603cc8549c119f800b19927137027051b8af Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Thu, 27 Jul 2023 03:42:52 -0700 Subject: [PATCH 06/18] move spmd_utils.py to utils dir --- examples/daal4py/__init__.py | 0 examples/daal4py/covariance_spmd.py | 2 +- examples/daal4py/log_reg_model_builder.py | 4 ++ examples/daal4py/low_order_moms_spmd.py | 2 +- examples/sklearnex/n_jobs.py | 4 ++ examples/sklearnex/patch_sklearn.py | 4 ++ examples/sklearnex/verbose_mode.py | 3 ++ examples/{daal4py => utils}/spmd_utils.py | 0 tests/run_examples.py | 65 ++++++++++++----------- 9 files changed, 50 insertions(+), 34 deletions(-) delete mode 100644 examples/daal4py/__init__.py rename examples/{daal4py => utils}/spmd_utils.py (100%) diff --git a/examples/daal4py/__init__.py b/examples/daal4py/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/daal4py/covariance_spmd.py b/examples/daal4py/covariance_spmd.py index 2651afee3b..35dea362f9 100644 --- a/examples/daal4py/covariance_spmd.py +++ b/examples/daal4py/covariance_spmd.py @@ -21,7 +21,7 @@ import daal4py as d4p # let's use a reading of file in chunks (defined in spmd_utils.py) -from spmd_utils import read_csv, get_chunk_params +from examples.utils import read_csv, get_chunk_params def main(): diff --git a/examples/daal4py/log_reg_model_builder.py b/examples/daal4py/log_reg_model_builder.py index e3b6519c99..492f6c9298 100644 --- a/examples/daal4py/log_reg_model_builder.py +++ b/examples/daal4py/log_reg_model_builder.py @@ -13,9 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. #=============================================================================== +import sys +print("KNOWN BUG IN EXAMPLES. TODO: fixme") +sys.exit() import daal4py as d4p import numpy as np + from daal4py.sklearn._utils import daal_check_version from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression diff --git a/examples/daal4py/low_order_moms_spmd.py b/examples/daal4py/low_order_moms_spmd.py index 132bc49275..2a7ca7093d 100644 --- a/examples/daal4py/low_order_moms_spmd.py +++ b/examples/daal4py/low_order_moms_spmd.py @@ -21,7 +21,7 @@ import daal4py as d4p # let's use a reading of file in chunks (defined in spmd_utils.py) -from spmd_utils import read_csv, get_chunk_params +from examples.utils import read_csv, get_chunk_params def main(): diff --git a/examples/sklearnex/n_jobs.py b/examples/sklearnex/n_jobs.py index fc36d95fa9..91a6844c9e 100644 --- a/examples/sklearnex/n_jobs.py +++ b/examples/sklearnex/n_jobs.py @@ -18,6 +18,10 @@ # scikit-learn n_jobs yet. Thus it's requered to use daal4py package to set this. # nthreads parameter define number of threads used by sklearnex. # Without this code sklearnex would be using all system cores +import sys +print("KNOWN BUG IN EXAMPLES. TODO: fixme") +sys.exit() + import daal4py daal4py.daalinit(nthreads=2) diff --git a/examples/sklearnex/patch_sklearn.py b/examples/sklearnex/patch_sklearn.py index 5052952028..af225e8f27 100644 --- a/examples/sklearnex/patch_sklearn.py +++ b/examples/sklearnex/patch_sklearn.py @@ -16,6 +16,10 @@ # Calling scikit-learn patch - this would enable acceleration on all # enabled algorithms. This is most straight forward way of patching +import sys +print("KNOWN BUG IN EXAMPLES. TODO: fixme") +sys.exit() + from sklearnex import patch_sklearn patch_sklearn() diff --git a/examples/sklearnex/verbose_mode.py b/examples/sklearnex/verbose_mode.py index 4354847c7b..1a2a140546 100644 --- a/examples/sklearnex/verbose_mode.py +++ b/examples/sklearnex/verbose_mode.py @@ -17,6 +17,9 @@ # sklearnex can help you debug your aplications by printing messages on it's invocation # to allow you to see if stock of accelerated version was used. # By setting sklearnex logger level to "INFO" you would enable this verbose mode +import sys +print("KNOWN BUG IN EXAMPLES. TODO: fixme") +sys.exit() import logging logging.getLogger('sklearnex').setLevel(logging.INFO) diff --git a/examples/daal4py/spmd_utils.py b/examples/utils/spmd_utils.py similarity index 100% rename from examples/daal4py/spmd_utils.py rename to examples/utils/spmd_utils.py diff --git a/tests/run_examples.py b/tests/run_examples.py index a248b5a421..bd68c8d0c6 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -171,9 +171,7 @@ def check_library(rule): req_os = defaultdict(lambda: []) -skiped_files = ['__init__.py', - 'spmd_utils.py', - 'log_reg_model_builder.py', +skiped_files = ['log_reg_model_builder.py', 'n_jobs.py', 'verbose_mode.py', 'patch_sklearn.py'] @@ -222,39 +220,42 @@ def run(exdir, logdir, nodist=False, nostream=False): os.makedirs(logdir) for (dirpath, dirnames, filenames) in os.walk(exdir): for script in filenames: - if script.endswith('.py') and script not in skiped_files: + if script.endswith('.py') and script not in ['__init__.py']: n += 1 - logfn = jp(logdir, script.replace('.py', '.res')) - with open(logfn, 'w') as logfile: - print('\n##### ' + jp(dirpath, script)) - execute_string = get_exe_cmd(jp(dirpath, script), - nodist, nostream) - if execute_string: - os.chdir(dirpath) - proc = subprocess.Popen( - execute_string if IS_WIN else ['/bin/bash', - '-c', - execute_string], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - shell=False - ) - out = proc.communicate()[0] - logfile.write(out.decode('ascii')) - if proc.returncode: - print(out) - print( - strftime("%H:%M:%S", gmtime()) + '\tFAILED' - '\t' + script + '\twith errno' - '\t' + str(proc.returncode) + if script in skiped_files: + print(strftime("%H:%M:%S", gmtime()) + '\tKNOWN BUG IN EXAMPLES\t' + script) + else: + logfn = jp(logdir, script.replace('.py', '.res')) + with open(logfn, 'w') as logfile: + print('\n##### ' + jp(dirpath, script)) + execute_string = get_exe_cmd(jp(dirpath, script), + nodist, nostream) + if execute_string: + os.chdir(dirpath) + proc = subprocess.Popen( + execute_string if IS_WIN else ['/bin/bash', + '-c', + execute_string], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + shell=False ) + out = proc.communicate()[0] + logfile.write(out.decode('ascii')) + if proc.returncode: + print(out) + print( + strftime("%H:%M:%S", gmtime()) + '\tFAILED' + '\t' + script + '\twith errno' + '\t' + str(proc.returncode) + ) + else: + success += 1 + print(strftime("%H:%M:%S", gmtime()) + '\t' + 'PASSED\t' + script) else: success += 1 - print(strftime("%H:%M:%S", gmtime()) + '\t' - 'PASSED\t' + script) - else: - success += 1 - print(strftime("%H:%M:%S", gmtime()) + '\tSKIPPED\t' + script) + print(strftime("%H:%M:%S", gmtime()) + '\tSKIPPED\t' + script) return success, n From f277e4f57e9c394bb99b17834f5d75b2eab77d91 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Thu, 27 Jul 2023 05:52:22 -0700 Subject: [PATCH 07/18] isort --- examples/daal4py/adaboost.py | 3 ++- examples/daal4py/adagrad_mse.py | 3 ++- examples/daal4py/association_rules.py | 3 ++- examples/daal4py/bacon_outlier.py | 3 ++- examples/daal4py/bf_knn_classification.py | 6 ++++-- examples/daal4py/brownboost.py | 3 ++- examples/daal4py/cholesky.py | 3 ++- examples/daal4py/correlation_distance.py | 6 ++++-- examples/daal4py/cosine_distance.py | 6 ++++-- examples/daal4py/covariance.py | 3 ++- examples/daal4py/covariance_spmd.py | 3 +-- examples/daal4py/dbscan.py | 3 ++- .../decision_forest_classification_default_dense.py | 3 ++- examples/daal4py/decision_forest_classification_hist.py | 3 ++- .../daal4py/decision_forest_classification_traverse.py | 6 ++++-- .../daal4py/decision_forest_regression_default_dense.py | 3 ++- examples/daal4py/decision_forest_regression_hist.py | 3 ++- examples/daal4py/decision_forest_regression_traverse.py | 3 ++- examples/daal4py/decision_tree_classification.py | 3 ++- examples/daal4py/decision_tree_classification_traverse.py | 3 ++- examples/daal4py/decision_tree_regression.py | 3 ++- examples/daal4py/decision_tree_regression_traverse.py | 3 ++- examples/daal4py/distributions_bernoulli.py | 3 ++- examples/daal4py/distributions_normal.py | 3 ++- examples/daal4py/distributions_uniform.py | 3 ++- examples/daal4py/elastic_net.py | 3 ++- examples/daal4py/em_gmm.py | 3 ++- examples/daal4py/gradient_boosted_classification.py | 3 ++- .../daal4py/gradient_boosted_classification_traverse.py | 3 ++- examples/daal4py/gradient_boosted_regression.py | 3 ++- examples/daal4py/gradient_boosted_regression_traverse.py | 3 ++- examples/daal4py/implicit_als.py | 3 ++- examples/daal4py/kdtree_knn_classification.py | 6 ++++-- examples/daal4py/kmeans.py | 3 ++- examples/daal4py/lasso_regression.py | 3 ++- examples/daal4py/lbfgs_cr_entr_loss.py | 3 ++- examples/daal4py/lbfgs_mse.py | 3 ++- examples/daal4py/linear_regression.py | 3 ++- examples/daal4py/log_reg_binary_dense.py | 3 ++- examples/daal4py/log_reg_model_builder.py | 7 ++++--- examples/daal4py/logitboost.py | 3 ++- examples/daal4py/low_order_moms_dense.py | 3 ++- examples/daal4py/low_order_moms_spmd.py | 3 +-- examples/daal4py/multivariate_outlier.py | 3 ++- examples/daal4py/naive_bayes.py | 3 ++- examples/daal4py/normalization_minmax.py | 3 ++- examples/daal4py/normalization_zscore.py | 3 ++- examples/daal4py/pca.py | 3 ++- examples/daal4py/pca_transform.py | 3 ++- examples/daal4py/pivoted_qr.py | 3 ++- examples/daal4py/qr.py | 3 ++- examples/daal4py/quantiles.py | 3 ++- examples/daal4py/ridge_regression.py | 3 ++- examples/daal4py/saga.py | 3 ++- examples/daal4py/sgd_logistic_loss.py | 3 ++- examples/daal4py/sgd_mse.py | 3 ++- examples/daal4py/sorting.py | 3 ++- examples/daal4py/stump_classification.py | 3 ++- examples/daal4py/stump_regression.py | 3 ++- examples/daal4py/svd.py | 3 ++- examples/daal4py/svm.py | 3 ++- examples/daal4py/svm_multiclass.py | 3 ++- examples/daal4py/univariate_outlier.py | 3 ++- examples/sklearnex/n_jobs.py | 5 ++++- examples/sklearnex/patch_sklearn.py | 4 ++++ examples/sklearnex/verbose_mode.py | 3 +++ tests/spmd_test_examples.py | 6 ++++-- tests/test_examples.py | 3 +++ 68 files changed, 154 insertions(+), 75 deletions(-) diff --git a/examples/daal4py/adaboost.py b/examples/daal4py/adaboost.py index 8956a82ce7..131c5aed83 100644 --- a/examples/daal4py/adaboost.py +++ b/examples/daal4py/adaboost.py @@ -16,9 +16,10 @@ # daal4py Adaboost example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/adagrad_mse.py b/examples/daal4py/adagrad_mse.py index 4e74c2b329..9156c9470b 100644 --- a/examples/daal4py/adagrad_mse.py +++ b/examples/daal4py/adagrad_mse.py @@ -17,9 +17,10 @@ # daal4py AdaGrad (Adaptive Subgradient Method) example for shared memory systems # using Mean Squared Error objective function -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/association_rules.py b/examples/daal4py/association_rules.py index 180de107dd..fd64bd6f7e 100644 --- a/examples/daal4py/association_rules.py +++ b/examples/daal4py/association_rules.py @@ -16,9 +16,10 @@ # daal4py assiciation rules example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/bacon_outlier.py b/examples/daal4py/bacon_outlier.py index 372c37b3b6..2a4f791763 100644 --- a/examples/daal4py/bacon_outlier.py +++ b/examples/daal4py/bacon_outlier.py @@ -16,9 +16,10 @@ # daal4py outlier detection bacon example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/bf_knn_classification.py b/examples/daal4py/bf_knn_classification.py index 316e7d004a..c3313a37b8 100644 --- a/examples/daal4py/bf_knn_classification.py +++ b/examples/daal4py/bf_knn_classification.py @@ -16,10 +16,12 @@ # daal4py Brute Force KNN example for shared memory systems -import daal4py as d4p -import numpy as np import os +import numpy as np + +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/brownboost.py b/examples/daal4py/brownboost.py index 7bcb4cb973..9f34dfa8fa 100644 --- a/examples/daal4py/brownboost.py +++ b/examples/daal4py/brownboost.py @@ -16,9 +16,10 @@ # daal4py Brownboost example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/cholesky.py b/examples/daal4py/cholesky.py index 955640586d..cfaf6ff275 100644 --- a/examples/daal4py/cholesky.py +++ b/examples/daal4py/cholesky.py @@ -16,9 +16,10 @@ # daal4py cholesky example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/correlation_distance.py b/examples/daal4py/correlation_distance.py index 37949243e5..56ab78b8b9 100644 --- a/examples/daal4py/correlation_distance.py +++ b/examples/daal4py/correlation_distance.py @@ -16,10 +16,12 @@ # daal4py correlation distance example for shared memory systems -import daal4py as d4p -import numpy as np import os +import numpy as np + +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/cosine_distance.py b/examples/daal4py/cosine_distance.py index cdd4eb7cf7..ae8603350c 100644 --- a/examples/daal4py/cosine_distance.py +++ b/examples/daal4py/cosine_distance.py @@ -16,10 +16,12 @@ # daal4py cosine distance example for shared memory systems -import daal4py as d4p -import numpy as np import os +import numpy as np + +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/covariance.py b/examples/daal4py/covariance.py index 7f4eb02838..aa6643a0c9 100644 --- a/examples/daal4py/covariance.py +++ b/examples/daal4py/covariance.py @@ -16,9 +16,10 @@ # daal4py covariance example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/covariance_spmd.py b/examples/daal4py/covariance_spmd.py index 35dea362f9..47cbbc5608 100644 --- a/examples/daal4py/covariance_spmd.py +++ b/examples/daal4py/covariance_spmd.py @@ -19,9 +19,8 @@ # mpirun -n 4 python ./covariance_spmd.py import daal4py as d4p - # let's use a reading of file in chunks (defined in spmd_utils.py) -from examples.utils import read_csv, get_chunk_params +from examples.utils import get_chunk_params, read_csv def main(): diff --git a/examples/daal4py/dbscan.py b/examples/daal4py/dbscan.py index 15a31f71d4..c7def79065 100644 --- a/examples/daal4py/dbscan.py +++ b/examples/daal4py/dbscan.py @@ -16,9 +16,10 @@ # daal4py DBSCAN example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/decision_forest_classification_default_dense.py b/examples/daal4py/decision_forest_classification_default_dense.py index d97a4cf55e..03713e82c1 100755 --- a/examples/daal4py/decision_forest_classification_default_dense.py +++ b/examples/daal4py/decision_forest_classification_default_dense.py @@ -16,9 +16,10 @@ # daal4py Decision Forest Classification example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/decision_forest_classification_hist.py b/examples/daal4py/decision_forest_classification_hist.py index 5adad2e360..420c3b72d6 100755 --- a/examples/daal4py/decision_forest_classification_hist.py +++ b/examples/daal4py/decision_forest_classification_hist.py @@ -16,9 +16,10 @@ # daal4py Decision Forest Classification example of Hist method for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/decision_forest_classification_traverse.py b/examples/daal4py/decision_forest_classification_traverse.py index 6554942d46..949b866a66 100755 --- a/examples/daal4py/decision_forest_classification_traverse.py +++ b/examples/daal4py/decision_forest_classification_traverse.py @@ -17,9 +17,11 @@ # daal4py Decision Forest Classification Tree Traversal example import math -import daal4py as d4p -from decision_forest_classification_default_dense import main as df_classification +from decision_forest_classification_default_dense import \ + main as df_classification + +import daal4py as d4p def printTree(nodes, values): diff --git a/examples/daal4py/decision_forest_regression_default_dense.py b/examples/daal4py/decision_forest_regression_default_dense.py index 77a111554c..bf77a382a5 100755 --- a/examples/daal4py/decision_forest_regression_default_dense.py +++ b/examples/daal4py/decision_forest_regression_default_dense.py @@ -16,9 +16,10 @@ # daal4py Decision Forest Regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/decision_forest_regression_hist.py b/examples/daal4py/decision_forest_regression_hist.py index 3450d67b4b..e00926be03 100755 --- a/examples/daal4py/decision_forest_regression_hist.py +++ b/examples/daal4py/decision_forest_regression_hist.py @@ -16,9 +16,10 @@ # daal4py Decision Forest Regression example of Hist method for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/decision_forest_regression_traverse.py b/examples/daal4py/decision_forest_regression_traverse.py index 594d079294..9d7925152d 100755 --- a/examples/daal4py/decision_forest_regression_traverse.py +++ b/examples/daal4py/decision_forest_regression_traverse.py @@ -17,10 +17,11 @@ # daal4py Decision Forest Regression Tree Traversal example import math -import daal4py as d4p from decision_forest_regression_default_dense import main as df_regression +import daal4py as d4p + def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/decision_tree_classification.py b/examples/daal4py/decision_tree_classification.py index a190a68345..0b9df500c7 100644 --- a/examples/daal4py/decision_tree_classification.py +++ b/examples/daal4py/decision_tree_classification.py @@ -16,9 +16,10 @@ # daal4py Decision Tree Classification example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/decision_tree_classification_traverse.py b/examples/daal4py/decision_tree_classification_traverse.py index 41743d3de0..d3d765bd82 100644 --- a/examples/daal4py/decision_tree_classification_traverse.py +++ b/examples/daal4py/decision_tree_classification_traverse.py @@ -17,10 +17,11 @@ # daal4py Decision Tree Regression example for shared memory systems import math -import daal4py as d4p from decision_tree_classification import main as dt_classification +import daal4py as d4p + def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/decision_tree_regression.py b/examples/daal4py/decision_tree_regression.py index 2c6d514f23..c87b371463 100644 --- a/examples/daal4py/decision_tree_regression.py +++ b/examples/daal4py/decision_tree_regression.py @@ -16,9 +16,10 @@ # daal4py Decision Tree Regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/decision_tree_regression_traverse.py b/examples/daal4py/decision_tree_regression_traverse.py index 636b6e25e4..3cd61fc16a 100644 --- a/examples/daal4py/decision_tree_regression_traverse.py +++ b/examples/daal4py/decision_tree_regression_traverse.py @@ -17,10 +17,11 @@ # daal4py Decision Tree Regression example for shared memory systems import math -import daal4py as d4p from decision_tree_regression import main as dt_regression +import daal4py as d4p + def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/distributions_bernoulli.py b/examples/daal4py/distributions_bernoulli.py index 0165083fea..7656cc532e 100644 --- a/examples/daal4py/distributions_bernoulli.py +++ b/examples/daal4py/distributions_bernoulli.py @@ -16,9 +16,10 @@ # daal4py bernoulli distribution example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + def main(readcsv=None, method='defaultDense'): diff --git a/examples/daal4py/distributions_normal.py b/examples/daal4py/distributions_normal.py index 8027087f6c..81672e0296 100644 --- a/examples/daal4py/distributions_normal.py +++ b/examples/daal4py/distributions_normal.py @@ -16,9 +16,10 @@ # daal4py normal distribution example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + def main(readcsv=None, method='defaultDense'): diff --git a/examples/daal4py/distributions_uniform.py b/examples/daal4py/distributions_uniform.py index 4341de87f6..0a79e3f15b 100644 --- a/examples/daal4py/distributions_uniform.py +++ b/examples/daal4py/distributions_uniform.py @@ -16,9 +16,10 @@ # daal4py uniform distribution example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + def main(readcsv=None, method='defaultDense'): diff --git a/examples/daal4py/elastic_net.py b/examples/daal4py/elastic_net.py index 1f86a6b10c..e743621321 100644 --- a/examples/daal4py/elastic_net.py +++ b/examples/daal4py/elastic_net.py @@ -16,9 +16,10 @@ # daal4py Elastic Net example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/em_gmm.py b/examples/daal4py/em_gmm.py index f27b7da4ab..85c8b01943 100644 --- a/examples/daal4py/em_gmm.py +++ b/examples/daal4py/em_gmm.py @@ -16,9 +16,10 @@ # daal4py em_gmm example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/gradient_boosted_classification.py b/examples/daal4py/gradient_boosted_classification.py index bfdebf48a8..404967a022 100644 --- a/examples/daal4py/gradient_boosted_classification.py +++ b/examples/daal4py/gradient_boosted_classification.py @@ -16,9 +16,10 @@ # daal4py Gradient Bossting Classification example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/gradient_boosted_classification_traverse.py b/examples/daal4py/gradient_boosted_classification_traverse.py index 08d638df00..dc96d329a7 100644 --- a/examples/daal4py/gradient_boosted_classification_traverse.py +++ b/examples/daal4py/gradient_boosted_classification_traverse.py @@ -17,10 +17,11 @@ # daal4py Gradient Boosting Classification Tree Traversal example import math -import daal4py as d4p from gradient_boosted_classification import main as gbt_classification +import daal4py as d4p + def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/gradient_boosted_regression.py b/examples/daal4py/gradient_boosted_regression.py index cfd49ec9ed..fcbc6fc687 100644 --- a/examples/daal4py/gradient_boosted_regression.py +++ b/examples/daal4py/gradient_boosted_regression.py @@ -16,9 +16,10 @@ # daal4py Gradient Bossting Regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/gradient_boosted_regression_traverse.py b/examples/daal4py/gradient_boosted_regression_traverse.py index 0e5015b32d..d83d9bfd3a 100644 --- a/examples/daal4py/gradient_boosted_regression_traverse.py +++ b/examples/daal4py/gradient_boosted_regression_traverse.py @@ -17,10 +17,11 @@ # daal4py Gradient Boosting Regression Tree Traversal example import math -import daal4py as d4p from gradient_boosted_regression import main as gbt_regression +import daal4py as d4p + def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/implicit_als.py b/examples/daal4py/implicit_als.py index b210e35ec0..01407ce048 100644 --- a/examples/daal4py/implicit_als.py +++ b/examples/daal4py/implicit_als.py @@ -16,9 +16,10 @@ # daal4py implicit_als example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/kdtree_knn_classification.py b/examples/daal4py/kdtree_knn_classification.py index 638147feb6..069c127b02 100644 --- a/examples/daal4py/kdtree_knn_classification.py +++ b/examples/daal4py/kdtree_knn_classification.py @@ -16,10 +16,12 @@ # daal4py KD-Tree KNN example for shared memory systems -import daal4py as d4p -import numpy as np import os +import numpy as np + +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/kmeans.py b/examples/daal4py/kmeans.py index 4df52858c0..e521962078 100644 --- a/examples/daal4py/kmeans.py +++ b/examples/daal4py/kmeans.py @@ -16,9 +16,10 @@ # daal4py K-Means example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/lasso_regression.py b/examples/daal4py/lasso_regression.py index c653e2ea31..c6211030f9 100644 --- a/examples/daal4py/lasso_regression.py +++ b/examples/daal4py/lasso_regression.py @@ -16,9 +16,10 @@ # daal4py Lasso Regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/lbfgs_cr_entr_loss.py b/examples/daal4py/lbfgs_cr_entr_loss.py index 9700603400..a28936c70f 100644 --- a/examples/daal4py/lbfgs_cr_entr_loss.py +++ b/examples/daal4py/lbfgs_cr_entr_loss.py @@ -18,9 +18,10 @@ # example for shared memory systems # using cross entropy loss function -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/lbfgs_mse.py b/examples/daal4py/lbfgs_mse.py index 49583131f0..928d801f73 100644 --- a/examples/daal4py/lbfgs_mse.py +++ b/examples/daal4py/lbfgs_mse.py @@ -18,9 +18,10 @@ # example for shared memory systems # using Mean Squared Error objective function -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/linear_regression.py b/examples/daal4py/linear_regression.py index 8c139a3adb..06113338df 100644 --- a/examples/daal4py/linear_regression.py +++ b/examples/daal4py/linear_regression.py @@ -16,9 +16,10 @@ # daal4py Linear Regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/log_reg_binary_dense.py b/examples/daal4py/log_reg_binary_dense.py index 3a7a33fe1d..3d3d153770 100644 --- a/examples/daal4py/log_reg_binary_dense.py +++ b/examples/daal4py/log_reg_binary_dense.py @@ -16,9 +16,10 @@ # daal4py logistic regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/log_reg_model_builder.py b/examples/daal4py/log_reg_model_builder.py index 492f6c9298..fee1386974 100644 --- a/examples/daal4py/log_reg_model_builder.py +++ b/examples/daal4py/log_reg_model_builder.py @@ -14,16 +14,17 @@ # limitations under the License. #=============================================================================== import sys + print("KNOWN BUG IN EXAMPLES. TODO: fixme") sys.exit() -import daal4py as d4p import numpy as np - -from daal4py.sklearn._utils import daal_check_version from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression +import daal4py as d4p +from daal4py.sklearn._utils import daal_check_version + def main(): X, y = load_iris(return_X_y=True) diff --git a/examples/daal4py/logitboost.py b/examples/daal4py/logitboost.py index ffa3d339a3..39062c47ca 100644 --- a/examples/daal4py/logitboost.py +++ b/examples/daal4py/logitboost.py @@ -16,9 +16,10 @@ # daal4py Logitboost example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/low_order_moms_dense.py b/examples/daal4py/low_order_moms_dense.py index f6f8315716..09def55dbd 100644 --- a/examples/daal4py/low_order_moms_dense.py +++ b/examples/daal4py/low_order_moms_dense.py @@ -16,9 +16,10 @@ # daal4py low order moments example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/low_order_moms_spmd.py b/examples/daal4py/low_order_moms_spmd.py index 2a7ca7093d..3ec5b13b0a 100644 --- a/examples/daal4py/low_order_moms_spmd.py +++ b/examples/daal4py/low_order_moms_spmd.py @@ -19,9 +19,8 @@ # mpirun -n 4 python ./low_order_moms_spmd.py import daal4py as d4p - # let's use a reading of file in chunks (defined in spmd_utils.py) -from examples.utils import read_csv, get_chunk_params +from examples.utils import get_chunk_params, read_csv def main(): diff --git a/examples/daal4py/multivariate_outlier.py b/examples/daal4py/multivariate_outlier.py index 3705b03699..b7ef7f1439 100644 --- a/examples/daal4py/multivariate_outlier.py +++ b/examples/daal4py/multivariate_outlier.py @@ -16,9 +16,10 @@ # daal4py outlier detection multivariate example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/naive_bayes.py b/examples/daal4py/naive_bayes.py index 4300485799..80b5dc21ce 100644 --- a/examples/daal4py/naive_bayes.py +++ b/examples/daal4py/naive_bayes.py @@ -16,9 +16,10 @@ # daal4py Naive Bayes Classification example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/normalization_minmax.py b/examples/daal4py/normalization_minmax.py index 7743b6eb9e..64fa94cd9e 100644 --- a/examples/daal4py/normalization_minmax.py +++ b/examples/daal4py/normalization_minmax.py @@ -16,9 +16,10 @@ # daal4py normalization minmax example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/normalization_zscore.py b/examples/daal4py/normalization_zscore.py index 94bebb0f3e..1bc693cb60 100644 --- a/examples/daal4py/normalization_zscore.py +++ b/examples/daal4py/normalization_zscore.py @@ -16,9 +16,10 @@ # daal4py normalization zscore example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/pca.py b/examples/daal4py/pca.py index 3bf3f4bd49..67fa89102b 100644 --- a/examples/daal4py/pca.py +++ b/examples/daal4py/pca.py @@ -16,9 +16,10 @@ # daal4py PCA example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/pca_transform.py b/examples/daal4py/pca_transform.py index b96dd55fbd..1937b56067 100644 --- a/examples/daal4py/pca_transform.py +++ b/examples/daal4py/pca_transform.py @@ -16,9 +16,10 @@ # daal4py PCA example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/pivoted_qr.py b/examples/daal4py/pivoted_qr.py index 06a55e2901..a890c62172 100644 --- a/examples/daal4py/pivoted_qr.py +++ b/examples/daal4py/pivoted_qr.py @@ -16,9 +16,10 @@ # daal4py pivoted QR example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/qr.py b/examples/daal4py/qr.py index 8dfdc387db..b5ed6d852a 100644 --- a/examples/daal4py/qr.py +++ b/examples/daal4py/qr.py @@ -16,9 +16,10 @@ # daal4py QR example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/quantiles.py b/examples/daal4py/quantiles.py index eb362deadc..f2d32a11aa 100644 --- a/examples/daal4py/quantiles.py +++ b/examples/daal4py/quantiles.py @@ -16,9 +16,10 @@ # daal4py quantiles example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/ridge_regression.py b/examples/daal4py/ridge_regression.py index c430af5772..34527d0889 100644 --- a/examples/daal4py/ridge_regression.py +++ b/examples/daal4py/ridge_regression.py @@ -16,9 +16,10 @@ # daal4py Ridge Regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/saga.py b/examples/daal4py/saga.py index 384a5cb6d7..2398babe48 100644 --- a/examples/daal4py/saga.py +++ b/examples/daal4py/saga.py @@ -16,9 +16,10 @@ # daal4py Saga example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/sgd_logistic_loss.py b/examples/daal4py/sgd_logistic_loss.py index e28af65f47..dd7d9ba7b4 100644 --- a/examples/daal4py/sgd_logistic_loss.py +++ b/examples/daal4py/sgd_logistic_loss.py @@ -17,9 +17,10 @@ # daal4py SGD (Stochastic Gradient Descent) example for shared memory systems # using Logisitc Loss objective function -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/sgd_mse.py b/examples/daal4py/sgd_mse.py index f91578fa38..a044f54bc9 100644 --- a/examples/daal4py/sgd_mse.py +++ b/examples/daal4py/sgd_mse.py @@ -17,9 +17,10 @@ # daal4py SGD (Stochastic Gradient Descent) example for shared memory systems # using Mean Squared Error objective function -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/sorting.py b/examples/daal4py/sorting.py index af91bb9501..0eb055fa36 100644 --- a/examples/daal4py/sorting.py +++ b/examples/daal4py/sorting.py @@ -16,9 +16,10 @@ # daal4py sorting example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/stump_classification.py b/examples/daal4py/stump_classification.py index f82467c524..262046a144 100644 --- a/examples/daal4py/stump_classification.py +++ b/examples/daal4py/stump_classification.py @@ -16,9 +16,10 @@ # daal4py Stump classification example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/stump_regression.py b/examples/daal4py/stump_regression.py index 9b8a31ba54..042e734ed3 100644 --- a/examples/daal4py/stump_regression.py +++ b/examples/daal4py/stump_regression.py @@ -16,9 +16,10 @@ # daal4py Stump regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/svd.py b/examples/daal4py/svd.py index be2d33dafa..059d71e4e8 100644 --- a/examples/daal4py/svd.py +++ b/examples/daal4py/svd.py @@ -16,9 +16,10 @@ # daal4py SVD example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/svm.py b/examples/daal4py/svm.py index f282a23947..023612dbf1 100644 --- a/examples/daal4py/svm.py +++ b/examples/daal4py/svm.py @@ -16,9 +16,10 @@ # daal4py SVM example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/svm_multiclass.py b/examples/daal4py/svm_multiclass.py index 324ccc2a91..3b6e07dfe9 100644 --- a/examples/daal4py/svm_multiclass.py +++ b/examples/daal4py/svm_multiclass.py @@ -16,9 +16,10 @@ # daal4py multi-class SVM example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/univariate_outlier.py b/examples/daal4py/univariate_outlier.py index 40e14d645d..9e71fffa57 100644 --- a/examples/daal4py/univariate_outlier.py +++ b/examples/daal4py/univariate_outlier.py @@ -16,9 +16,10 @@ # daal4py outlier detection univariate example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/sklearnex/n_jobs.py b/examples/sklearnex/n_jobs.py index 91a6844c9e..0d6ef515ec 100644 --- a/examples/sklearnex/n_jobs.py +++ b/examples/sklearnex/n_jobs.py @@ -19,14 +19,17 @@ # nthreads parameter define number of threads used by sklearnex. # Without this code sklearnex would be using all system cores import sys + print("KNOWN BUG IN EXAMPLES. TODO: fixme") sys.exit() import daal4py + daal4py.daalinit(nthreads=2) # Calling scikit-learn patch - this would enable acceleration on all enabled algorithms from sklearnex import patch_sklearn + patch_sklearn() # Remaining non modified scikit-learn code @@ -41,8 +44,8 @@ X = StandardScaler().fit_transform(X) -from sklearn.cluster import DBSCAN from sklearn import metrics +from sklearn.cluster import DBSCAN db = DBSCAN(eps=0.3, min_samples=10).fit(X) labels = db.labels_ diff --git a/examples/sklearnex/patch_sklearn.py b/examples/sklearnex/patch_sklearn.py index af225e8f27..5b46b366e4 100644 --- a/examples/sklearnex/patch_sklearn.py +++ b/examples/sklearnex/patch_sklearn.py @@ -17,18 +17,22 @@ # Calling scikit-learn patch - this would enable acceleration on all # enabled algorithms. This is most straight forward way of patching import sys + print("KNOWN BUG IN EXAMPLES. TODO: fixme") sys.exit() from sklearnex import patch_sklearn + patch_sklearn() # Function that can validate current state of patching from sklearnex import sklearn_is_patched + sklearn_is_patched() # Calling scikit-learn unpatch - this would revert patching for all algorithms from sklearnex import unpatch_sklearn + unpatch_sklearn() # Direct import of functions in way aligned with scikit-learn diff --git a/examples/sklearnex/verbose_mode.py b/examples/sklearnex/verbose_mode.py index 1a2a140546..6d3bf6c828 100644 --- a/examples/sklearnex/verbose_mode.py +++ b/examples/sklearnex/verbose_mode.py @@ -18,13 +18,16 @@ # to allow you to see if stock of accelerated version was used. # By setting sklearnex logger level to "INFO" you would enable this verbose mode import sys + print("KNOWN BUG IN EXAMPLES. TODO: fixme") sys.exit() import logging + logging.getLogger('sklearnex').setLevel(logging.INFO) # Calling scikit-learn patch - this would enable acceleration on all enabled algorithms from sklearnex import patch_sklearn + patch_sklearn() # Remaining non modified scikit-learn code diff --git a/tests/spmd_test_examples.py b/tests/spmd_test_examples.py index 97e094502f..217f2833e2 100644 --- a/tests/spmd_test_examples.py +++ b/tests/spmd_test_examples.py @@ -14,13 +14,15 @@ # limitations under the License. #=============================================================================== -import daal4py as d4p import os +import daal4py as d4p + if d4p.__has_dist__: import unittest + import numpy as np - from test_examples import np_read_csv, add_test + from test_examples import add_test, np_read_csv class Base(): def test_svd_spmd(self): diff --git a/tests/test_examples.py b/tests/test_examples.py index f46251afa0..c1a2d98c2f 100755 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -16,6 +16,7 @@ import os import sys + test_path = os.path.abspath(os.path.dirname(__file__)) unittest_data_path = os.path.join(test_path, "unittest_data") examples_path = os.path.join(os.path.dirname(test_path), "examples", "daal4py") @@ -23,11 +24,13 @@ os.chdir(examples_path) import unittest + import numpy as np import pandas as pd from scipy.sparse import csr_matrix from daal4py.sklearn._utils import get_daal_version + # First item is major version - 2021, # second is minor+patch - 0110, # third item is status - B From 2f037f6b3084a68aa2407567f8293f69de3c880e Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Thu, 27 Jul 2023 05:55:59 -0700 Subject: [PATCH 08/18] more isort --- examples/daal4py/covariance_spmd.py | 1 + examples/daal4py/decision_forest_classification_traverse.py | 3 +-- examples/daal4py/log_reg_dense.py | 3 ++- examples/daal4py/low_order_moms_spmd.py | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/daal4py/covariance_spmd.py b/examples/daal4py/covariance_spmd.py index 47cbbc5608..70b4b09554 100644 --- a/examples/daal4py/covariance_spmd.py +++ b/examples/daal4py/covariance_spmd.py @@ -19,6 +19,7 @@ # mpirun -n 4 python ./covariance_spmd.py import daal4py as d4p + # let's use a reading of file in chunks (defined in spmd_utils.py) from examples.utils import get_chunk_params, read_csv diff --git a/examples/daal4py/decision_forest_classification_traverse.py b/examples/daal4py/decision_forest_classification_traverse.py index 949b866a66..0013746c45 100755 --- a/examples/daal4py/decision_forest_classification_traverse.py +++ b/examples/daal4py/decision_forest_classification_traverse.py @@ -18,8 +18,7 @@ import math -from decision_forest_classification_default_dense import \ - main as df_classification +from decision_forest_classification_default_dense import main as df_classification import daal4py as d4p diff --git a/examples/daal4py/log_reg_dense.py b/examples/daal4py/log_reg_dense.py index 53f9069622..663cc9d0ad 100644 --- a/examples/daal4py/log_reg_dense.py +++ b/examples/daal4py/log_reg_dense.py @@ -16,9 +16,10 @@ # daal4py logistic regression example for shared memory systems -import daal4py as d4p import numpy as np +import daal4py as d4p + # let's try to use pandas' fast csv reader try: import pandas diff --git a/examples/daal4py/low_order_moms_spmd.py b/examples/daal4py/low_order_moms_spmd.py index 3ec5b13b0a..c0bd233326 100644 --- a/examples/daal4py/low_order_moms_spmd.py +++ b/examples/daal4py/low_order_moms_spmd.py @@ -19,6 +19,7 @@ # mpirun -n 4 python ./low_order_moms_spmd.py import daal4py as d4p + # let's use a reading of file in chunks (defined in spmd_utils.py) from examples.utils import get_chunk_params, read_csv From 8644612b06ef3c91d7e0666f9e439c9593dd32a7 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Thu, 27 Jul 2023 06:04:23 -0700 Subject: [PATCH 09/18] black --- examples/daal4py/adaboost.py | 17 +- examples/daal4py/adagrad_mse.py | 25 +- examples/daal4py/association_rules.py | 15 +- examples/daal4py/bacon_outlier.py | 13 +- examples/daal4py/bf_knn_classification.py | 18 +- examples/daal4py/brownboost.py | 17 +- examples/daal4py/cholesky.py | 13 +- examples/daal4py/correlation_distance.py | 17 +- examples/daal4py/cosine_distance.py | 15 +- examples/daal4py/covariance.py | 13 +- examples/daal4py/covariance_spmd.py | 10 +- examples/daal4py/dbscan.py | 15 +- ...ion_forest_classification_default_dense.py | 23 +- .../decision_forest_classification_hist.py | 23 +- ...decision_forest_classification_traverse.py | 8 +- ...ecision_forest_regression_default_dense.py | 19 +- .../decision_forest_regression_hist.py | 19 +- .../decision_forest_regression_traverse.py | 8 +- .../daal4py/decision_tree_classification.py | 15 +- .../decision_tree_classification_traverse.py | 6 +- examples/daal4py/decision_tree_regression.py | 15 +- .../decision_tree_regression_traverse.py | 6 +- examples/daal4py/distributions_bernoulli.py | 13 +- examples/daal4py/distributions_normal.py | 25 +- examples/daal4py/distributions_uniform.py | 25 +- examples/daal4py/elastic_net.py | 15 +- examples/daal4py/em_gmm.py | 13 +- .../gradient_boosted_classification.py | 27 +- ...radient_boosted_classification_traverse.py | 8 +- .../daal4py/gradient_boosted_regression.py | 28 +- .../gradient_boosted_regression_traverse.py | 8 +- examples/daal4py/implicit_als.py | 13 +- examples/daal4py/kdtree_knn_classification.py | 18 +- examples/daal4py/kmeans.py | 13 +- examples/daal4py/lasso_regression.py | 17 +- examples/daal4py/lbfgs_cr_entr_loss.py | 68 +++- examples/daal4py/lbfgs_mse.py | 24 +- examples/daal4py/linear_regression.py | 15 +- examples/daal4py/log_reg_binary_dense.py | 21 +- examples/daal4py/log_reg_dense.py | 49 ++- examples/daal4py/log_reg_model_builder.py | 24 +- examples/daal4py/logitboost.py | 22 +- examples/daal4py/low_order_moms_dense.py | 29 +- examples/daal4py/low_order_moms_spmd.py | 30 +- examples/daal4py/multivariate_outlier.py | 13 +- examples/daal4py/naive_bayes.py | 15 +- examples/daal4py/normalization_minmax.py | 13 +- examples/daal4py/normalization_zscore.py | 13 +- examples/daal4py/pca.py | 20 +- examples/daal4py/pca_transform.py | 24 +- examples/daal4py/pivoted_qr.py | 13 +- examples/daal4py/qr.py | 15 +- examples/daal4py/quantiles.py | 13 +- examples/daal4py/ridge_regression.py | 15 +- examples/daal4py/saga.py | 39 +- examples/daal4py/sgd_logistic_loss.py | 20 +- examples/daal4py/sgd_mse.py | 23 +- examples/daal4py/sorting.py | 15 +- examples/daal4py/stump_classification.py | 19 +- examples/daal4py/stump_regression.py | 17 +- examples/daal4py/svd.py | 27 +- examples/daal4py/svm.py | 17 +- examples/daal4py/svm_multiclass.py | 27 +- examples/daal4py/univariate_outlier.py | 13 +- examples/sklearnex/n_jobs.py | 4 +- examples/sklearnex/patch_sklearn.py | 8 +- examples/sklearnex/verbose_mode.py | 6 +- examples/utils/spmd_utils.py | 17 +- tests/run_examples.py | 102 ++--- tests/spmd_test_examples.py | 123 +++--- tests/test_examples.py | 379 +++++++++++------- 71 files changed, 1052 insertions(+), 793 deletions(-) diff --git a/examples/daal4py/adaboost.py b/examples/daal4py/adaboost.py index 131c5aed83..60a296c5f9 100644 --- a/examples/daal4py/adaboost.py +++ b/examples/daal4py/adaboost.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Adaboost example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/adaboost_train.csv" testfile = "./data/batch/adaboost_test.csv" nClasses = 2 @@ -56,7 +57,7 @@ def main(readcsv=read_csv, method='defaultDense'): # The prediction result provides prediction assert predict_result.prediction.shape == (pdata.shape[0], dep_data.shape[1]) - ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=',', ndmin=2) + ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=",", ndmin=2) assert np.allclose(predict_result.prediction, ptdata) return (train_result, predict_result, ptdata) @@ -67,6 +68,6 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nGround truth (first 20 observations):\n", ptdata[:20]) print( "Adaboost classification results: (first 20 observations):\n", - predict_result.prediction[:20] + predict_result.prediction[:20], ) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/adagrad_mse.py b/examples/daal4py/adagrad_mse.py index 9156c9470b..23f5ffecf5 100644 --- a/examples/daal4py/adagrad_mse.py +++ b/examples/daal4py/adagrad_mse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py AdaGrad (Adaptive Subgradient Method) example for shared memory systems # using Mean Squared Error objective function @@ -26,14 +26,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/mse.csv" # Read the data, let's have 3 independent variables data = readcsv(infile, range(3)) @@ -47,11 +48,13 @@ def main(readcsv=read_csv, method='defaultDense'): # configure an AdaGrad object lr = np.array([[1.0]], dtype=np.double) niters = 1000 - sgd_algo = d4p.optimization_solver_adagrad(mse_algo, - learningRate=lr, - accuracyThreshold=0.0000001, - nIterations=niters, - batchSize=1) + sgd_algo = d4p.optimization_solver_adagrad( + mse_algo, + learningRate=lr, + accuracyThreshold=0.0000001, + nIterations=niters, + batchSize=1, + ) # finally do the computation inp = np.array([[8], [2], [1], [4]], dtype=np.double) @@ -67,4 +70,4 @@ def main(readcsv=read_csv, method='defaultDense'): res = main() print("\nMinimum:\n", res.minimum) print("\nNumber of iterations performed:\n", res.nIterations[0][0]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/association_rules.py b/examples/daal4py/association_rules.py index fd64bd6f7e..aefb2811e7 100644 --- a/examples/daal4py/association_rules.py +++ b/examples/daal4py/association_rules.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py assiciation rules example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/apriori.csv" # configure a association_rules object @@ -58,6 +59,6 @@ def main(readcsv=read_csv, method='defaultDense'): if __name__ == "__main__": result1 = main() - print('Confidence: (20 first)') + print("Confidence: (20 first)") print(result1.confidence[0:20]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/bacon_outlier.py b/examples/daal4py/bacon_outlier.py index 2a4f791763..6d7bccdb4c 100644 --- a/examples/daal4py/bacon_outlier.py +++ b/examples/daal4py/bacon_outlier.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py outlier detection bacon example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # Input file infile = "./data/batch/outlierdetection.csv" @@ -56,4 +57,4 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nInput data\n", data) print("\nOutlier detection result (Bacon method) weights:\n", res.weights) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/bf_knn_classification.py b/examples/daal4py/bf_knn_classification.py index c3313a37b8..70a2751f53 100644 --- a/examples/daal4py/bf_knn_classification.py +++ b/examples/daal4py/bf_knn_classification.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2020 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Brute Force KNN example for shared memory systems @@ -27,17 +27,18 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # Input data set parameters - train_file = os.path.join('data', 'batch', 'k_nearest_neighbors_train.csv') - predict_file = os.path.join('data', 'batch', 'k_nearest_neighbors_test.csv') + train_file = os.path.join("data", "batch", "k_nearest_neighbors_train.csv") + predict_file = os.path.join("data", "batch", "k_nearest_neighbors_test.csv") # Read data. Let's use 5 features per observation nFeatures = 5 @@ -71,6 +72,5 @@ def main(readcsv=read_csv, method='defaultDense'): print("Brute Force kNN classification results:") print("Ground truth(observations #30-34):\n", predict_labels[30:35]) print( - "Classification results(observations #30-34):\n", - predict_result.prediction[30:35] + "Classification results(observations #30-34):\n", predict_result.prediction[30:35] ) diff --git a/examples/daal4py/brownboost.py b/examples/daal4py/brownboost.py index 9f34dfa8fa..14fe231fcd 100644 --- a/examples/daal4py/brownboost.py +++ b/examples/daal4py/brownboost.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Brownboost example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/brownboost_train.csv" testfile = "./data/batch/brownboost_test.csv" @@ -55,7 +56,7 @@ def main(readcsv=read_csv, method='defaultDense'): # The prediction result provides prediction assert predict_result.prediction.shape == (pdata.shape[0], dep_data.shape[1]) - ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=',', ndmin=2) + ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=",", ndmin=2) assert np.allclose(predict_result.prediction, ptdata) return (train_result, predict_result, ptdata) @@ -66,6 +67,6 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nGround truth (first 20 observations):\n", ptdata[:20]) print( "Brownboost classification results: (first 20 observations):\n", - predict_result.prediction[:20] + predict_result.prediction[:20], ) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/cholesky.py b/examples/daal4py/cholesky.py index cfaf6ff275..75d9b76bd6 100644 --- a/examples/daal4py/cholesky.py +++ b/examples/daal4py/cholesky.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py cholesky example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/cholesky.csv" # configure a cholesky object @@ -46,4 +47,4 @@ def main(readcsv=read_csv, method='defaultDense'): if __name__ == "__main__": result = main() print("\nFactor:\n", result.choleskyFactor) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/correlation_distance.py b/examples/daal4py/correlation_distance.py index 56ab78b8b9..2bd4ccefd2 100644 --- a/examples/daal4py/correlation_distance.py +++ b/examples/daal4py/correlation_distance.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py correlation distance example for shared memory systems @@ -27,21 +27,22 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): - data = readcsv(os.path.join('data', 'batch', 'distance.csv'), range(10)) +def main(readcsv=read_csv, method="defaultDense"): + data = readcsv(os.path.join("data", "batch", "distance.csv"), range(10)) # Create algorithm to compute correlation distance (no parameters) algorithm = d4p.correlation_distance() # Computed correlation distance with file or numpy array - res1 = algorithm.compute(os.path.join('data', 'batch', 'distance.csv')) + res1 = algorithm.compute(os.path.join("data", "batch", "distance.csv")) res2 = algorithm.compute(data) assert np.allclose(res1.correlationDistance, res2.correlationDistance) @@ -53,6 +54,6 @@ def main(readcsv=read_csv, method='defaultDense'): res = main() print( "\nCorrelation distance (first 15 rows/columns):\n", - res.correlationDistance[0:15, 0:15] + res.correlationDistance[0:15, 0:15], ) print("All looks good!") diff --git a/examples/daal4py/cosine_distance.py b/examples/daal4py/cosine_distance.py index ae8603350c..61da63cf39 100644 --- a/examples/daal4py/cosine_distance.py +++ b/examples/daal4py/cosine_distance.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py cosine distance example for shared memory systems @@ -27,21 +27,22 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=t) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=t) -def main(readcsv=read_csv, method='defaultDense'): - data = readcsv(os.path.join('data', 'batch', 'distance.csv'), range(10)) +def main(readcsv=read_csv, method="defaultDense"): + data = readcsv(os.path.join("data", "batch", "distance.csv"), range(10)) # Create algorithm to compute cosine distance (no parameters) algorithm = d4p.cosine_distance() # Computed cosine distance with file or numpy array - res1 = algorithm.compute(os.path.join('data', 'batch', 'distance.csv')) + res1 = algorithm.compute(os.path.join("data", "batch", "distance.csv")) res2 = algorithm.compute(data) assert np.allclose(res1.cosineDistance, res2.cosineDistance) diff --git a/examples/daal4py/covariance.py b/examples/daal4py/covariance.py index aa6643a0c9..0fca126ccb 100644 --- a/examples/daal4py/covariance.py +++ b/examples/daal4py/covariance.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py covariance example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/covcormoments_dense.csv" # configure a covariance object @@ -58,4 +59,4 @@ def main(readcsv=read_csv, method='defaultDense'): res = main() print("Covariance matrix:\n", res.covariance) print("Mean vector:\n", res.mean) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/covariance_spmd.py b/examples/daal4py/covariance_spmd.py index 70b4b09554..c03e69ba02 100644 --- a/examples/daal4py/covariance_spmd.py +++ b/examples/daal4py/covariance_spmd.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py covariance example for distributed memory systems; SPMD mode # run like this: @@ -29,9 +29,9 @@ def main(): # We know the number of lines in the file # and use this to separate data between processes - skiprows, nrows = get_chunk_params(lines_count=200, - chunks_count=d4p.num_procs(), - chunk_number=d4p.my_procid()) + skiprows, nrows = get_chunk_params( + lines_count=200, chunks_count=d4p.num_procs(), chunk_number=d4p.my_procid() + ) # Each process reads its chunk of the file data = read_csv(infile, sr=skiprows, nr=nrows) diff --git a/examples/daal4py/dbscan.py b/examples/daal4py/dbscan.py index c7def79065..187dd416e6 100644 --- a/examples/daal4py/dbscan.py +++ b/examples/daal4py/dbscan.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py DBSCAN example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/dbscan_dense.csv" epsilon = 0.04 minObservations = 45 @@ -45,7 +46,7 @@ def main(readcsv=read_csv, method='defaultDense'): algo = d4p.dbscan( minObservations=minObservations, epsilon=epsilon, - resultsToCompute='computeCoreIndices|computeCoreObservations' + resultsToCompute="computeCoreIndices|computeCoreObservations", ) # and compute result = algo.compute(data) @@ -71,4 +72,4 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nFirst 10 cluster core indices:\n", result.coreIndices[0:10]) print("\nFirst 10 cluster core observations:\n", result.coreObservations[0:10]) print("\nNumber of clusters:\n", result.nClusters) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/decision_forest_classification_default_dense.py b/examples/daal4py/decision_forest_classification_default_dense.py index 03713e82c1..21a7c88726 100755 --- a/examples/daal4py/decision_forest_classification_default_dense.py +++ b/examples/daal4py/decision_forest_classification_default_dense.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Forest Classification example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=t) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=t) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # input data file infile = "./data/batch/df_classification_train.csv" testfile = "./data/batch/df_classification_test.csv" @@ -45,9 +46,9 @@ def main(readcsv=read_csv, method='defaultDense'): minObservationsInLeafNode=8, featuresPerNode=3, engine=d4p.engines_mt19937(seed=777), - varImportance='MDI', + varImportance="MDI", bootstrap=True, - resultsToCompute='computeOutOfBagError' + resultsToCompute="computeOutOfBagError", ) # Read data. Let's use 3 features per observation @@ -61,7 +62,7 @@ def main(readcsv=read_csv, method='defaultDense'): predict_algo = d4p.decision_forest_classification_prediction( nClasses=5, resultsToEvaluate="computeClassLabels|computeClassProbabilities", - votingMethod="unweighted" + votingMethod="unweighted", ) # read test data (with same #features) pdata = readcsv(testfile, range(3), t=np.float32) @@ -81,11 +82,11 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nOOB error:\n", train_result.outOfBagError) print( "\nDecision forest prediction results (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print( "\nDecision forest probabilities results (first 10 rows):\n", - predict_result.probabilities[0:10] + predict_result.probabilities[0:10], ) print("\nGround truth (first 10 rows):\n", plabels[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/decision_forest_classification_hist.py b/examples/daal4py/decision_forest_classification_hist.py index 420c3b72d6..a2be41356b 100755 --- a/examples/daal4py/decision_forest_classification_hist.py +++ b/examples/daal4py/decision_forest_classification_hist.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2021 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Forest Classification example of Hist method for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=t) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=t) -def main(readcsv=read_csv, method='hist'): +def main(readcsv=read_csv, method="hist"): # input data file infile = "./data/batch/df_classification_train.csv" testfile = "./data/batch/df_classification_test.csv" @@ -47,9 +48,9 @@ def main(readcsv=read_csv, method='hist'): minObservationsInLeafNode=8, featuresPerNode=3, engine=d4p.engines_mt19937(seed=777), - varImportance='MDI', + varImportance="MDI", bootstrap=True, - resultsToCompute='computeOutOfBagError' + resultsToCompute="computeOutOfBagError", ) # Read data. Let's use 3 features per observation @@ -63,7 +64,7 @@ def main(readcsv=read_csv, method='hist'): predict_algo = d4p.decision_forest_classification_prediction( nClasses=5, resultsToEvaluate="computeClassLabels|computeClassProbabilities", - votingMethod="unweighted" + votingMethod="unweighted", ) # read test data (with same #features) pdata = readcsv(testfile, range(3), t=np.float32) @@ -83,11 +84,11 @@ def main(readcsv=read_csv, method='hist'): print("\nOOB error:\n", train_result.outOfBagError) print( "\nDecision forest prediction results (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print( "\nDecision forest probabilities results (first 10 rows):\n", - predict_result.probabilities[0:10] + predict_result.probabilities[0:10], ) print("\nGround truth (first 10 rows):\n", plabels[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/decision_forest_classification_traverse.py b/examples/daal4py/decision_forest_classification_traverse.py index 0013746c45..a3b1ed5d21 100755 --- a/examples/daal4py/decision_forest_classification_traverse.py +++ b/examples/daal4py/decision_forest_classification_traverse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Forest Classification Tree Traversal example @@ -54,5 +54,5 @@ def printNodes(node_id, nodes, values, level): printTree(treeState.node_ar, treeState.value_ar) # Now let printTree traverse the TreeState printTree(treeState.node_ar, treeState.value_ar) - print('Traversed {} trees.'.format(train_result.model.NumberOfTrees)) - print('All looks good!') + print("Traversed {} trees.".format(train_result.model.NumberOfTrees)) + print("All looks good!") diff --git a/examples/daal4py/decision_forest_regression_default_dense.py b/examples/daal4py/decision_forest_regression_default_dense.py index bf77a382a5..708e32328d 100755 --- a/examples/daal4py/decision_forest_regression_default_dense.py +++ b/examples/daal4py/decision_forest_regression_default_dense.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Forest Regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float32) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=np.float32) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=np.float32) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=np.float32) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/df_regression_train.csv" testfile = "./data/batch/df_regression_test.csv" @@ -40,10 +41,10 @@ def main(readcsv=read_csv, method='defaultDense'): train_algo = d4p.decision_forest_regression_training( method=method, nTrees=100, - varImportance='MDA_Raw', + varImportance="MDA_Raw", bootstrap=True, engine=d4p.engines_mt2203(seed=777), - resultsToCompute='computeOutOfBagError|computeOutOfBagErrorPerObservation' + resultsToCompute="computeOutOfBagError|computeOutOfBagErrorPerObservation", ) # Read data. Let's have 13 independent, @@ -75,7 +76,7 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nOOB error:\n", train_result.outOfBagError) print( "\nDecision forest prediction results (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", ptdata[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/decision_forest_regression_hist.py b/examples/daal4py/decision_forest_regression_hist.py index e00926be03..024b31a330 100755 --- a/examples/daal4py/decision_forest_regression_hist.py +++ b/examples/daal4py/decision_forest_regression_hist.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2021 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Forest Regression example of Hist method for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float32) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=np.float32) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=np.float32) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=np.float32) -def main(readcsv=read_csv, method='hist'): +def main(readcsv=read_csv, method="hist"): infile = "./data/batch/df_regression_train.csv" testfile = "./data/batch/df_regression_test.csv" @@ -42,10 +43,10 @@ def main(readcsv=read_csv, method='hist'): maxBins=512, minBinSize=1, nTrees=100, - varImportance='MDA_Raw', + varImportance="MDA_Raw", bootstrap=True, engine=d4p.engines_mt2203(seed=777), - resultsToCompute='computeOutOfBagError|computeOutOfBagErrorPerObservation' + resultsToCompute="computeOutOfBagError|computeOutOfBagErrorPerObservation", ) # Read data. Let's have 13 independent, @@ -77,7 +78,7 @@ def main(readcsv=read_csv, method='hist'): print("\nOOB error:\n", train_result.outOfBagError) print( "\nDecision forest prediction results (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", ptdata[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/decision_forest_regression_traverse.py b/examples/daal4py/decision_forest_regression_traverse.py index 9d7925152d..7217c546cd 100755 --- a/examples/daal4py/decision_forest_regression_traverse.py +++ b/examples/daal4py/decision_forest_regression_traverse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Forest Regression Tree Traversal example @@ -52,5 +52,5 @@ def printNodes(node_id, nodes, values, level): for treeId in range(train_result.model.NumberOfTrees): treeState = d4p.getTreeState(train_result.model, treeId) printTree(treeState.node_ar, treeState.value_ar) - print('Traversed {} trees.'.format(train_result.model.NumberOfTrees)) - print('All looks good!') + print("Traversed {} trees.".format(train_result.model.NumberOfTrees)) + print("All looks good!") diff --git a/examples/daal4py/decision_tree_classification.py b/examples/daal4py/decision_tree_classification.py index 0b9df500c7..320925a345 100644 --- a/examples/daal4py/decision_tree_classification.py +++ b/examples/daal4py/decision_tree_classification.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Tree Classification example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float32) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=np.float32) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=np.float32) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=np.float32) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # input data file infile = "./data/batch/decision_tree_train.csv" prunefile = "./data/batch/decision_tree_prune.csv" @@ -66,7 +67,7 @@ def main(readcsv=read_csv, method='defaultDense'): (train_result, predict_result, plabels) = main() print( "\nDecision tree prediction results (first 20 rows):\n", - predict_result.prediction[0:20] + predict_result.prediction[0:20], ) print("\nGround truth (first 20 rows):\n", plabels[0:20]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/decision_tree_classification_traverse.py b/examples/daal4py/decision_tree_classification_traverse.py index d3d765bd82..d88db2fdf2 100644 --- a/examples/daal4py/decision_tree_classification_traverse.py +++ b/examples/daal4py/decision_tree_classification_traverse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Tree Regression example for shared memory systems @@ -53,4 +53,4 @@ def printNodes(node_id, nodes, values, level): treeState = d4p.getTreeState(train_result.model, treeId, 5) # Now let printTree traverse the TreeState printTree(treeState.node_ar, treeState.value_ar) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/decision_tree_regression.py b/examples/daal4py/decision_tree_regression.py index c87b371463..2379e59331 100644 --- a/examples/daal4py/decision_tree_regression.py +++ b/examples/daal4py/decision_tree_regression.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Tree Regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/decision_tree_train.csv" prunefile = "./data/batch/decision_tree_prune.csv" testfile = "./data/batch/decision_tree_test.csv" @@ -67,7 +68,7 @@ def main(readcsv=read_csv, method='defaultDense'): (train_result, predict_result, ptdata) = main() print( "\nDecision tree prediction results (first 20 rows):\n", - predict_result.prediction[0:20] + predict_result.prediction[0:20], ) print("\nGround truth (first 10 rows):\n", ptdata[0:20]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/decision_tree_regression_traverse.py b/examples/daal4py/decision_tree_regression_traverse.py index 3cd61fc16a..e5f4a31c19 100644 --- a/examples/daal4py/decision_tree_regression_traverse.py +++ b/examples/daal4py/decision_tree_regression_traverse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Decision Tree Regression example for shared memory systems @@ -53,4 +53,4 @@ def printNodes(node_id, nodes, values, level): treeState = d4p.getTreeState(train_result.model, treeId, 5) # Now let printTree traverse the TreeState printTree(treeState.node_ar, treeState.value_ar) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/distributions_bernoulli.py b/examples/daal4py/distributions_bernoulli.py index 7656cc532e..a0eca7b8ff 100644 --- a/examples/daal4py/distributions_bernoulli.py +++ b/examples/daal4py/distributions_bernoulli.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py bernoulli distribution example for shared memory systems @@ -21,8 +21,7 @@ import daal4py as d4p -def main(readcsv=None, method='defaultDense'): - +def main(readcsv=None, method="defaultDense"): # Create algorithm algorithm = d4p.distributions_bernoulli(0.5, engine=d4p.engines_mt19937(seed=777)) @@ -32,11 +31,7 @@ def main(readcsv=None, method='defaultDense'): assert np.allclose(data, res.randomNumbers) assert np.allclose( - data, - [[ - 1.0, 1.000, 1.000, 0.000, 1.000, - 0.000, 1.000, 0.000, 1.000, 0.000 - ]] + data, [[1.0, 1.000, 1.000, 0.000, 1.000, 0.000, 1.000, 0.000, 1.000, 0.000]] ) return data diff --git a/examples/daal4py/distributions_normal.py b/examples/daal4py/distributions_normal.py index 81672e0296..7a7aa3ea4b 100644 --- a/examples/daal4py/distributions_normal.py +++ b/examples/daal4py/distributions_normal.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py normal distribution example for shared memory systems @@ -21,8 +21,7 @@ import daal4py as d4p -def main(readcsv=None, method='defaultDense'): - +def main(readcsv=None, method="defaultDense"): # Create algorithm algorithm = d4p.distributions_normal(engine=d4p.engines_mt19937(seed=777)) @@ -33,10 +32,20 @@ def main(readcsv=None, method='defaultDense'): assert np.allclose(data, res.randomNumbers) assert np.allclose( data, - [[ - -0.74104167, -0.13616829, -0.13679562, 2.40385531, -0.33556821, - 0.19041699, -0.61331181, 0.95958821, -0.42301092, 0.09460208 - ]] + [ + [ + -0.74104167, + -0.13616829, + -0.13679562, + 2.40385531, + -0.33556821, + 0.19041699, + -0.61331181, + 0.95958821, + -0.42301092, + 0.09460208, + ] + ], ) return data diff --git a/examples/daal4py/distributions_uniform.py b/examples/daal4py/distributions_uniform.py index 0a79e3f15b..fdccedc908 100644 --- a/examples/daal4py/distributions_uniform.py +++ b/examples/daal4py/distributions_uniform.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py uniform distribution example for shared memory systems @@ -21,8 +21,7 @@ import daal4py as d4p -def main(readcsv=None, method='defaultDense'): - +def main(readcsv=None, method="defaultDense"): # Create algorithm algorithm = d4p.distributions_uniform(engine=d4p.engines_mt19937(seed=777)) @@ -33,10 +32,20 @@ def main(readcsv=None, method='defaultDense'): assert np.allclose(data, res.randomNumbers) assert np.allclose( data, - [[ - 0.22933409, 0.44584412, 0.44559617, 0.9918884, 0.36859825, - 0.57550881, 0.26983509, 0.83136875, 0.33614365, 0.53768455, - ]] + [ + [ + 0.22933409, + 0.44584412, + 0.44559617, + 0.9918884, + 0.36859825, + 0.57550881, + 0.26983509, + 0.83136875, + 0.33614365, + 0.53768455, + ] + ], ) return data diff --git a/examples/daal4py/elastic_net.py b/examples/daal4py/elastic_net.py index e743621321..90af8b9b76 100644 --- a/examples/daal4py/elastic_net.py +++ b/examples/daal4py/elastic_net.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Elastic Net example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/linear_regression_train.csv" testfile = "./data/batch/linear_regression_test.csv" @@ -64,7 +65,7 @@ def main(readcsv=read_csv, method='defaultDense'): (predict_result, ptdata) = main() print( "\nElastic Net prediction results: (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", ptdata[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/em_gmm.py b/examples/daal4py/em_gmm.py index 85c8b01943..8118aec526 100644 --- a/examples/daal4py/em_gmm.py +++ b/examples/daal4py/em_gmm.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py em_gmm example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): nComponents = 2 infile = "./data/batch/em_gmm.csv" # We load the data @@ -60,4 +61,4 @@ def main(readcsv=read_csv, method='defaultDense'): print("Means:\n", res.means) for c in res.covariances: print("Covariance:\n", c) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/gradient_boosted_classification.py b/examples/daal4py/gradient_boosted_classification.py index 404967a022..77a8d99ac6 100644 --- a/examples/daal4py/gradient_boosted_classification.py +++ b/examples/daal4py/gradient_boosted_classification.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Gradient Bossting Classification example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=t) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=t) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): nFeatures = 3 nClasses = 5 maxIterations = 200 @@ -47,7 +48,7 @@ def main(readcsv=read_csv, method='defaultDense'): maxIterations=maxIterations, minObservationsInLeafNode=minObservationsInLeafNode, featuresPerNode=nFeatures, - varImportance='weight|totalCover|cover|totalGain|gain' + varImportance="weight|totalCover|cover|totalGain|gain", ) # Read data. Let's use 3 features per observation @@ -59,7 +60,7 @@ def main(readcsv=read_csv, method='defaultDense'): # previous version has different interface predict_algo = d4p.gbt_classification_prediction( nClasses=nClasses, - resultsToEvaluate="computeClassLabels|computeClassProbabilities" + resultsToEvaluate="computeClassLabels|computeClassProbabilities", ) # read test data (with same #features) pdata = readcsv(testfile, range(3), t=np.float32) @@ -77,22 +78,20 @@ def main(readcsv=read_csv, method='defaultDense'): (train_result, predict_result, plabels) = main() print( "\nGradient boosted trees prediction results (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", plabels[0:10]) print( "\nGradient boosted trees prediction probabilities (first 10 rows):\n", - predict_result.probabilities[0:10] + predict_result.probabilities[0:10], ) print("\nvariableImportanceByWeight:\n", train_result.variableImportanceByWeight) print( - "\nvariableImportanceByTotalCover:\n", - train_result.variableImportanceByTotalCover + "\nvariableImportanceByTotalCover:\n", train_result.variableImportanceByTotalCover ) print("\nvariableImportanceByCover:\n", train_result.variableImportanceByCover) print( - "\nvariableImportanceByTotalGain:\n", - train_result.variableImportanceByTotalGain + "\nvariableImportanceByTotalGain:\n", train_result.variableImportanceByTotalGain ) print("\nvariableImportanceByGain:\n", train_result.variableImportanceByGain) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/gradient_boosted_classification_traverse.py b/examples/daal4py/gradient_boosted_classification_traverse.py index dc96d329a7..0ff20553ba 100644 --- a/examples/daal4py/gradient_boosted_classification_traverse.py +++ b/examples/daal4py/gradient_boosted_classification_traverse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Gradient Boosting Classification Tree Traversal example @@ -52,5 +52,5 @@ def printNodes(node_id, nodes, values, level): for treeId in range(train_result.model.NumberOfTrees): treeState = d4p.getTreeState(train_result.model, treeId, 5) printTree(treeState.node_ar, treeState.value_ar) - print('Traversed {} trees.'.format(train_result.model.NumberOfTrees)) - print('All looks good!') + print("Traversed {} trees.".format(train_result.model.NumberOfTrees)) + print("All looks good!") diff --git a/examples/daal4py/gradient_boosted_regression.py b/examples/daal4py/gradient_boosted_regression.py index fcbc6fc687..4292aceae9 100644 --- a/examples/daal4py/gradient_boosted_regression.py +++ b/examples/daal4py/gradient_boosted_regression.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Gradient Bossting Regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float32) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=np.float32) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=np.float32) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=np.float32) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): maxIterations = 200 # input data file @@ -55,16 +56,17 @@ def main(readcsv=read_csv, method='defaultDense'): predict_result = predict_algo.compute(pdata, train_result.model) # Prediction result provides prediction - ptdata = np.loadtxt(testfile, usecols=range(13, 14), - delimiter=',', ndmin=2, dtype=np.float32) + ptdata = np.loadtxt( + testfile, usecols=range(13, 14), delimiter=",", ndmin=2, dtype=np.float32 + ) # ptdata = np.loadtxt('../tests/unittest_data/gradient_boosted_regression_batch.csv', # delimiter=',', ndmin=2, dtype=np.float32) - if hasattr(ptdata, 'toarray'): + if hasattr(ptdata, "toarray"): ptdata = ptdata.toarray() # to make the next assertion work with scipy's csr_matrix - assert True or \ - np.square(predict_result.prediction - ptdata).mean() < 1e-2, \ - np.square(predict_result.prediction - ptdata).mean() + assert True or np.square(predict_result.prediction - ptdata).mean() < 1e-2, np.square( + predict_result.prediction - ptdata + ).mean() return (train_result, predict_result, ptdata) @@ -73,7 +75,7 @@ def main(readcsv=read_csv, method='defaultDense'): (train_result, predict_result, ptdata) = main() print( "\nGradient boosted trees prediction results (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", ptdata[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/gradient_boosted_regression_traverse.py b/examples/daal4py/gradient_boosted_regression_traverse.py index d83d9bfd3a..b0316eb14d 100644 --- a/examples/daal4py/gradient_boosted_regression_traverse.py +++ b/examples/daal4py/gradient_boosted_regression_traverse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Gradient Boosting Regression Tree Traversal example @@ -52,5 +52,5 @@ def printNodes(node_id, nodes, values, level): for treeId in range(train_result.model.NumberOfTrees): treeState = d4p.getTreeState(train_result.model, treeId) printTree(treeState.node_ar, treeState.value_ar) - print('Traversed {} trees.'.format(train_result.model.NumberOfTrees)) - print('All looks good!') + print("Traversed {} trees.".format(train_result.model.NumberOfTrees)) + print("All looks good!") diff --git a/examples/daal4py/implicit_als.py b/examples/daal4py/implicit_als.py index 01407ce048..8750e72512 100644 --- a/examples/daal4py/implicit_als.py +++ b/examples/daal4py/implicit_als.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py implicit_als example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): nFactors = 2 infile = "./data/batch/implicit_als_dense.csv" # We load the data @@ -62,4 +63,4 @@ def main(readcsv=read_csv, method='defaultDense'): if __name__ == "__main__": res = main() print("Predicted ratings:\n", res.prediction[:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/kdtree_knn_classification.py b/examples/daal4py/kdtree_knn_classification.py index 069c127b02..16cfdec5c3 100644 --- a/examples/daal4py/kdtree_knn_classification.py +++ b/examples/daal4py/kdtree_knn_classification.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py KD-Tree KNN example for shared memory systems @@ -27,17 +27,18 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # Input data set parameters - train_file = os.path.join('data', 'batch', 'k_nearest_neighbors_train.csv') - predict_file = os.path.join('data', 'batch', 'k_nearest_neighbors_test.csv') + train_file = os.path.join("data", "batch", "k_nearest_neighbors_train.csv") + predict_file = os.path.join("data", "batch", "k_nearest_neighbors_test.csv") # Read data. Let's use 5 features per observation nFeatures = 5 @@ -71,6 +72,5 @@ def main(readcsv=read_csv, method='defaultDense'): print("KD-tree based kNN classification results:") print("Ground truth(observations #30-34):\n", predict_labels[30:35]) print( - "Classification results(observations #30-34):\n", - predict_result.prediction[30:35] + "Classification results(observations #30-34):\n", predict_result.prediction[30:35] ) diff --git a/examples/daal4py/kmeans.py b/examples/daal4py/kmeans.py index e521962078..565de34715 100644 --- a/examples/daal4py/kmeans.py +++ b/examples/daal4py/kmeans.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py K-Means example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/kmeans_dense.csv" nClusters = 20 maxIter = 5 @@ -69,4 +70,4 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nFirst 10 cluster assignments:\n", result.assignments[0:10]) print("\nFirst 10 dimensions of centroids:\n", result.centroids[:, 0:10]) print("\nObjective function value:\n", result.objectiveFunction) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/lasso_regression.py b/examples/daal4py/lasso_regression.py index c6211030f9..6d8ea91f81 100644 --- a/examples/daal4py/lasso_regression.py +++ b/examples/daal4py/lasso_regression.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Lasso Regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/linear_regression_train.csv" testfile = "./data/batch/linear_regression_test.csv" @@ -59,7 +60,7 @@ def main(readcsv=read_csv, method='defaultDense'): # the example is used in tests with the scipy.sparse matrix # we use this trick until subtracting a sparse matrix is not supported - if hasattr(ptdata, 'toarray'): + if hasattr(ptdata, "toarray"): ptdata = ptdata.toarray() # this assertion is outdated, will be fixed in next release # assert np.square(predict_result.prediction - np.asarray(ptdata)).mean() < 2.2 @@ -71,7 +72,7 @@ def main(readcsv=read_csv, method='defaultDense'): (predict_result, ptdata) = main() print( "\nLasso Regression prediction results: (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", ptdata[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/lbfgs_cr_entr_loss.py b/examples/daal4py/lbfgs_cr_entr_loss.py index a28936c70f..329b7ec283 100644 --- a/examples/daal4py/lbfgs_cr_entr_loss.py +++ b/examples/daal4py/lbfgs_cr_entr_loss.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py LBFGS (limited memory Broyden-Fletcher-Goldfarb-Shanno) # example for shared memory systems @@ -27,14 +27,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): nFeatures = 6 nClasses = 5 nIterations = 1000 @@ -48,15 +49,16 @@ def main(readcsv=read_csv, method='defaultDense'): nVectors = data.shape[0] # configure a function - func = d4p.optimization_solver_cross_entropy_loss(nClasses, nVectors, - interceptFlag=True) + func = d4p.optimization_solver_cross_entropy_loss( + nClasses, nVectors, interceptFlag=True + ) func.setup(data, dep_data) # configure a algorithm stepLengthSequence = np.array([[stepLength]], dtype=np.double) - alg = d4p.optimization_solver_lbfgs(func, - stepLengthSequence=stepLengthSequence, - nIterations=nIterations) + alg = d4p.optimization_solver_lbfgs( + func, stepLengthSequence=stepLengthSequence, nIterations=nIterations + ) # do the computation nParameters = nClasses * (nFeatures + 1) @@ -76,15 +78,45 @@ def main(readcsv=read_csv, method='defaultDense'): "\nExpected coefficients:\n", np.array( [ - [-2.277], [2.836], [14.985], [0.511], [7.510], [-2.831], [-5.814], - [-0.033], [13.227], [-24.447], [3.730], [10.394], [-10.461], [-0.766], - [0.077], [1.558], [-1.133], [2.884], [-3.825], [7.699], [2.421], - [-0.135], [-6.996], [1.785], [-2.294], [-9.819], [1.692], [-0.725], - [0.069], [-8.41], [1.458], [-3.306], [-4.719], [5.507], [-1.642] + [-2.277], + [2.836], + [14.985], + [0.511], + [7.510], + [-2.831], + [-5.814], + [-0.033], + [13.227], + [-24.447], + [3.730], + [10.394], + [-10.461], + [-0.766], + [0.077], + [1.558], + [-1.133], + [2.884], + [-3.825], + [7.699], + [2.421], + [-0.135], + [-6.996], + [1.785], + [-2.294], + [-9.819], + [1.692], + [-0.725], + [0.069], + [-8.41], + [1.458], + [-3.306], + [-4.719], + [5.507], + [-1.642], ], - dtype=np.double - ) + dtype=np.double, + ), ) print("\nResulting coefficients:\n", res.minimum) print("\nNumber of iterations performed:\n", res.nIterations[0][0]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/lbfgs_mse.py b/examples/daal4py/lbfgs_mse.py index 928d801f73..9c5e1fd0e6 100644 --- a/examples/daal4py/lbfgs_mse.py +++ b/examples/daal4py/lbfgs_mse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py LBFGS (limited memory Broyden-Fletcher-Goldfarb-Shanno) # example for shared memory systems @@ -27,14 +27,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/lbfgs.csv" # Read the data, let's have 10 independent variables data = readcsv(infile, range(10)) @@ -48,9 +49,9 @@ def main(readcsv=read_csv, method='defaultDense'): # configure an LBFGS object sls = np.array([[1.0e-4]], dtype=np.double) niters = 1000 - lbfgs_algo = d4p.optimization_solver_lbfgs(mse_algo, - stepLengthSequence=sls, - nIterations=niters) + lbfgs_algo = d4p.optimization_solver_lbfgs( + mse_algo, stepLengthSequence=sls, nIterations=niters + ) # finally do the computation inp = np.array([[100]] * 11, dtype=np.double) @@ -67,10 +68,9 @@ def main(readcsv=read_csv, method='defaultDense'): print( "\nExpected coefficients:\n", np.array( - [[11], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]], - dtype=np.double - ) + [[11], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]], dtype=np.double + ), ) print("\nResulting coefficients:\n", res.minimum) print("\nNumber of iterations performed:\n", res.nIterations[0][0]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/linear_regression.py b/examples/daal4py/linear_regression.py index 06113338df..cc66848eab 100644 --- a/examples/daal4py/linear_regression.py +++ b/examples/daal4py/linear_regression.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Linear Regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/linear_regression_train.csv" testfile = "./data/batch/linear_regression_test.csv" @@ -65,7 +66,7 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nLinear Regression coefficients:\n", train_result.model.Beta) print( "\nLinear Regression prediction results: (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", ptdata[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/log_reg_binary_dense.py b/examples/daal4py/log_reg_binary_dense.py index 3d3d153770..794f4dbf0e 100644 --- a/examples/daal4py/log_reg_binary_dense.py +++ b/examples/daal4py/log_reg_binary_dense.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py logistic regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): nClasses = 2 nFeatures = 20 @@ -55,8 +56,10 @@ def main(readcsv=read_csv, method='defaultDense'): predict_result = predict_alg.compute(predict_data, train_result.model) # the prediction result provides prediction - assert predict_result.prediction.shape == (predict_data.shape[0], - train_labels.shape[1]) + assert predict_result.prediction.shape == ( + predict_data.shape[0], + train_labels.shape[1], + ) return (train_result, predict_result, predict_labels) @@ -66,7 +69,7 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nLogistic Regression coefficients:\n", train_result.model.Beta) print( "\nLogistic regression prediction results (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", predict_labels[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/log_reg_dense.py b/examples/daal4py/log_reg_dense.py index 663cc9d0ad..44c548e650 100644 --- a/examples/daal4py/log_reg_dense.py +++ b/examples/daal4py/log_reg_dense.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py logistic regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): nClasses = 5 nFeatures = 6 @@ -42,10 +43,9 @@ def main(readcsv=read_csv, method='defaultDense'): train_labels = readcsv(trainfile, range(nFeatures, nFeatures + 1)) # set parameters and train - train_alg = d4p.logistic_regression_training(nClasses=nClasses, - penaltyL1=0.1, - penaltyL2=0.1, - interceptFlag=True) + train_alg = d4p.logistic_regression_training( + nClasses=nClasses, penaltyL1=0.1, penaltyL2=0.1, interceptFlag=True + ) train_result = train_alg.compute(train_data, train_labels) # read testing data from file with 6 features per observation @@ -53,24 +53,23 @@ def main(readcsv=read_csv, method='defaultDense'): predict_data = readcsv(testfile, range(nFeatures)) # set parameters and compute predictions - predict_alg = \ - d4p.logistic_regression_prediction( - nClasses=nClasses, - resultsToEvaluate="computeClassLabels|computeClassProbabilities|" - "computeClassLogProbabilities" - ) + predict_alg = d4p.logistic_regression_prediction( + nClasses=nClasses, + resultsToEvaluate="computeClassLabels|computeClassProbabilities|" + "computeClassLogProbabilities", + ) predict_result = predict_alg.compute(predict_data, train_result.model) # the prediction result provides prediction, probabilities and logProbabilities assert predict_result.probabilities.shape == (predict_data.shape[0], nClasses) assert predict_result.logProbabilities.shape == (predict_data.shape[0], nClasses) predict_labels = np.loadtxt( - testfile, - usecols=range(nFeatures, nFeatures + 1), - delimiter=',', - ndmin=2 + testfile, usecols=range(nFeatures, nFeatures + 1), delimiter=",", ndmin=2 + ) + assert ( + np.count_nonzero(predict_result.prediction - predict_labels) + / predict_labels.shape[0] + < 0.025 ) - assert np.count_nonzero(predict_result.prediction - predict_labels) \ - / predict_labels.shape[0] < 0.025 return (train_result, predict_result, predict_labels) @@ -80,15 +79,15 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nLogistic Regression coefficients:\n", train_result.model.Beta) print( "\nLogistic regression prediction results (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", predict_labels[0:10]) print( "\nLogistic regression prediction probabilities (first 10 rows):\n", - predict_result.probabilities[0:10] + predict_result.probabilities[0:10], ) print( "\nLogistic regression prediction log probabilities (first 10 rows):\n", - predict_result.logProbabilities[0:10] + predict_result.logProbabilities[0:10], ) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/log_reg_model_builder.py b/examples/daal4py/log_reg_model_builder.py index fee1386974..642be4d040 100644 --- a/examples/daal4py/log_reg_model_builder.py +++ b/examples/daal4py/log_reg_model_builder.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2020 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== import sys print("KNOWN BUG IN EXAMPLES. TODO: fixme") @@ -33,15 +33,15 @@ def main(): # set parameters and train clf = LogisticRegression(fit_intercept=True, max_iter=1000, random_state=0).fit(X, y) - #set parameters and call model builder - builder = d4p.logistic_regression_model_builder(n_classes=n_classes, - n_features=X.shape[1]) + # set parameters and call model builder + builder = d4p.logistic_regression_model_builder( + n_classes=n_classes, n_features=X.shape[1] + ) builder.set_beta(clf.coef_, clf.intercept_) # set parameters and compute predictions predict_alg = d4p.logistic_regression_prediction( - nClasses=n_classes, - resultsToEvaluate="computeClassLabels" + nClasses=n_classes, resultsToEvaluate="computeClassLabels" ) # set parameters and compute predictions predict_result_daal = predict_alg.compute(X, builder.model) @@ -51,19 +51,19 @@ def main(): if __name__ == "__main__": - if daal_check_version(((2021, 'P', 1))): + if daal_check_version(((2021, "P", 1))): (builder, predict_result_daal) = main() print("\nLogistic Regression coefficients:\n", builder.model) print( "\nLogistic regression prediction results (first 10 rows):\n", - predict_result_daal.prediction[0:10] + predict_result_daal.prediction[0:10], ) print( "\nLogistic regression prediction probabilities (first 10 rows):\n", - predict_result_daal.probabilities[0:10] + predict_result_daal.probabilities[0:10], ) print( "\nLogistic regression prediction log probabilities (first 10 rows):\n", - predict_result_daal.logProbabilities[0:10] + predict_result_daal.logProbabilities[0:10], ) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/logitboost.py b/examples/daal4py/logitboost.py index 39062c47ca..cd038ac44e 100644 --- a/examples/daal4py/logitboost.py +++ b/examples/daal4py/logitboost.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Logitboost example for shared memory systems @@ -25,21 +25,23 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/logitboost_train.csv" testfile = "./data/batch/logitboost_test.csv" nClasses = 5 # Configure a logitboost training object - train_algo = d4p.logitboost_training(nClasses, maxIterations=100, - accuracyThreshold=0.01) + train_algo = d4p.logitboost_training( + nClasses, maxIterations=100, accuracyThreshold=0.01 + ) # Read data. Let's have 20 independent, # and 1 dependent variable (for each observation) @@ -57,7 +59,7 @@ def main(readcsv=read_csv, method='defaultDense'): # The prediction result provides prediction assert predict_result.prediction.shape == (pdata.shape[0], dep_data.shape[1]) - ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=',', ndmin=2) + ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=",", ndmin=2) assert np.allclose(predict_result.prediction, ptdata) return (train_result, predict_result, ptdata) @@ -67,6 +69,6 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nGround truth (first 20 observations):\n", ptdata[:20]) print( "Logitboost classification results: (first 20 observations):\n", - predict_result.prediction[:20] + predict_result.prediction[:20], ) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/low_order_moms_dense.py b/examples/daal4py/low_order_moms_dense.py index 09def55dbd..6846fe204c 100644 --- a/examples/daal4py/low_order_moms_dense.py +++ b/examples/daal4py/low_order_moms_dense.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py low order moments example for shared memory systems @@ -25,11 +25,12 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) def main(readcsv=read_csv, method="defaultDense"): @@ -43,9 +44,21 @@ def main(readcsv=read_csv, method="defaultDense"): # result provides minimum, maximum, sum, sumSquares, sumSquaresCentered, # mean, secondOrderRawMoment, variance, standardDeviation, variation - assert all(getattr(res, name).shape == (1, data.shape[1]) for name in - ['minimum', 'maximum', 'sum', 'sumSquares', 'sumSquaresCentered', 'mean', - 'secondOrderRawMoment', 'variance', 'standardDeviation', 'variation']) + assert all( + getattr(res, name).shape == (1, data.shape[1]) + for name in [ + "minimum", + "maximum", + "sum", + "sumSquares", + "sumSquaresCentered", + "mean", + "secondOrderRawMoment", + "variance", + "standardDeviation", + "variation", + ] + ) return res @@ -63,4 +76,4 @@ def main(readcsv=read_csv, method="defaultDense"): print("\nVariance:\n", res.variance) print("\nStandard deviation:\n", res.standardDeviation) print("\nVariation:\n", res.variation) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/low_order_moms_spmd.py b/examples/daal4py/low_order_moms_spmd.py index c0bd233326..58d3f1b505 100644 --- a/examples/daal4py/low_order_moms_spmd.py +++ b/examples/daal4py/low_order_moms_spmd.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py low order moments example for distributed memory systems; SPMD mode # run like this: @@ -29,24 +29,36 @@ def main(): # We know the number of lines in the file # and use this to separate data between processes - skiprows, nrows = get_chunk_params(lines_count=200, - chunks_count=d4p.num_procs(), - chunk_number=d4p.my_procid()) + skiprows, nrows = get_chunk_params( + lines_count=200, chunks_count=d4p.num_procs(), chunk_number=d4p.my_procid() + ) # Each process reads its chunk of the file data = read_csv(infile, sr=skiprows, nr=nrows) # Create algorithm with distributed mode - alg = d4p.low_order_moments(method='defaultDense', distributed=True) + alg = d4p.low_order_moments(method="defaultDense", distributed=True) # Perform computation res = alg.compute(data) # result provides minimum, maximum, sum, sumSquares, sumSquaresCentered, # mean, secondOrderRawMoment, variance, standardDeviation, variation - assert all(getattr(res, name).shape == (1, data.shape[1]) for name in - ['minimum', 'maximum', 'sum', 'sumSquares', 'sumSquaresCentered', 'mean', - 'secondOrderRawMoment', 'variance', 'standardDeviation', 'variation']) + assert all( + getattr(res, name).shape == (1, data.shape[1]) + for name in [ + "minimum", + "maximum", + "sum", + "sumSquares", + "sumSquaresCentered", + "mean", + "secondOrderRawMoment", + "variance", + "standardDeviation", + "variation", + ] + ) return res diff --git a/examples/daal4py/multivariate_outlier.py b/examples/daal4py/multivariate_outlier.py index b7ef7f1439..9b6d139c0f 100644 --- a/examples/daal4py/multivariate_outlier.py +++ b/examples/daal4py/multivariate_outlier.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py outlier detection multivariate example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # Input file infile = "./data/batch/outlierdetection.csv" @@ -56,4 +57,4 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nInput data\n", data) print("\nOutlier detection result (Default method) weights:\n", res.weights) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/naive_bayes.py b/examples/daal4py/naive_bayes.py index 80b5dc21ce..034bf0e29f 100644 --- a/examples/daal4py/naive_bayes.py +++ b/examples/daal4py/naive_bayes.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Naive Bayes Classification example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # input data file infile = "./data/batch/naivebayes_train_dense.csv" testfile = "./data/batch/naivebayes_test_dense.csv" @@ -63,7 +64,7 @@ def main(readcsv=read_csv, method='defaultDense'): (presult, plabels) = main() print( "\nNaiveBayes classification results (first 20 observations):\n", - presult.prediction[0:20] + presult.prediction[0:20], ) print("\nGround truth (first 20 observations)\n", plabels[0:20]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/normalization_minmax.py b/examples/daal4py/normalization_minmax.py index 64fa94cd9e..41bb24ef2f 100644 --- a/examples/daal4py/normalization_minmax.py +++ b/examples/daal4py/normalization_minmax.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py normalization minmax example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/normalization.csv" # configure a covariance object @@ -54,4 +55,4 @@ def main(readcsv=read_csv, method='defaultDense'): if __name__ == "__main__": res = main() print("MinMax result (first 5 rows):\n", res.normalizedData[:5]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/normalization_zscore.py b/examples/daal4py/normalization_zscore.py index 1bc693cb60..51bd3fa493 100644 --- a/examples/daal4py/normalization_zscore.py +++ b/examples/daal4py/normalization_zscore.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py normalization zscore example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/normalization.csv" # configure a covariance object @@ -57,4 +58,4 @@ def main(readcsv=read_csv, method='defaultDense'): if __name__ == "__main__": res = main() print("ZScore result (first 5 rows):\n", res.normalizedData[:5]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/pca.py b/examples/daal4py/pca.py index 67fa89102b..008ce0cee8 100644 --- a/examples/daal4py/pca.py +++ b/examples/daal4py/pca.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py PCA example for shared memory systems @@ -25,22 +25,26 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='svdDense'): +def main(readcsv=read_csv, method="svdDense"): infile = "./data/batch/pca_normalized.csv" # 'normalization' is an optional parameter to PCA; # we use z-score which could be configured differently zscore = d4p.normalization_zscore() # configure a PCA object - algo = d4p.pca(resultsToCompute="mean|variance|eigenvalue", - isDeterministic=True, normalization=zscore) + algo = d4p.pca( + resultsToCompute="mean|variance|eigenvalue", + isDeterministic=True, + normalization=zscore, + ) # let's provide a file directly, not a table/array result1 = algo.compute(infile) @@ -68,4 +72,4 @@ def main(readcsv=read_csv, method='svdDense'): print("\nEigenvectors:\n", result1.eigenvectors) print("\nMeans:\n", result1.means) print("\nVariances:\n", result1.variances) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/pca_transform.py b/examples/daal4py/pca_transform.py index 1937b56067..8bf250bb6a 100644 --- a/examples/daal4py/pca_transform.py +++ b/examples/daal4py/pca_transform.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py PCA example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='svdDense'): +def main(readcsv=read_csv, method="svdDense"): dataFileName = "data/batch/pca_transform.csv" nComponents = 2 @@ -45,8 +46,9 @@ def main(readcsv=read_csv, method='svdDense'): # Apply transform with whitening because means and eigenvalues are provided pcatrans_algo = d4p.pca_transform(nComponents=nComponents) - pcatrans_res = pcatrans_algo.compute(data, pca_res.eigenvectors, - pca_res.dataForTransform) + pcatrans_res = pcatrans_algo.compute( + data, pca_res.eigenvectors, pca_res.dataForTransform + ) # pca_transform_result objects provides transformedData return (pca_res, pcatrans_res) @@ -58,9 +60,9 @@ def main(readcsv=read_csv, method='svdDense'): # print PCA results print("\nEigenvalues:\n", pca_res.eigenvalues) print("\nEigenvectors:\n", pca_res.eigenvectors) - print("\nEigenvalues kv:\n", pca_res.dataForTransform['eigenvalue']) - print("\nMeans kv:\n", pca_res.dataForTransform['mean']) - print("\nVariances kv:\n", pca_res.dataForTransform['variance']) + print("\nEigenvalues kv:\n", pca_res.dataForTransform["eigenvalue"]) + print("\nMeans kv:\n", pca_res.dataForTransform["mean"]) + print("\nVariances kv:\n", pca_res.dataForTransform["variance"]) # print results of tranform print("\nTransformed data:", pcatrans_res.transformedData) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/pivoted_qr.py b/examples/daal4py/pivoted_qr.py index a890c62172..071d465253 100644 --- a/examples/daal4py/pivoted_qr.py +++ b/examples/daal4py/pivoted_qr.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py pivoted QR example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='svdDense'): +def main(readcsv=read_csv, method="svdDense"): infile = "./data/batch/qr.csv" # configure a pivoted QR object @@ -54,4 +55,4 @@ def main(readcsv=read_csv, method='svdDense'): print("Orthogonal matrix Q (:10):\n", result.matrixQ[:10]) print("Triangular matrix R:\n", result.matrixR) print("\nPermutation matrix P:\n", result.permutationMatrix) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/qr.py b/examples/daal4py/qr.py index b5ed6d852a..b14a2ea437 100644 --- a/examples/daal4py/qr.py +++ b/examples/daal4py/qr.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py QR example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='svdDense'): +def main(readcsv=read_csv, method="svdDense"): infile = "./data/batch/qr.csv" # configure a QR object @@ -52,7 +53,7 @@ def main(readcsv=read_csv, method='svdDense'): assert np.allclose(result1.matrixQ, result2.matrixQ, atol=1e-07) assert np.allclose(result1.matrixR, result2.matrixR, atol=1e-07) - if hasattr(data, 'toarray'): + if hasattr(data, "toarray"): data = data.toarray() # to make the next assertion work with scipy's csr_matrix assert np.allclose(data, np.matmul(result1.matrixQ, result1.matrixR)) @@ -62,4 +63,4 @@ def main(readcsv=read_csv, method='svdDense'): if __name__ == "__main__": (_, result) = main() print(result) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/quantiles.py b/examples/daal4py/quantiles.py index f2d32a11aa..814a78dfb6 100644 --- a/examples/daal4py/quantiles.py +++ b/examples/daal4py/quantiles.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py quantiles example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/quantiles.csv" # configure a quantiles object @@ -54,4 +55,4 @@ def main(readcsv=read_csv, method='defaultDense'): if __name__ == "__main__": result = main() print("Quantiles:\n", result.quantiles) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/ridge_regression.py b/examples/daal4py/ridge_regression.py index 34527d0889..84268683b3 100644 --- a/examples/daal4py/ridge_regression.py +++ b/examples/daal4py/ridge_regression.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Ridge Regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/linear_regression_train.csv" testfile = "./data/batch/linear_regression_test.csv" @@ -64,7 +65,7 @@ def main(readcsv=read_csv, method='defaultDense'): (predict_result, ptdata) = main() print( "\nRidge Regression prediction results: (first 10 rows):\n", - predict_result.prediction[0:10] + predict_result.prediction[0:10], ) print("\nGround truth (first 10 rows):\n", ptdata[0:10]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/saga.py b/examples/daal4py/saga.py index 2398babe48..cc7a0dc4bd 100644 --- a/examples/daal4py/saga.py +++ b/examples/daal4py/saga.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Saga example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/XM.csv" # Read the data, let's have 3 independent variables data = readcsv(infile, range(1)) @@ -40,22 +41,26 @@ def main(readcsv=read_csv, method='defaultDense'): nVectors = data.shape[0] # configure a Logistic Loss object - logloss_algo = d4p.optimization_solver_logistic_loss(numberOfTerms=nVectors, - penaltyL1=0.3, - penaltyL2=0, - interceptFlag=True, - resultsToCompute='gradient') + logloss_algo = d4p.optimization_solver_logistic_loss( + numberOfTerms=nVectors, + penaltyL1=0.3, + penaltyL2=0, + interceptFlag=True, + resultsToCompute="gradient", + ) logloss_algo.setup(data, dep_data) # configure an Saga object lr = np.array([[0.01]], dtype=np.double) niters = 100000 - saga_algo = d4p.optimization_solver_saga(nIterations=niters, - accuracyThreshold=1e-5, - batchSize=1, - function=logloss_algo, - learningRateSequence=lr, - optionalResultRequired=True) + saga_algo = d4p.optimization_solver_saga( + nIterations=niters, + accuracyThreshold=1e-5, + batchSize=1, + function=logloss_algo, + learningRateSequence=lr, + optionalResultRequired=True, + ) # finally do the computation inp = np.zeros((2, 1), dtype=np.double) @@ -72,4 +77,4 @@ def main(readcsv=read_csv, method='defaultDense'): res = main() print("\nMinimum:\n", res.minimum) print("\nNumber of iterations performed:\n", res.nIterations[0][0]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/sgd_logistic_loss.py b/examples/daal4py/sgd_logistic_loss.py index dd7d9ba7b4..bd98ab895f 100644 --- a/examples/daal4py/sgd_logistic_loss.py +++ b/examples/daal4py/sgd_logistic_loss.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py SGD (Stochastic Gradient Descent) example for shared memory systems # using Logisitc Loss objective function @@ -26,14 +26,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/custom.csv" # Read the data, let's have 4 independent variables data = readcsv(infile, range(4)) @@ -47,10 +48,9 @@ def main(readcsv=read_csv, method='defaultDense'): # configure a SGD object lrs = np.array([[0.01]], dtype=np.double) niters = 1000 - sgd_algo = d4p.optimization_solver_sgd(ll_algo, - learningRateSequence=lrs, - accuracyThreshold=0.02, - nIterations=niters) + sgd_algo = d4p.optimization_solver_sgd( + ll_algo, learningRateSequence=lrs, accuracyThreshold=0.02, nIterations=niters + ) # finally do the computation inp = np.array([[1], [1], [1], [1], [1]], dtype=np.double) @@ -66,4 +66,4 @@ def main(readcsv=read_csv, method='defaultDense'): res = main() print("\nMinimum:\n", res.minimum) print("\nNumber of iterations performed:\n", res.nIterations[0][0]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/sgd_mse.py b/examples/daal4py/sgd_mse.py index a044f54bc9..c0e578abe3 100644 --- a/examples/daal4py/sgd_mse.py +++ b/examples/daal4py/sgd_mse.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py SGD (Stochastic Gradient Descent) example for shared memory systems # using Mean Squared Error objective function @@ -26,14 +26,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/mse.csv" # Read the data, let's have 3 independent variables data = readcsv(infile, range(3)) @@ -47,10 +48,12 @@ def main(readcsv=read_csv, method='defaultDense'): # configure a SGD object lrs = np.array([[1.0]], dtype=np.double) niters = 1000 - sgd_algo = d4p.optimization_solver_sgd(mse_algo, - learningRateSequence=lrs, - accuracyThreshold=0.0000001, - nIterations=niters) + sgd_algo = d4p.optimization_solver_sgd( + mse_algo, + learningRateSequence=lrs, + accuracyThreshold=0.0000001, + nIterations=niters, + ) # finally do the computation inp = np.array([[8], [2], [1], [4]], dtype=np.double) @@ -66,4 +69,4 @@ def main(readcsv=read_csv, method='defaultDense'): res = main() print("\nMinimum:\n", res.minimum) print("\nNumber of iterations performed:\n", res.nIterations[0][0]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/sorting.py b/examples/daal4py/sorting.py index 0eb055fa36..12160cae1d 100644 --- a/examples/daal4py/sorting.py +++ b/examples/daal4py/sorting.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py sorting example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c=None, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c=None, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/sorting.csv" # configure a sorting object @@ -49,7 +50,7 @@ def main(readcsv=read_csv, method='defaultDense'): assert np.allclose(result1.sortedData, result2.sortedData) assert np.allclose( result1.sortedData, - np.sort(data.toarray() if hasattr(data, 'toarray') else data, axis=0) + np.sort(data.toarray() if hasattr(data, "toarray") else data, axis=0), ) return result1 @@ -58,4 +59,4 @@ def main(readcsv=read_csv, method='defaultDense'): if __name__ == "__main__": result = main() print("Sorted matrix of observations:\n", result.sortedData) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/stump_classification.py b/examples/daal4py/stump_classification.py index 262046a144..eaca5a514b 100644 --- a/examples/daal4py/stump_classification.py +++ b/examples/daal4py/stump_classification.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Stump classification example for shared memory systems @@ -25,19 +25,20 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/stump_train.csv" testfile = "./data/batch/stump_test.csv" # Configure a stump classification training object - train_algo = d4p.stump_classification_training(splitCriterion='gini') + train_algo = d4p.stump_classification_training(splitCriterion="gini") # Read data. Let's have 20 independent, # and 1 dependent variable (for each observation) @@ -55,7 +56,7 @@ def main(readcsv=read_csv, method='defaultDense'): # The prediction result provides prediction assert predict_result.prediction.shape == (pdata.shape[0], dep_data.shape[1]) - ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=',', ndmin=2) + ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=",", ndmin=2) assert np.allclose(predict_result.prediction, ptdata) return (train_result, predict_result, ptdata) @@ -65,6 +66,6 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nGround truth (first 20 observations):\n", ptdata[:20]) print( "Stump classification results: (first 20 observations):\n", - predict_result.prediction[:20] + predict_result.prediction[:20], ) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/stump_regression.py b/examples/daal4py/stump_regression.py index 042e734ed3..ab8ff1088a 100644 --- a/examples/daal4py/stump_regression.py +++ b/examples/daal4py/stump_regression.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py Stump regression example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/stump_train.csv" testfile = "./data/batch/stump_test.csv" @@ -55,7 +56,7 @@ def main(readcsv=read_csv, method='defaultDense'): # The prediction result provides prediction assert predict_result.prediction.shape == (pdata.shape[0], dep_data.shape[1]) - ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=',', ndmin=2) + ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=",", ndmin=2) assert np.allclose(predict_result.prediction, ptdata) return (train_result, predict_result, ptdata) @@ -66,6 +67,6 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nGround truth (first 20 observations):\n", ptdata[:20]) print( "Stump regression results: (first 20 observations):\n", - predict_result.prediction[:20] + predict_result.prediction[:20], ) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/svd.py b/examples/daal4py/svd.py index 059d71e4e8..002d895787 100644 --- a/examples/daal4py/svd.py +++ b/examples/daal4py/svd.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py SVD example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float32) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=np.float32) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=np.float32) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=np.float32) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): infile = "./data/batch/svd.csv" # configure a SVD object @@ -48,23 +49,23 @@ def main(readcsv=read_csv, method='defaultDense'): # SVD result objects provide leftSingularMatrix, # rightSingularMatrix and singularValues - assert np.allclose(result1.leftSingularMatrix, - result2.leftSingularMatrix, atol=1e-07) - assert np.allclose(result1.rightSingularMatrix, - result2.rightSingularMatrix, atol=1e-07) + assert np.allclose(result1.leftSingularMatrix, result2.leftSingularMatrix, atol=1e-07) + assert np.allclose( + result1.rightSingularMatrix, result2.rightSingularMatrix, atol=1e-07 + ) assert np.allclose(result1.singularValues, result2.singularValues, atol=1e-07) assert result1.singularValues.shape == (1, data.shape[1]) assert result1.rightSingularMatrix.shape == (data.shape[1], data.shape[1]) assert result1.leftSingularMatrix.shape == data.shape - if hasattr(data, 'toarray'): + if hasattr(data, "toarray"): data = data.toarray() # to make the next assertion work with scipy's csr_matrix assert np.allclose( data, np.matmul( np.matmul(result1.leftSingularMatrix, np.diag(result1.singularValues[0])), - result1.rightSingularMatrix - ) + result1.rightSingularMatrix, + ), ) return (data, result1) @@ -73,4 +74,4 @@ def main(readcsv=read_csv, method='defaultDense'): if __name__ == "__main__": (_, result) = main() print(result) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/svm.py b/examples/daal4py/svm.py index 023612dbf1..38e35e8677 100644 --- a/examples/daal4py/svm.py +++ b/examples/daal4py/svm.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py SVM example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # input data file infile = "./data/batch/svm_two_class_train_dense.csv" testfile = "./data/batch/svm_two_class_test_dense.csv" @@ -40,7 +41,7 @@ def main(readcsv=read_csv, method='defaultDense'): # Configure a SVM object to use rbf kernel (and adjusting cachesize) kern = d4p.kernel_function_linear() # need an object that lives when creating train_algo - train_algo = d4p.svm_training(method='thunder', kernel=kern, cacheSize=600000000) + train_algo = d4p.svm_training(method="thunder", kernel=kern, cacheSize=600000000) # Read data. Let's use features per observation data = readcsv(infile, range(20)) @@ -70,8 +71,8 @@ def main(readcsv=read_csv, method='defaultDense'): print( "\nSVM classification decision function (first 20 observations):\n", - decision_function[0:20] + decision_function[0:20], ) print("\nSVM classification results (first 20 observations):\n", predict_labels[0:20]) print("\nGround truth (first 20 observations):\n", plabels[0:20]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/svm_multiclass.py b/examples/daal4py/svm_multiclass.py index 3b6e07dfe9..f56c814f9d 100644 --- a/examples/daal4py/svm_multiclass.py +++ b/examples/daal4py/svm_multiclass.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py multi-class SVM example for shared memory systems @@ -25,28 +25,29 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): nFeatures = 20 nClasses = 5 # read training data from file # with nFeatures features per observation and 1 class label - train_file = 'data/batch/svm_multi_class_train_dense.csv' + train_file = "data/batch/svm_multi_class_train_dense.csv" train_data = readcsv(train_file, range(nFeatures)) train_labels = readcsv(train_file, range(nFeatures, nFeatures + 1)) # Create and configure algorithm object algorithm = d4p.multi_class_classifier_training( nClasses=nClasses, - training=d4p.svm_training(method='thunder'), - prediction=d4p.svm_prediction() + training=d4p.svm_training(method="thunder"), + prediction=d4p.svm_prediction(), ) # Pass data to training. Training result provides model @@ -56,15 +57,15 @@ def main(readcsv=read_csv, method='defaultDense'): # Now the prediction stage # Read data - pred_file = 'data/batch/svm_multi_class_test_dense.csv' + pred_file = "data/batch/svm_multi_class_test_dense.csv" pred_data = readcsv(pred_file, range(nFeatures)) pred_labels = readcsv(pred_file, range(nFeatures, nFeatures + 1)) # Create an algorithm object to predict multi-class SVM values algorithm = d4p.multi_class_classifier_prediction( nClasses, - training=d4p.svm_training(method='thunder'), - prediction=d4p.svm_prediction() + training=d4p.svm_training(method="thunder"), + prediction=d4p.svm_prediction(), ) # Pass data to prediction. Prediction result provides prediction pred_result = algorithm.compute(pred_data, train_result.model) @@ -77,7 +78,7 @@ def main(readcsv=read_csv, method='defaultDense'): (pred_res, pred_labels) = main() print( "\nSVM classification results (first 20 observations):\n", - pred_res.prediction[0:20] + pred_res.prediction[0:20], ) print("\nGround truth (first 20 observations):\n", pred_labels[0:20]) - print('All looks good!') + print("All looks good!") diff --git a/examples/daal4py/univariate_outlier.py b/examples/daal4py/univariate_outlier.py index 9e71fffa57..886e3268a8 100644 --- a/examples/daal4py/univariate_outlier.py +++ b/examples/daal4py/univariate_outlier.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # daal4py outlier detection univariate example for shared memory systems @@ -25,14 +25,15 @@ import pandas def read_csv(f, c, t=np.float64): - return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t) + return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t) + except ImportError: # fall back to numpy loadtxt def read_csv(f, c, t=np.float64): - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2) -def main(readcsv=read_csv, method='defaultDense'): +def main(readcsv=read_csv, method="defaultDense"): # Input file infile = "./data/batch/outlierdetection.csv" @@ -56,4 +57,4 @@ def main(readcsv=read_csv, method='defaultDense'): print("\nInput data\n", data) print("\nOutlier detection result (univariate) weights:\n", res.weights) - print('All looks good!') + print("All looks good!") diff --git a/examples/sklearnex/n_jobs.py b/examples/sklearnex/n_jobs.py index 0d6ef515ec..df999792db 100644 --- a/examples/sklearnex/n_jobs.py +++ b/examples/sklearnex/n_jobs.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2023 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # sklearnex doesn't have interface for threading configuration and not following # scikit-learn n_jobs yet. Thus it's requered to use daal4py package to set this. diff --git a/examples/sklearnex/patch_sklearn.py b/examples/sklearnex/patch_sklearn.py index 5b46b366e4..a0261e1b6d 100644 --- a/examples/sklearnex/patch_sklearn.py +++ b/examples/sklearnex/patch_sklearn.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2023 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # Calling scikit-learn patch - this would enable acceleration on all # enabled algorithms. This is most straight forward way of patching @@ -38,10 +38,10 @@ # Direct import of functions in way aligned with scikit-learn from sklearnex.neighbors import NearestNeighbors -#Patching can be enabled for selected algorithms/estimators only +# Patching can be enabled for selected algorithms/estimators only patch_sklearn(["DBSCAN"]) -#Remaining non modified scikit-learn codes +# Remaining non modified scikit-learn codes from sklearn.datasets import make_blobs from sklearn.preprocessing import StandardScaler diff --git a/examples/sklearnex/verbose_mode.py b/examples/sklearnex/verbose_mode.py index 6d3bf6c828..7716e32e14 100644 --- a/examples/sklearnex/verbose_mode.py +++ b/examples/sklearnex/verbose_mode.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2023 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # sklearnex can help you debug your aplications by printing messages on it's invocation # to allow you to see if stock of accelerated version was used. @@ -23,7 +23,7 @@ sys.exit() import logging -logging.getLogger('sklearnex').setLevel(logging.INFO) +logging.getLogger("sklearnex").setLevel(logging.INFO) # Calling scikit-learn patch - this would enable acceleration on all enabled algorithms from sklearnex import patch_sklearn diff --git a/examples/utils/spmd_utils.py b/examples/utils/spmd_utils.py index 26c7de0dff..a5bb96e889 100644 --- a/examples/utils/spmd_utils.py +++ b/examples/utils/spmd_utils.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== # Example showing reading of file in few chunks, this reader is used in SPMD examples @@ -23,20 +23,23 @@ import pandas def read_csv(f, c=None, sr=0, nr=None, t=np.float64): - return pandas.read_csv(f, usecols=c, skiprows=sr, nrows=nr, - delimiter=',', header=None, dtype=t) + return pandas.read_csv( + f, usecols=c, skiprows=sr, nrows=nr, delimiter=",", header=None, dtype=t + ) + except: # fall back to numpy loadtxt def read_csv(f, c=None, sr=0, nr=np.iinfo(np.int64).max, t=np.float64): - res = np.genfromtxt(f, usecols=c, delimiter=',', - skip_header=sr, max_rows=nr, dtype=t) + res = np.genfromtxt( + f, usecols=c, delimiter=",", skip_header=sr, max_rows=nr, dtype=t + ) if res.ndim == 1: return res[:, np.newaxis] return res def get_chunk_params(lines_count, chunks_count, chunk_number): - 'returns count of rows to skip from beginning of file and count of rows to read' + "returns count of rows to skip from beginning of file and count of rows to read" min_nrows = (int)(lines_count / chunks_count) rest_rows = lines_count - min_nrows * chunks_count is_tail = rest_rows > chunk_number diff --git a/tests/run_examples.py b/tests/run_examples.py index d9a8a092ae..329f951aaa 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -188,10 +188,12 @@ def check_library(rule): req_os = defaultdict(lambda: []) -skiped_files = ['log_reg_model_builder.py', - 'n_jobs.py', - 'verbose_mode.py', - 'patch_sklearn.py'] +skiped_files = [ + "log_reg_model_builder.py", + "n_jobs.py", + "verbose_mode.py", + "patch_sklearn.py", +] def get_exe_cmd(ex, nodist, nostream): @@ -220,7 +222,7 @@ def get_exe_cmd(ex, nodist, nostream): return None if not check_library(req_library[os.path.basename(ex)]): return None - if not nodist and ex.endswith('spmd.py'): + if not nodist and ex.endswith("spmd.py"): if IS_WIN: return 'mpiexec -localonly -n 4 "' + sys.executable + '" "' + ex + '"' return 'mpirun -n 4 "' + sys.executable + '" "' + ex + '"' @@ -235,50 +237,58 @@ def run(exdir, logdir, nodist=False, nostream=False): os.makedirs(logdir) for dirpath, dirnames, filenames in os.walk(exdir): for script in filenames: - if script.endswith('.py') and script not in ['__init__.py']: + if script.endswith(".py") and script not in ["__init__.py"]: n += 1 if script in skiped_files: - print(strftime("%H:%M:%S", gmtime()) + '\tKNOWN BUG IN EXAMPLES\t' + script) + print( + strftime("%H:%M:%S", gmtime()) + + "\tKNOWN BUG IN EXAMPLES\t" + + script + ) else: - logfn = jp(logdir, script.replace(".py", ".res")) - with open(logfn, "w") as logfile: - print("\n##### " + jp(dirpath, script)) - execute_string = get_exe_cmd(jp(dirpath, script), nodist, nostream) - if execute_string: - os.chdir(dirpath) - proc = subprocess.Popen( - execute_string - if IS_WIN - else ["/bin/bash", "-c", execute_string], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - shell=False, - ) - out = proc.communicate()[0] - logfile.write(out.decode("ascii")) - if proc.returncode: - print(out) - print( - strftime("%H:%M:%S", gmtime()) + "\tFAILED" - "\t" + script + "\twith errno" - "\t" + str(proc.returncode) - ) - out = proc.communicate()[0] - logfile.write(out.decode('ascii')) - if proc.returncode: - print(out) - print( - strftime("%H:%M:%S", gmtime()) + '\tFAILED' - '\t' + script + '\twith errno' - '\t' + str(proc.returncode) - ) - else: - success += 1 - print(strftime("%H:%M:%S", gmtime()) + '\t' - 'PASSED\t' + script) - else: - success += 1 - print(strftime("%H:%M:%S", gmtime()) + '\tSKIPPED\t' + script) + logfn = jp(logdir, script.replace(".py", ".res")) + with open(logfn, "w") as logfile: + print("\n##### " + jp(dirpath, script)) + execute_string = get_exe_cmd( + jp(dirpath, script), nodist, nostream + ) + if execute_string: + os.chdir(dirpath) + proc = subprocess.Popen( + execute_string + if IS_WIN + else ["/bin/bash", "-c", execute_string], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + shell=False, + ) + out = proc.communicate()[0] + logfile.write(out.decode("ascii")) + if proc.returncode: + print(out) + print( + strftime("%H:%M:%S", gmtime()) + "\tFAILED" + "\t" + script + "\twith errno" + "\t" + str(proc.returncode) + ) + out = proc.communicate()[0] + logfile.write(out.decode("ascii")) + if proc.returncode: + print(out) + print( + strftime("%H:%M:%S", gmtime()) + "\tFAILED" + "\t" + script + "\twith errno" + "\t" + str(proc.returncode) + ) + else: + success += 1 + print( + strftime("%H:%M:%S", gmtime()) + "\t" + "PASSED\t" + script + ) + else: + success += 1 + print(strftime("%H:%M:%S", gmtime()) + "\tSKIPPED\t" + script) return success, n diff --git a/tests/spmd_test_examples.py b/tests/spmd_test_examples.py index 217f2833e2..2f6b5519b4 100644 --- a/tests/spmd_test_examples.py +++ b/tests/spmd_test_examples.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== import os @@ -24,25 +24,26 @@ import numpy as np from test_examples import add_test, np_read_csv - class Base(): + class Base: def test_svd_spmd(self): import svd_spmd as ex + (data, result) = self.call(ex) self.assertTrue( np.allclose( data, np.matmul( np.matmul( - result.leftSingularMatrix, - np.diag(result.singularValues[0]) + result.leftSingularMatrix, np.diag(result.singularValues[0]) ), - result.rightSingularMatrix - ) + result.rightSingularMatrix, + ), ) ) def test_qr_spmd(self): import qr_spmd as ex + (data, result) = self.call(ex) self.assertTrue(np.allclose(data, np.matmul(result.matrixQ, result.matrixR))) @@ -50,60 +51,67 @@ def test_kmeans_spmd(self): nClusters = 10 maxIter = 25 - data = np.loadtxt("./data/distributed/kmeans_dense.csv", delimiter=',') + data = np.loadtxt("./data/distributed/kmeans_dense.csv", delimiter=",") rpp = int(data.shape[0] / d4p.num_procs()) - spmd_data = data[rpp * d4p.my_procid():rpp * d4p.my_procid() + rpp, :] - - for init_method in ['plusPlusDense', - 'parallelPlusDense', - 'deterministicDense']: - batch_init_res = d4p.kmeans_init(nClusters=nClusters, - method=init_method).compute(data) - spmd_init_res = d4p.kmeans_init(nClusters=nClusters, - method=init_method, - distributed=True).compute(spmd_data) - - if init_method in ['parallelPlusDense']: - print("Warning: It is well known " - "that results of parallelPlusDense init " - "does not match with batch algorithm") + spmd_data = data[rpp * d4p.my_procid() : rpp * d4p.my_procid() + rpp, :] + + for init_method in [ + "plusPlusDense", + "parallelPlusDense", + "deterministicDense", + ]: + batch_init_res = d4p.kmeans_init( + nClusters=nClusters, method=init_method + ).compute(data) + spmd_init_res = d4p.kmeans_init( + nClusters=nClusters, method=init_method, distributed=True + ).compute(spmd_data) + + if init_method in ["parallelPlusDense"]: + print( + "Warning: It is well known " + "that results of parallelPlusDense init " + "does not match with batch algorithm" + ) else: reason = "Initial centroids with " + init_method reason += " does not match with batch algorithm" self.assertTrue( np.allclose(batch_init_res.centroids, spmd_init_res.centroids), - reason + reason, ) batch_res = d4p.kmeans( - nClusters=nClusters, - maxIterations=maxIter).compute(data, batch_init_res.centroids) + nClusters=nClusters, maxIterations=maxIter + ).compute(data, batch_init_res.centroids) spmd_res = d4p.kmeans( - nClusters=nClusters, - maxIterations=maxIter, - distributed=True).compute(spmd_data, spmd_init_res.centroids) - - if init_method in ['parallelPlusDense']: - print("Warning: It is well known " - "that results of parallelPlusDense init " - "does not match with batch algorithm") + nClusters=nClusters, maxIterations=maxIter, distributed=True + ).compute(spmd_data, spmd_init_res.centroids) + + if init_method in ["parallelPlusDense"]: + print( + "Warning: It is well known " + "that results of parallelPlusDense init " + "does not match with batch algorithm" + ) else: reason = "Final centroids with " + init_method reason += " does not match with batch algorithm" self.assertTrue( - np.allclose(batch_res.centroids, spmd_res.centroids), - reason + np.allclose(batch_res.centroids, spmd_res.centroids), reason ) def test_dbscan_spmd(self): epsilon = 0.04 minObservations = 45 - data = np_read_csv(os.path.join(".", 'data', 'batch', 'dbscan_dense.csv')) + data = np_read_csv(os.path.join(".", "data", "batch", "dbscan_dense.csv")) - batch_algo = d4p.dbscan(minObservations=minObservations, - epsilon=epsilon, - resultsToCompute='computeCoreIndices') + batch_algo = d4p.dbscan( + minObservations=minObservations, + epsilon=epsilon, + resultsToCompute="computeCoreIndices", + ) batch_result = batch_algo.compute(data) rpp = int(data.shape[0] / d4p.num_procs()) @@ -111,8 +119,9 @@ def test_dbscan_spmd(self): node_range = range(node_stride, node_stride + rpp) node_data = data[node_range, :] - spmd_algo = d4p.dbscan(minObservations=minObservations, - epsilon=epsilon, distributed=True) + spmd_algo = d4p.dbscan( + minObservations=minObservations, epsilon=epsilon, distributed=True + ) spmd_result = spmd_algo.compute(node_data) # clusters can get different indexes in batch and spmd algos, @@ -126,16 +135,28 @@ def test_dbscan_spmd(self): if not batch_result.assignments[i][0] in cluster_index_dict: cluster_index_dict[batch_result.assignments[i][0]] = right left = cluster_index_dict[batch_result.assignments[i][0]] - self.assertTrue( - left == right - ) + self.assertTrue(left == right) gen_examples = [ - ('covariance_spmd', 'covariance.csv', 'covariance'), - ('low_order_moms_spmd', 'low_order_moms_dense.csv', - lambda r: np.vstack((r.minimum, r.maximum, r.sum, r.sumSquares, - r.sumSquaresCentered, r.mean, r.secondOrderRawMoment, - r.variance, r.standardDeviation, r.variation))), + ("covariance_spmd", "covariance.csv", "covariance"), + ( + "low_order_moms_spmd", + "low_order_moms_dense.csv", + lambda r: np.vstack( + ( + r.minimum, + r.maximum, + r.sum, + r.sumSquares, + r.sumSquaresCentered, + r.mean, + r.secondOrderRawMoment, + r.variance, + r.standardDeviation, + r.variation, + ) + ), + ), ] for example in gen_examples: @@ -153,5 +174,5 @@ def tearDownClass(cls): def call(self, ex): return ex.main() - if __name__ == '__main__': + if __name__ == "__main__": unittest.main() diff --git a/tests/test_examples.py b/tests/test_examples.py index c1a2d98c2f..1a395e8f16 100755 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -1,4 +1,4 @@ -#=============================================================================== +# =============================================================================== # Copyright 2014 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -#=============================================================================== +# =============================================================================== import os import sys @@ -35,7 +35,7 @@ # second is minor+patch - 0110, # third item is status - B daal_version = get_daal_version() -print('DAAL version:', daal_version) +print("DAAL version:", daal_version) def check_version(rule, target): @@ -54,7 +54,7 @@ def check_version(rule, target): def check_libraries(rule): for rule_item in rule: try: - __import__(rule_item, fromlist=['']) + __import__(rule_item, fromlist=[""]) except ImportError: return False return True @@ -63,8 +63,8 @@ def check_libraries(rule): # function reading file and returning numpy array def np_read_csv(f, c=None, s=0, n=np.iinfo(np.int64).max, t=np.float64): if s == 0 and n == np.iinfo(np.int64).max: - return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=t) - a = np.genfromtxt(f, usecols=c, delimiter=',', skip_header=s, max_rows=n, dtype=t) + return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2, dtype=t) + a = np.genfromtxt(f, usecols=c, delimiter=",", skip_header=s, max_rows=n, dtype=t) if a.shape[0] == 0: raise Exception("done") if a.ndim == 1: @@ -74,8 +74,9 @@ def np_read_csv(f, c=None, s=0, n=np.iinfo(np.int64).max, t=np.float64): # function reading file and returning pandas DataFrame def pd_read_csv(f, c=None, s=0, n=None, t=np.float64): - return pd.read_csv(f, usecols=c, delimiter=',', header=None, - skiprows=s, nrows=n, dtype=t) + return pd.read_csv( + f, usecols=c, delimiter=",", header=None, skiprows=s, nrows=n, dtype=t + ) # function reading file and returning scipy.sparse.csr_matrix @@ -88,11 +89,10 @@ def add_test(cls, e, f=None, attr=None, ver=(0, 0), req_libs=[]): @unittest.skipUnless( check_version(ver, daal_version), - str(ver) + " not supported in this library version " + str(daal_version) + str(ver) + " not supported in this library version " + str(daal_version), ) @unittest.skipUnless( - check_libraries(req_libs), - "cannot import required libraries " + str(req_libs) + check_libraries(req_libs), "cannot import required libraries " + str(req_libs) ) def testit(self): ex = importlib.import_module(e) @@ -102,57 +102,73 @@ def testit(self): actual = attr(result) if callable(attr) else getattr(result, attr) self.assertTrue( np.allclose(actual, testdata, atol=1e-05), - msg="Discrepancy found: {}".format(np.abs(actual - testdata).max()) + msg="Discrepancy found: {}".format(np.abs(actual - testdata).max()), ) else: self.assertTrue(True) - setattr(cls, 'test_' + e, testit) + + setattr(cls, "test_" + e, testit) -class Base(): +class Base: """ We also use generic functions to test these, they get added later. """ def test_svd(self): import svd as ex + (data, result) = self.call(ex) - self.assertTrue(np.allclose(data, - np.matmul( - np.matmul(result.leftSingularMatrix, - np.diag(result.singularValues[0])), - result.rightSingularMatrix) - ) - ) + self.assertTrue( + np.allclose( + data, + np.matmul( + np.matmul( + result.leftSingularMatrix, np.diag(result.singularValues[0]) + ), + result.rightSingularMatrix, + ), + ) + ) def test_svd_stream(self): import svd_streaming as ex + result = self.call(ex) - data = np.loadtxt("./data/distributed/svd_1.csv", delimiter=',') + data = np.loadtxt("./data/distributed/svd_1.csv", delimiter=",") for f in ["./data/distributed/svd_{}.csv".format(i) for i in range(2, 5)]: - data = np.append(data, np.loadtxt(f, delimiter=','), axis=0) - self.assertTrue(np.allclose(data, - np.matmul(np.matmul(result.leftSingularMatrix, - np.diag(result.singularValues[0])), - result.rightSingularMatrix))) + data = np.append(data, np.loadtxt(f, delimiter=","), axis=0) + self.assertTrue( + np.allclose( + data, + np.matmul( + np.matmul( + result.leftSingularMatrix, np.diag(result.singularValues[0]) + ), + result.rightSingularMatrix, + ), + ) + ) def test_qr(self): import qr as ex + (data, result) = self.call(ex) self.assertTrue(np.allclose(data, np.matmul(result.matrixQ, result.matrixR))) def test_qr_stream(self): import qr_streaming as ex + result = self.call(ex) - data = np.loadtxt("./data/distributed/qr_1.csv", delimiter=',') + data = np.loadtxt("./data/distributed/qr_1.csv", delimiter=",") for f in ["./data/distributed/qr_{}.csv".format(i) for i in range(2, 5)]: - data = np.append(data, np.loadtxt(f, delimiter=','), axis=0) + data = np.append(data, np.loadtxt(f, delimiter=","), axis=0) self.assertTrue(np.allclose(data, np.matmul(result.matrixQ, result.matrixR))) def test_svm(self): - testdata = np_read_csv(os.path.join(unittest_data_path, "svm.csv"), - range(1)) + testdata = np_read_csv(os.path.join(unittest_data_path, "svm.csv"), range(1)) import svm as ex + (decision_result, _, _) = self.call(ex) left = np.absolute(decision_result - testdata).max() right = np.absolute(decision_result.max() - decision_result.min()) * 0.05 @@ -160,103 +176,174 @@ def test_svm(self): gen_examples = [ - ('adaboost', None, None, (2020, 'P', 0)), - ('adagrad_mse', 'adagrad_mse.csv', 'minimum'), - ('association_rules', 'association_rules.csv', 'confidence'), - ('bacon_outlier', 'multivariate_outlier.csv', lambda r: r[1].weights), - ('brownboost', None, None, (2020, 'P', 0)), - ('correlation_distance', 'correlation_distance.csv', - lambda r: [[np.amin(r.correlationDistance)], - [np.amax(r.correlationDistance)], - [np.mean(r.correlationDistance)], - [np.average(r.correlationDistance)]]), - ('cosine_distance', 'cosine_distance.csv', - lambda r: [[np.amin(r.cosineDistance)], - [np.amax(r.cosineDistance)], - [np.mean(r.cosineDistance)], - [np.average(r.cosineDistance)]]), + ("adaboost", None, None, (2020, "P", 0)), + ("adagrad_mse", "adagrad_mse.csv", "minimum"), + ("association_rules", "association_rules.csv", "confidence"), + ("bacon_outlier", "multivariate_outlier.csv", lambda r: r[1].weights), + ("brownboost", None, None, (2020, "P", 0)), + ( + "correlation_distance", + "correlation_distance.csv", + lambda r: [ + [np.amin(r.correlationDistance)], + [np.amax(r.correlationDistance)], + [np.mean(r.correlationDistance)], + [np.average(r.correlationDistance)], + ], + ), + ( + "cosine_distance", + "cosine_distance.csv", + lambda r: [ + [np.amin(r.cosineDistance)], + [np.amax(r.cosineDistance)], + [np.mean(r.cosineDistance)], + [np.average(r.cosineDistance)], + ], + ), # ('gradient_boosted_regression', 'gradient_boosted_regression.csv', # lambda x: x[1].prediction), - ('cholesky', 'cholesky.csv', 'choleskyFactor'), - ('covariance', 'covariance.csv', 'covariance'), - ('covariance_streaming', 'covariance.csv', 'covariance'), - ('decision_forest_classification_default_dense', - None, lambda r: r[1].prediction, (2023, 'P', 1)), - ('decision_forest_classification_hist', - None, lambda r: r[1].prediction, (2023, 'P', 1)), - ('decision_forest_regression_default_dense', - 'decision_forest_regression.csv', lambda r: r[1].prediction, (2023, 'P', 1)), - ('decision_forest_regression_hist', - 'decision_forest_regression.csv', lambda r: r[1].prediction, (2023, 'P', 1)), - ('decision_forest_regression_default_dense', - 'decision_forest_regression_20230101.csv', - lambda r: r[1].prediction, (2023, 'P', 101)), - ('decision_forest_regression_hist', - 'decision_forest_regression_20230101.csv', - lambda r: r[1].prediction, (2023, 'P', 101)), - ('decision_tree_classification', 'decision_tree_classification.csv', - lambda r: r[1].prediction), - ('decision_tree_regression', 'decision_tree_regression.csv', - lambda r: r[1].prediction), - ('distributions_bernoulli',), - ('distributions_normal',), - ('distributions_uniform',), - ('em_gmm', 'em_gmm.csv', lambda r: r.covariances[0]), - ('model_builders_lightgbm', None, None, - ((2020, 'P', 2), (2021, 'B', 109)), ['lightgbm']), - ('model_builders_xgboost', None, None, - ((2020, 'P', 2), (2021, 'B', 109)), ['xgboost']), - ('model_builders_catboost', None, None, - (2021, 'P', 4), ['catboost']), - ('gradient_boosted_classification',), - ('gradient_boosted_regression',), - ('implicit_als', 'implicit_als.csv', 'prediction'), - ('kdtree_knn_classification', None, None), - ('kmeans', 'kmeans.csv', 'centroids'), - ('lbfgs_cr_entr_loss', 'lbfgs_cr_entr_loss.csv', 'minimum'), - ('lbfgs_mse', 'lbfgs_mse.csv', 'minimum'), - ('linear_regression', 'linear_regression.csv', - lambda r: r[1].prediction), - ('linear_regression_streaming', 'linear_regression.csv', - lambda r: r[1].prediction), + ("cholesky", "cholesky.csv", "choleskyFactor"), + ("covariance", "covariance.csv", "covariance"), + ("covariance_streaming", "covariance.csv", "covariance"), + ( + "decision_forest_classification_default_dense", + None, + lambda r: r[1].prediction, + (2023, "P", 1), + ), + ( + "decision_forest_classification_hist", + None, + lambda r: r[1].prediction, + (2023, "P", 1), + ), + ( + "decision_forest_regression_default_dense", + "decision_forest_regression.csv", + lambda r: r[1].prediction, + (2023, "P", 1), + ), + ( + "decision_forest_regression_hist", + "decision_forest_regression.csv", + lambda r: r[1].prediction, + (2023, "P", 1), + ), + ( + "decision_forest_regression_default_dense", + "decision_forest_regression_20230101.csv", + lambda r: r[1].prediction, + (2023, "P", 101), + ), + ( + "decision_forest_regression_hist", + "decision_forest_regression_20230101.csv", + lambda r: r[1].prediction, + (2023, "P", 101), + ), + ( + "decision_tree_classification", + "decision_tree_classification.csv", + lambda r: r[1].prediction, + ), + ( + "decision_tree_regression", + "decision_tree_regression.csv", + lambda r: r[1].prediction, + ), + ("distributions_bernoulli",), + ("distributions_normal",), + ("distributions_uniform",), + ("em_gmm", "em_gmm.csv", lambda r: r.covariances[0]), + ( + "model_builders_lightgbm", + None, + None, + ((2020, "P", 2), (2021, "B", 109)), + ["lightgbm"], + ), + ( + "model_builders_xgboost", + None, + None, + ((2020, "P", 2), (2021, "B", 109)), + ["xgboost"], + ), + ("model_builders_catboost", None, None, (2021, "P", 4), ["catboost"]), + ("gradient_boosted_classification",), + ("gradient_boosted_regression",), + ("implicit_als", "implicit_als.csv", "prediction"), + ("kdtree_knn_classification", None, None), + ("kmeans", "kmeans.csv", "centroids"), + ("lbfgs_cr_entr_loss", "lbfgs_cr_entr_loss.csv", "minimum"), + ("lbfgs_mse", "lbfgs_mse.csv", "minimum"), + ("linear_regression", "linear_regression.csv", lambda r: r[1].prediction), + ("linear_regression_streaming", "linear_regression.csv", lambda r: r[1].prediction), # return when Logistic Regression will be fixed # ('log_reg_binary_dense', 'log_reg_binary_dense.csv', # lambda r: r[1].prediction), - ('log_reg_binary_dense', None, None), - ('log_reg_dense',), - ('logitboost', None, None, (2020, 'P', 0)), - ('low_order_moms_dense', 'low_order_moms_dense.csv', - lambda r: np.vstack((r.minimum, r.maximum, r.sum, r.sumSquares, - r.sumSquaresCentered, r.mean, r.secondOrderRawMoment, - r.variance, r.standardDeviation, r.variation))), - ('low_order_moms_streaming', 'low_order_moms_dense.csv', - lambda r: np.vstack((r.minimum, r.maximum, r.sum, r.sumSquares, - r.sumSquaresCentered, r.mean, r.secondOrderRawMoment, - r.variance, r.standardDeviation, r.variation))), - ('multivariate_outlier', 'multivariate_outlier.csv', - lambda r: r[1].weights), - ('naive_bayes', 'naive_bayes.csv', lambda r: r[0].prediction), - ('naive_bayes_streaming', 'naive_bayes.csv', lambda r: r[0].prediction), - ('normalization_minmax', 'normalization_minmax.csv', 'normalizedData'), - ('normalization_zscore', 'normalization_zscore.csv', 'normalizedData'), - ('pca', 'pca.csv', 'eigenvectors'), - ('pca_transform', 'pca_transform.csv', lambda r: r[1].transformedData), - ('pivoted_qr', 'pivoted_qr.csv', 'matrixR'), - ('quantiles', 'quantiles.csv', 'quantiles'), - ('ridge_regression', 'ridge_regression.csv', lambda r: r[0].prediction), - ('ridge_regression_streaming', 'ridge_regression.csv', - lambda r: r[0].prediction), - ('saga', None, None, (2019, 'P', 3)), - ('sgd_logistic_loss', 'sgd_logistic_loss.csv', 'minimum'), - ('sgd_mse', 'sgd_mse.csv', 'minimum'), - ('sorting',), - ('stump_classification', None, None, (2020, 'P', 0)), - ('stump_regression', None, None, (2020, 'P', 0)), - ('svm_multiclass', 'svm_multiclass.csv', lambda r: r[0].prediction), - ('univariate_outlier', 'univariate_outlier.csv', lambda r: r[1].weights), - ('dbscan', 'dbscan.csv', 'assignments', (2019, 'P', 5)), - ('lasso_regression', None, None, (2019, 'P', 5)), - ('elastic_net', None, None, ((2020, 'P', 1), (2021, 'B', 105))), + ("log_reg_binary_dense", None, None), + ("log_reg_dense",), + ("logitboost", None, None, (2020, "P", 0)), + ( + "low_order_moms_dense", + "low_order_moms_dense.csv", + lambda r: np.vstack( + ( + r.minimum, + r.maximum, + r.sum, + r.sumSquares, + r.sumSquaresCentered, + r.mean, + r.secondOrderRawMoment, + r.variance, + r.standardDeviation, + r.variation, + ) + ), + ), + ( + "low_order_moms_streaming", + "low_order_moms_dense.csv", + lambda r: np.vstack( + ( + r.minimum, + r.maximum, + r.sum, + r.sumSquares, + r.sumSquaresCentered, + r.mean, + r.secondOrderRawMoment, + r.variance, + r.standardDeviation, + r.variation, + ) + ), + ), + ("multivariate_outlier", "multivariate_outlier.csv", lambda r: r[1].weights), + ("naive_bayes", "naive_bayes.csv", lambda r: r[0].prediction), + ("naive_bayes_streaming", "naive_bayes.csv", lambda r: r[0].prediction), + ("normalization_minmax", "normalization_minmax.csv", "normalizedData"), + ("normalization_zscore", "normalization_zscore.csv", "normalizedData"), + ("pca", "pca.csv", "eigenvectors"), + ("pca_transform", "pca_transform.csv", lambda r: r[1].transformedData), + ("pivoted_qr", "pivoted_qr.csv", "matrixR"), + ("quantiles", "quantiles.csv", "quantiles"), + ("ridge_regression", "ridge_regression.csv", lambda r: r[0].prediction), + ("ridge_regression_streaming", "ridge_regression.csv", lambda r: r[0].prediction), + ("saga", None, None, (2019, "P", 3)), + ("sgd_logistic_loss", "sgd_logistic_loss.csv", "minimum"), + ("sgd_mse", "sgd_mse.csv", "minimum"), + ("sorting",), + ("stump_classification", None, None, (2020, "P", 0)), + ("stump_regression", None, None, (2020, "P", 0)), + ("svm_multiclass", "svm_multiclass.csv", lambda r: r[0].prediction), + ("univariate_outlier", "univariate_outlier.csv", lambda r: r[1].weights), + ("dbscan", "dbscan.csv", "assignments", (2019, "P", 5)), + ("lasso_regression", None, None, (2019, "P", 5)), + ("elastic_net", None, None, ((2020, "P", 1), (2021, "B", 105))), ] for example in gen_examples: @@ -268,6 +355,7 @@ class TestExNpyArray(Base, unittest.TestCase): We run and validate all the examples but read data with numpy, so working natively on a numpy arrays. """ + def call(self, ex): return ex.main(readcsv=np_read_csv) @@ -277,6 +365,7 @@ class TestExPandasDF(Base, unittest.TestCase): We run and validate all the examples but read data with pandas, so working natively on a pandas DataFrame """ + def call(self, ex): return ex.main(readcsv=pd_read_csv) @@ -287,31 +376,39 @@ class TestExCSRMatrix(Base, unittest.TestCase): We also let algos use CSR method (some algos ignore the method argument since they do not specifically support CSR). """ + def call(self, ex): # some algos do not support CSR matrices - if ex.__name__.startswith('sorting'): + if ex.__name__.startswith("sorting"): self.skipTest("not supporting CSR") - if any(ex.__name__.startswith(x) for x in ['adaboost', - 'brownboost', - 'stump_classification', - 'model_builders', - 'decision_forest']): + if any( + ex.__name__.startswith(x) + for x in [ + "adaboost", + "brownboost", + "stump_classification", + "model_builders", + "decision_forest", + ] + ): self.skipTest("not supporting CSR") - method = \ - 'singlePassCSR' if any(x in ex.__name__ - for x in ['low_order_moms', 'covariance']) \ - else 'fastCSR' + method = ( + "singlePassCSR" + if any(x in ex.__name__ for x in ["low_order_moms", "covariance"]) + else "fastCSR" + ) # cannot use fastCSR ofr implicit als - if 'implicit_als' in ex.__name__: - method = 'defaultDense' + if "implicit_als" in ex.__name__: + method = "defaultDense" # kmeans have no special method for CSR - if 'kmeans' in ex.__name__: - method = 'randomDense' - if hasattr(ex, 'dflt_method'): - method = ex.dflt_method.replace('defaultDense', - 'fastCSR').replace('Dense', 'CSR') + if "kmeans" in ex.__name__: + method = "randomDense" + if hasattr(ex, "dflt_method"): + method = ex.dflt_method.replace("defaultDense", "fastCSR").replace( + "Dense", "CSR" + ) return ex.main(readcsv=csr_read_csv, method=method) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() From a60e815073f3a9ccee5e846aa5ee47922cf8fea7 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Thu, 27 Jul 2023 07:30:02 -0700 Subject: [PATCH 10/18] fixes --- examples/daal4py/covariance_spmd.py | 6 ++--- examples/daal4py/low_order_moms_spmd.py | 6 ++--- examples/{utils => daal4py}/spmd_utils.py | 0 ...batch.py => knn_bf_classification_dpnp.py} | 0 ...h.py => random_forest_classifier_dpctl.py} | 0 ...tch.py => random_forest_regressor_dpnp.py} | 0 tests/run_examples.py | 25 ++++++------------- 7 files changed, 13 insertions(+), 24 deletions(-) rename examples/{utils => daal4py}/spmd_utils.py (100%) rename examples/sklearnex/{knn_bf_classification_dpnp_batch.py => knn_bf_classification_dpnp.py} (100%) rename examples/sklearnex/{random_forest_classifier_dpctl_batch.py => random_forest_classifier_dpctl.py} (100%) rename examples/sklearnex/{random_forest_regressor_dpnp_batch.py => random_forest_regressor_dpnp.py} (100%) diff --git a/examples/daal4py/covariance_spmd.py b/examples/daal4py/covariance_spmd.py index c03e69ba02..37245ce1e6 100644 --- a/examples/daal4py/covariance_spmd.py +++ b/examples/daal4py/covariance_spmd.py @@ -18,10 +18,10 @@ # run like this: # mpirun -n 4 python ./covariance_spmd.py -import daal4py as d4p - # let's use a reading of file in chunks (defined in spmd_utils.py) -from examples.utils import get_chunk_params, read_csv +from spmd_utils import get_chunk_params, read_csv + +import daal4py as d4p def main(): diff --git a/examples/daal4py/low_order_moms_spmd.py b/examples/daal4py/low_order_moms_spmd.py index 58d3f1b505..0cd4102cfb 100644 --- a/examples/daal4py/low_order_moms_spmd.py +++ b/examples/daal4py/low_order_moms_spmd.py @@ -18,10 +18,10 @@ # run like this: # mpirun -n 4 python ./low_order_moms_spmd.py -import daal4py as d4p - # let's use a reading of file in chunks (defined in spmd_utils.py) -from examples.utils import get_chunk_params, read_csv +from spmd_utils import get_chunk_params, read_csv + +import daal4py as d4p def main(): diff --git a/examples/utils/spmd_utils.py b/examples/daal4py/spmd_utils.py similarity index 100% rename from examples/utils/spmd_utils.py rename to examples/daal4py/spmd_utils.py diff --git a/examples/sklearnex/knn_bf_classification_dpnp_batch.py b/examples/sklearnex/knn_bf_classification_dpnp.py similarity index 100% rename from examples/sklearnex/knn_bf_classification_dpnp_batch.py rename to examples/sklearnex/knn_bf_classification_dpnp.py diff --git a/examples/sklearnex/random_forest_classifier_dpctl_batch.py b/examples/sklearnex/random_forest_classifier_dpctl.py similarity index 100% rename from examples/sklearnex/random_forest_classifier_dpctl_batch.py rename to examples/sklearnex/random_forest_classifier_dpctl.py diff --git a/examples/sklearnex/random_forest_regressor_dpnp_batch.py b/examples/sklearnex/random_forest_regressor_dpnp.py similarity index 100% rename from examples/sklearnex/random_forest_regressor_dpnp_batch.py rename to examples/sklearnex/random_forest_regressor_dpnp.py diff --git a/tests/run_examples.py b/tests/run_examples.py index 329f951aaa..b8a9ad82f1 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -240,6 +240,7 @@ def run(exdir, logdir, nodist=False, nostream=False): if script.endswith(".py") and script not in ["__init__.py"]: n += 1 if script in skiped_files: + print("\n##### " + jp(dirpath, script)) print( strftime("%H:%M:%S", gmtime()) + "\tKNOWN BUG IN EXAMPLES\t" @@ -249,9 +250,7 @@ def run(exdir, logdir, nodist=False, nostream=False): logfn = jp(logdir, script.replace(".py", ".res")) with open(logfn, "w") as logfile: print("\n##### " + jp(dirpath, script)) - execute_string = get_exe_cmd( - jp(dirpath, script), nodist, nostream - ) + execute_string = get_exe_cmd(jp(dirpath, script), nodist, nostream) if execute_string: os.chdir(dirpath) proc = subprocess.Popen( @@ -271,23 +270,13 @@ def run(exdir, logdir, nodist=False, nostream=False): "\t" + script + "\twith errno" "\t" + str(proc.returncode) ) - out = proc.communicate()[0] - logfile.write(out.decode("ascii")) - if proc.returncode: - print(out) - print( - strftime("%H:%M:%S", gmtime()) + "\tFAILED" - "\t" + script + "\twith errno" - "\t" + str(proc.returncode) - ) - else: - success += 1 - print( - strftime("%H:%M:%S", gmtime()) + "\t" - "PASSED\t" + script - ) else: success += 1 + print( + strftime("%H:%M:%S", gmtime()) + "\t" "PASSED\t" + script + ) + else: + success += 1 print(strftime("%H:%M:%S", gmtime()) + "\tSKIPPED\t" + script) return success, n From 1e35587afb7b875231382326fcb10a869504c586 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Thu, 27 Jul 2023 07:32:10 -0700 Subject: [PATCH 11/18] black --- tests/run_examples.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/run_examples.py b/tests/run_examples.py index b8a9ad82f1..37196223af 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -250,7 +250,9 @@ def run(exdir, logdir, nodist=False, nostream=False): logfn = jp(logdir, script.replace(".py", ".res")) with open(logfn, "w") as logfile: print("\n##### " + jp(dirpath, script)) - execute_string = get_exe_cmd(jp(dirpath, script), nodist, nostream) + execute_string = get_exe_cmd( + jp(dirpath, script), nodist, nostream + ) if execute_string: os.chdir(dirpath) proc = subprocess.Popen( @@ -273,7 +275,8 @@ def run(exdir, logdir, nodist=False, nostream=False): else: success += 1 print( - strftime("%H:%M:%S", gmtime()) + "\t" "PASSED\t" + script + strftime("%H:%M:%S", gmtime()) + "\t" + "PASSED\t" + script ) else: success += 1 From d7204438394da562e36176b5722005e98c59edec Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Thu, 27 Jul 2023 08:17:57 -0700 Subject: [PATCH 12/18] fixes --- examples/sklearnex/n_jobs.py | 4 ---- examples/sklearnex/patch_sklearn.py | 4 ---- examples/sklearnex/verbose_mode.py | 3 --- tests/run_examples.py | 5 +---- tests/test_examples_sklearnex.py | 2 +- 5 files changed, 2 insertions(+), 16 deletions(-) diff --git a/examples/sklearnex/n_jobs.py b/examples/sklearnex/n_jobs.py index df999792db..4c27a79db3 100644 --- a/examples/sklearnex/n_jobs.py +++ b/examples/sklearnex/n_jobs.py @@ -18,10 +18,6 @@ # scikit-learn n_jobs yet. Thus it's requered to use daal4py package to set this. # nthreads parameter define number of threads used by sklearnex. # Without this code sklearnex would be using all system cores -import sys - -print("KNOWN BUG IN EXAMPLES. TODO: fixme") -sys.exit() import daal4py diff --git a/examples/sklearnex/patch_sklearn.py b/examples/sklearnex/patch_sklearn.py index a0261e1b6d..268e606218 100644 --- a/examples/sklearnex/patch_sklearn.py +++ b/examples/sklearnex/patch_sklearn.py @@ -16,10 +16,6 @@ # Calling scikit-learn patch - this would enable acceleration on all # enabled algorithms. This is most straight forward way of patching -import sys - -print("KNOWN BUG IN EXAMPLES. TODO: fixme") -sys.exit() from sklearnex import patch_sklearn diff --git a/examples/sklearnex/verbose_mode.py b/examples/sklearnex/verbose_mode.py index 7716e32e14..c130660f29 100644 --- a/examples/sklearnex/verbose_mode.py +++ b/examples/sklearnex/verbose_mode.py @@ -17,10 +17,7 @@ # sklearnex can help you debug your aplications by printing messages on it's invocation # to allow you to see if stock of accelerated version was used. # By setting sklearnex logger level to "INFO" you would enable this verbose mode -import sys -print("KNOWN BUG IN EXAMPLES. TODO: fixme") -sys.exit() import logging logging.getLogger("sklearnex").setLevel(logging.INFO) diff --git a/tests/run_examples.py b/tests/run_examples.py index 37196223af..533da71247 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -189,10 +189,7 @@ def check_library(rule): req_os = defaultdict(lambda: []) skiped_files = [ - "log_reg_model_builder.py", - "n_jobs.py", - "verbose_mode.py", - "patch_sklearn.py", + "log_reg_model_builder.py" ] diff --git a/tests/test_examples_sklearnex.py b/tests/test_examples_sklearnex.py index 92e752a29f..45afdb82b2 100644 --- a/tests/test_examples_sklearnex.py +++ b/tests/test_examples_sklearnex.py @@ -60,7 +60,7 @@ def testit(self): files = [ f for f in os.listdir(examples_path) - if f.endswith(".py") and "spmd" not in f and "batch" not in f + if f.endswith(".py") and "spmd" not in f and "dpnp" not in f and "dpctl" not in f ] for file in files: From f0bf9349772aac907b2c213328aa6feb97d5e273 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Thu, 27 Jul 2023 23:45:41 -0700 Subject: [PATCH 13/18] black --- tests/run_examples.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/run_examples.py b/tests/run_examples.py index 533da71247..320a33bbb4 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -188,9 +188,7 @@ def check_library(rule): req_os = defaultdict(lambda: []) -skiped_files = [ - "log_reg_model_builder.py" -] +skiped_files = ["log_reg_model_builder.py"] def get_exe_cmd(ex, nodist, nostream): From cd47d9cfce9976fe2e06115bee6b8fd9675af708 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Fri, 28 Jul 2023 02:58:32 -0700 Subject: [PATCH 14/18] fix --- tests/run_examples.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/run_examples.py b/tests/run_examples.py index 320a33bbb4..073987c121 100755 --- a/tests/run_examples.py +++ b/tests/run_examples.py @@ -235,6 +235,7 @@ def run(exdir, logdir, nodist=False, nostream=False): if script.endswith(".py") and script not in ["__init__.py"]: n += 1 if script in skiped_files: + success += 1 print("\n##### " + jp(dirpath, script)) print( strftime("%H:%M:%S", gmtime()) From 7e5284d5e13a7201ec613a78daa9840c5f9515d4 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Wed, 2 Aug 2023 01:28:10 -0700 Subject: [PATCH 15/18] undo some unnessesary changes --- examples/daal4py/decision_forest_classification_traverse.py | 2 -- examples/daal4py/decision_forest_regression_traverse.py | 2 -- examples/daal4py/gradient_boosted_classification_traverse.py | 2 -- examples/daal4py/gradient_boosted_regression_traverse.py | 2 -- examples/sklearnex/n_jobs.py | 1 - examples/sklearnex/patch_sklearn.py | 1 - examples/sklearnex/verbose_mode.py | 1 - 7 files changed, 11 deletions(-) diff --git a/examples/daal4py/decision_forest_classification_traverse.py b/examples/daal4py/decision_forest_classification_traverse.py index 2e2ddcb853..a3b1ed5d21 100755 --- a/examples/daal4py/decision_forest_classification_traverse.py +++ b/examples/daal4py/decision_forest_classification_traverse.py @@ -22,8 +22,6 @@ import daal4py as d4p -import daal4py as d4p - def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/decision_forest_regression_traverse.py b/examples/daal4py/decision_forest_regression_traverse.py index cefa46017d..7217c546cd 100755 --- a/examples/daal4py/decision_forest_regression_traverse.py +++ b/examples/daal4py/decision_forest_regression_traverse.py @@ -22,8 +22,6 @@ import daal4py as d4p -import daal4py as d4p - def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/gradient_boosted_classification_traverse.py b/examples/daal4py/gradient_boosted_classification_traverse.py index 214552dbfa..0ff20553ba 100644 --- a/examples/daal4py/gradient_boosted_classification_traverse.py +++ b/examples/daal4py/gradient_boosted_classification_traverse.py @@ -22,8 +22,6 @@ import daal4py as d4p -import daal4py as d4p - def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/gradient_boosted_regression_traverse.py b/examples/daal4py/gradient_boosted_regression_traverse.py index 7811db70d0..b0316eb14d 100644 --- a/examples/daal4py/gradient_boosted_regression_traverse.py +++ b/examples/daal4py/gradient_boosted_regression_traverse.py @@ -22,8 +22,6 @@ import daal4py as d4p -import daal4py as d4p - def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/sklearnex/n_jobs.py b/examples/sklearnex/n_jobs.py index 4c27a79db3..13a5c05777 100644 --- a/examples/sklearnex/n_jobs.py +++ b/examples/sklearnex/n_jobs.py @@ -18,7 +18,6 @@ # scikit-learn n_jobs yet. Thus it's requered to use daal4py package to set this. # nthreads parameter define number of threads used by sklearnex. # Without this code sklearnex would be using all system cores - import daal4py daal4py.daalinit(nthreads=2) diff --git a/examples/sklearnex/patch_sklearn.py b/examples/sklearnex/patch_sklearn.py index 268e606218..3a87702cbf 100644 --- a/examples/sklearnex/patch_sklearn.py +++ b/examples/sklearnex/patch_sklearn.py @@ -16,7 +16,6 @@ # Calling scikit-learn patch - this would enable acceleration on all # enabled algorithms. This is most straight forward way of patching - from sklearnex import patch_sklearn patch_sklearn() diff --git a/examples/sklearnex/verbose_mode.py b/examples/sklearnex/verbose_mode.py index c130660f29..2cd610fc55 100644 --- a/examples/sklearnex/verbose_mode.py +++ b/examples/sklearnex/verbose_mode.py @@ -17,7 +17,6 @@ # sklearnex can help you debug your aplications by printing messages on it's invocation # to allow you to see if stock of accelerated version was used. # By setting sklearnex logger level to "INFO" you would enable this verbose mode - import logging logging.getLogger("sklearnex").setLevel(logging.INFO) From 1980c399dc6403a114c0d8f0a0c8fb5fe410a12b Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Wed, 2 Aug 2023 01:30:13 -0700 Subject: [PATCH 16/18] undo some unnessesary changes --- examples/daal4py/decision_tree_classification_traverse.py | 2 -- examples/daal4py/decision_tree_regression_traverse.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/examples/daal4py/decision_tree_classification_traverse.py b/examples/daal4py/decision_tree_classification_traverse.py index b50f4043de..d88db2fdf2 100644 --- a/examples/daal4py/decision_tree_classification_traverse.py +++ b/examples/daal4py/decision_tree_classification_traverse.py @@ -22,8 +22,6 @@ import daal4py as d4p -import daal4py as d4p - def printTree(nodes, values): def printNodes(node_id, nodes, values, level): diff --git a/examples/daal4py/decision_tree_regression_traverse.py b/examples/daal4py/decision_tree_regression_traverse.py index 35e94091a5..e5f4a31c19 100644 --- a/examples/daal4py/decision_tree_regression_traverse.py +++ b/examples/daal4py/decision_tree_regression_traverse.py @@ -22,8 +22,6 @@ import daal4py as d4p -import daal4py as d4p - def printTree(nodes, values): def printNodes(node_id, nodes, values, level): From f580a5921c6daedd1cbe59226fc63c71c6d32b32 Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Fri, 25 Aug 2023 05:20:06 -0700 Subject: [PATCH 17/18] remove the suffix from sycl example --- .../{bf_knn_classification_batch.py => bf_knn_classification.py} | 0 examples/daal4py/sycl/{covariance_batch.py => covariance.py} | 0 examples/daal4py/sycl/{dbscan_batch.py => dbscan.py} | 0 ..._classification_batch.py => decision_forest_classification.py} | 0 ...ation_hist_batch.py => decision_forest_classification_hist.py} | 0 ...n_forest_regression_batch.py => decision_forest_regression.py} | 0 ...egression_hist_batch.py => decision_forest_regression_hist.py} | 0 ...boosted_regression_batch.py => gradient_boosted_regression.py} | 0 examples/daal4py/sycl/{kmeans_batch.py => kmeans.py} | 0 .../sycl/{linear_regression_batch.py => linear_regression.py} | 0 .../{log_reg_binary_dense_batch.py => log_reg_binary_dense.py} | 0 .../daal4py/sycl/{log_reg_dense_batch.py => log_reg_dense.py} | 0 .../{low_order_moms_dense_batch.py => low_order_moms_dense.py} | 0 examples/daal4py/sycl/{pca_batch.py => pca.py} | 0 .../daal4py/sycl/{pca_transform_batch.py => pca_transform.py} | 0 examples/daal4py/sycl/{svm_batch.py => svm.py} | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename examples/daal4py/sycl/{bf_knn_classification_batch.py => bf_knn_classification.py} (100%) rename examples/daal4py/sycl/{covariance_batch.py => covariance.py} (100%) rename examples/daal4py/sycl/{dbscan_batch.py => dbscan.py} (100%) rename examples/daal4py/sycl/{decision_forest_classification_batch.py => decision_forest_classification.py} (100%) rename examples/daal4py/sycl/{decision_forest_classification_hist_batch.py => decision_forest_classification_hist.py} (100%) rename examples/daal4py/sycl/{decision_forest_regression_batch.py => decision_forest_regression.py} (100%) rename examples/daal4py/sycl/{decision_forest_regression_hist_batch.py => decision_forest_regression_hist.py} (100%) rename examples/daal4py/sycl/{gradient_boosted_regression_batch.py => gradient_boosted_regression.py} (100%) rename examples/daal4py/sycl/{kmeans_batch.py => kmeans.py} (100%) rename examples/daal4py/sycl/{linear_regression_batch.py => linear_regression.py} (100%) rename examples/daal4py/sycl/{log_reg_binary_dense_batch.py => log_reg_binary_dense.py} (100%) rename examples/daal4py/sycl/{log_reg_dense_batch.py => log_reg_dense.py} (100%) rename examples/daal4py/sycl/{low_order_moms_dense_batch.py => low_order_moms_dense.py} (100%) rename examples/daal4py/sycl/{pca_batch.py => pca.py} (100%) rename examples/daal4py/sycl/{pca_transform_batch.py => pca_transform.py} (100%) rename examples/daal4py/sycl/{svm_batch.py => svm.py} (100%) diff --git a/examples/daal4py/sycl/bf_knn_classification_batch.py b/examples/daal4py/sycl/bf_knn_classification.py similarity index 100% rename from examples/daal4py/sycl/bf_knn_classification_batch.py rename to examples/daal4py/sycl/bf_knn_classification.py diff --git a/examples/daal4py/sycl/covariance_batch.py b/examples/daal4py/sycl/covariance.py similarity index 100% rename from examples/daal4py/sycl/covariance_batch.py rename to examples/daal4py/sycl/covariance.py diff --git a/examples/daal4py/sycl/dbscan_batch.py b/examples/daal4py/sycl/dbscan.py similarity index 100% rename from examples/daal4py/sycl/dbscan_batch.py rename to examples/daal4py/sycl/dbscan.py diff --git a/examples/daal4py/sycl/decision_forest_classification_batch.py b/examples/daal4py/sycl/decision_forest_classification.py similarity index 100% rename from examples/daal4py/sycl/decision_forest_classification_batch.py rename to examples/daal4py/sycl/decision_forest_classification.py diff --git a/examples/daal4py/sycl/decision_forest_classification_hist_batch.py b/examples/daal4py/sycl/decision_forest_classification_hist.py similarity index 100% rename from examples/daal4py/sycl/decision_forest_classification_hist_batch.py rename to examples/daal4py/sycl/decision_forest_classification_hist.py diff --git a/examples/daal4py/sycl/decision_forest_regression_batch.py b/examples/daal4py/sycl/decision_forest_regression.py similarity index 100% rename from examples/daal4py/sycl/decision_forest_regression_batch.py rename to examples/daal4py/sycl/decision_forest_regression.py diff --git a/examples/daal4py/sycl/decision_forest_regression_hist_batch.py b/examples/daal4py/sycl/decision_forest_regression_hist.py similarity index 100% rename from examples/daal4py/sycl/decision_forest_regression_hist_batch.py rename to examples/daal4py/sycl/decision_forest_regression_hist.py diff --git a/examples/daal4py/sycl/gradient_boosted_regression_batch.py b/examples/daal4py/sycl/gradient_boosted_regression.py similarity index 100% rename from examples/daal4py/sycl/gradient_boosted_regression_batch.py rename to examples/daal4py/sycl/gradient_boosted_regression.py diff --git a/examples/daal4py/sycl/kmeans_batch.py b/examples/daal4py/sycl/kmeans.py similarity index 100% rename from examples/daal4py/sycl/kmeans_batch.py rename to examples/daal4py/sycl/kmeans.py diff --git a/examples/daal4py/sycl/linear_regression_batch.py b/examples/daal4py/sycl/linear_regression.py similarity index 100% rename from examples/daal4py/sycl/linear_regression_batch.py rename to examples/daal4py/sycl/linear_regression.py diff --git a/examples/daal4py/sycl/log_reg_binary_dense_batch.py b/examples/daal4py/sycl/log_reg_binary_dense.py similarity index 100% rename from examples/daal4py/sycl/log_reg_binary_dense_batch.py rename to examples/daal4py/sycl/log_reg_binary_dense.py diff --git a/examples/daal4py/sycl/log_reg_dense_batch.py b/examples/daal4py/sycl/log_reg_dense.py similarity index 100% rename from examples/daal4py/sycl/log_reg_dense_batch.py rename to examples/daal4py/sycl/log_reg_dense.py diff --git a/examples/daal4py/sycl/low_order_moms_dense_batch.py b/examples/daal4py/sycl/low_order_moms_dense.py similarity index 100% rename from examples/daal4py/sycl/low_order_moms_dense_batch.py rename to examples/daal4py/sycl/low_order_moms_dense.py diff --git a/examples/daal4py/sycl/pca_batch.py b/examples/daal4py/sycl/pca.py similarity index 100% rename from examples/daal4py/sycl/pca_batch.py rename to examples/daal4py/sycl/pca.py diff --git a/examples/daal4py/sycl/pca_transform_batch.py b/examples/daal4py/sycl/pca_transform.py similarity index 100% rename from examples/daal4py/sycl/pca_transform_batch.py rename to examples/daal4py/sycl/pca_transform.py diff --git a/examples/daal4py/sycl/svm_batch.py b/examples/daal4py/sycl/svm.py similarity index 100% rename from examples/daal4py/sycl/svm_batch.py rename to examples/daal4py/sycl/svm.py From 1270c97a327fb2743adb92892d70a8126582fced Mon Sep 17 00:00:00 2001 From: Dmitry Razdoburdin <> Date: Wed, 30 Aug 2023 03:01:20 -0700 Subject: [PATCH 18/18] rename spmd_utils.py --- examples/daal4py/covariance_spmd.py | 4 ++-- examples/daal4py/low_order_moms_spmd.py | 4 ++-- examples/daal4py/{spmd_utils.py => spmd_chunks_read.py} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename examples/daal4py/{spmd_utils.py => spmd_chunks_read.py} (100%) diff --git a/examples/daal4py/covariance_spmd.py b/examples/daal4py/covariance_spmd.py index fbf9c59b5e..a714a3d5ce 100644 --- a/examples/daal4py/covariance_spmd.py +++ b/examples/daal4py/covariance_spmd.py @@ -18,8 +18,8 @@ # run like this: # mpirun -n 4 python ./covariance_spmd.py -# let's use a reading of file in chunks (defined in spmd_utils.py) -from spmd_utils import get_chunk_params, read_csv +# let's use a reading of file in chunks (defined in spmd_chunks_read.py) +from spmd_chunks_read import get_chunk_params, read_csv import daal4py as d4p diff --git a/examples/daal4py/low_order_moms_spmd.py b/examples/daal4py/low_order_moms_spmd.py index 0275a7df4a..37edda7614 100644 --- a/examples/daal4py/low_order_moms_spmd.py +++ b/examples/daal4py/low_order_moms_spmd.py @@ -18,8 +18,8 @@ # run like this: # mpirun -n 4 python ./low_order_moms_spmd.py -# let's use a reading of file in chunks (defined in spmd_utils.py) -from spmd_utils import get_chunk_params, read_csv +# let's use a reading of file in chunks (defined in spmd_chunks_read.py) +from spmd_chunks_read import get_chunk_params, read_csv import daal4py as d4p diff --git a/examples/daal4py/spmd_utils.py b/examples/daal4py/spmd_chunks_read.py similarity index 100% rename from examples/daal4py/spmd_utils.py rename to examples/daal4py/spmd_chunks_read.py