You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by iv...@apache.org on 2023/09/11 09:10:23 UTC
[ignite] branch master updated: IGNITE-20216 Moving ignite-ml to extensions (#10897)
This is an automated email from the ASF dual-hosted git repository.
ivandasch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 9a216817df1 IGNITE-20216 Moving ignite-ml to extensions (#10897)
9a216817df1 is described below
commit 9a216817df1f9058c30dc90f3c62e16865b7032a
Author: Ivan Daschinskiy <iv...@apache.org>
AuthorDate: Mon Sep 11 12:10:15 2023 +0300
IGNITE-20216 Moving ignite-ml to extensions (#10897)
---
.gitignore | 3 -
README.md | 4 +-
assembly/dependencies-apache-ignite-slim.xml | 5 -
examples/config/example-ignite-ml.xml | 38 -
examples/pom-standalone-lgpl.xml | 30 -
examples/pom-standalone.xml | 30 -
examples/pom.xml | 35 -
.../ml/TrainingWithBinaryObjectExample.java | 93 -
.../clustering/CustomersClusterizationExample.java | 146 -
.../ml/clustering/GmmClusterizationExample.java | 119 -
.../ml/clustering/KMeansClusterizationExample.java | 109 -
.../examples/ml/clustering/package-info.java | 21 -
.../dataset/AlgorithmSpecificDatasetExample.java | 248 -
.../ml/dataset/CacheBasedDatasetExample.java | 97 -
.../ignite/examples/ml/dataset/model/Person.java | 72 -
.../examples/ml/dataset/model/package-info.java | 22 -
.../ignite/examples/ml/dataset/package-info.java | 22 -
.../TrainingWithCustomPreprocessorsExample.java | 160 -
.../examples/ml/environment/package-info.java | 21 -
.../IgniteModelDistributedInferenceExample.java | 112 -
.../examples/ml/inference/ModelStorageExample.java | 127 -
.../CatboostClassificationModelParserExample.java | 114 -
.../CatboostRegressionModelParserExample.java | 125 -
.../ml/inference/catboost/package-info.java | 22 -
.../ANNClassificationExportImportExample.java | 340 -
.../CompoundNaiveBayesExportImportExample.java | 129 -
...isionTreeClassificationExportImportExample.java | 152 -
.../DecisionTreeRegressionExportImportExample.java | 126 -
.../DiscreteNaiveBayesExportImportExample.java | 117 -
...DBOnTreesClassificationExportImportExample.java | 148 -
.../GDBOnTreesRegressionExportImportExample.java | 146 -
.../GaussianNaiveBayesExportImportExample.java | 117 -
.../KMeansClusterizationExportImportExample.java | 100 -
.../LinearRegressionExportImportExample.java | 116 -
.../LogisticRegressionExportImportExample.java | 122 -
...domForestClassificationExportImportExample.java | 145 -
.../RandomForestRegressionExportImportExample.java | 152 -
.../inference/exchange/SVMExportImportExample.java | 113 -
.../inference/h2o/H2OMojoModelParserExample.java | 103 -
.../examples/ml/inference/h2o/package-info.java | 22 -
.../ignite/examples/ml/inference/package-info.java | 21 -
.../spark/LogRegFromSparkThroughPMMLExample.java | 121 -
.../modelparser/DecisionTreeFromSparkExample.java | 98 -
.../DecisionTreeRegressionFromSparkExample.java | 105 -
.../spark/modelparser/GBTFromSparkExample.java | 96 -
.../modelparser/GBTRegressionFromSparkExample.java | 105 -
.../spark/modelparser/KMeansFromSparkExample.java | 102 -
.../LinearRegressionFromSparkExample.java | 104 -
.../spark/modelparser/LogRegFromSparkExample.java | 96 -
.../modelparser/RandomForestFromSparkExample.java | 96 -
.../RandomForestRegressionFromSparkExample.java | 105 -
.../spark/modelparser/SVMFromSparkExample.java | 94 -
.../inference/spark/modelparser/package-info.java | 21 -
.../examples/ml/inference/spark/package-info.java | 21 -
.../xgboost/XGBoostModelParserExample.java | 113 -
.../ml/inference/xgboost/package-info.java | 22 -
.../examples/ml/knn/ANNClassificationExample.java | 324 -
.../examples/ml/knn/IrisClassificationExample.java | 98 -
.../examples/ml/knn/KNNClassificationExample.java | 93 -
.../examples/ml/knn/KNNRegressionExample.java | 95 -
.../ignite/examples/ml/knn/package-info.java | 21 -
.../multiclass/OneVsRestClassificationExample.java | 178 -
.../examples/ml/multiclass/package-info.java | 21 -
.../ml/naivebayes/CompoundNaiveBayesExample.java | 98 -
.../DiscreteNaiveBayesTrainerExample.java | 96 -
.../GaussianNaiveBayesTrainerExample.java | 95 -
.../examples/ml/naivebayes/package-info.java | 22 -
.../ignite/examples/ml/nn/MLPTrainerExample.java | 139 -
.../apache/ignite/examples/ml/nn/package-info.java | 21 -
.../apache/ignite/examples/ml/package-info.java | 22 -
.../ml/preprocessing/BinarizationExample.java | 101 -
.../examples/ml/preprocessing/ImputingExample.java | 104 -
.../ml/preprocessing/MaxAbsScalerExample.java | 96 -
.../ml/preprocessing/MinMaxScalerExample.java | 105 -
.../ml/preprocessing/NormalizationExample.java | 102 -
.../ml/preprocessing/StandardScalerExample.java | 97 -
.../ml/preprocessing/encoding/EncoderExample.java | 105 -
.../encoding/EncoderExampleWithNormalization.java | 112 -
.../encoding/LabelEncoderExample.java | 111 -
.../encoding/TargetEncoderExample.java | 138 -
.../ml/preprocessing/encoding/package-info.java | 22 -
.../examples/ml/preprocessing/package-info.java | 22 -
.../ml/recommendation/MovieLensExample.java | 149 -
.../ml/recommendation/MovieLensSQLExample.java | 142 -
.../linear/BostonHousePricesPredictionExample.java | 123 -
.../linear/LinearRegressionLSQRTrainerExample.java | 98 -
...gressionLSQRTrainerWithMinMaxScalerExample.java | 108 -
.../linear/LinearRegressionSGDTrainerExample.java | 99 -
.../ml/regression/linear/package-info.java | 21 -
.../BaggedLogisticRegressionSGDTrainerExample.java | 117 -
.../regression/logistic/bagged/package-info.java | 21 -
.../LogisticRegressionSGDTrainerExample.java | 104 -
.../regression/logistic/binary/package-info.java | 21 -
.../ml/regression/logistic/package-info.java | 21 -
.../examples/ml/regression/package-info.java | 21 -
.../ml/selection/cv/CrossValidationExample.java | 127 -
.../examples/ml/selection/cv/package-info.java | 21 -
.../ignite/examples/ml/selection/package-info.java | 21 -
.../ml/selection/scoring/EvaluatorExample.java | 80 -
.../selection/scoring/RegressionMetricExample.java | 89 -
.../split/TrainTestDatasetSplitterExample.java | 111 -
.../examples/ml/selection/split/package-info.java | 21 -
...eeClassificationTrainerSQLInferenceExample.java | 142 -
...onTreeClassificationTrainerSQLTableExample.java | 230 -
.../ignite/examples/ml/sql/package-info.java | 21 -
.../ml/svm/SVMBinaryClassificationExample.java | 89 -
.../ignite/examples/ml/svm/package-info.java | 22 -
.../DecisionTreeClassificationTrainerExample.java | 127 -
.../tree/DecisionTreeRegressionTrainerExample.java | 112 -
.../examples/ml/tree/FraudDetectionExample.java | 114 -
.../GDBOnTreesClassificationTrainerExample.java | 123 -
.../GDBOnTreesRegressionTrainerExample.java | 120 -
.../examples/ml/tree/boosting/package-info.java | 21 -
.../ignite/examples/ml/tree/package-info.java | 21 -
.../RandomForestClassificationExample.java | 126 -
.../RandomForestRegressionExample.java | 136 -
.../ml/tree/randomforest/package-info.java | 21 -
.../examples/ml/tutorial/Step_10_Bagging.java | 147 -
.../examples/ml/tutorial/Step_11_Boosting.java | 139 -
.../examples/ml/tutorial/Step_12_Model_Update.java | 155 -
.../ml/tutorial/Step_1_Read_and_Learn.java | 87 -
.../examples/ml/tutorial/Step_2_Imputing.java | 97 -
.../examples/ml/tutorial/Step_3_Categorial.java | 111 -
.../Step_3_Categorial_with_One_Hot_Encoder.java | 115 -
.../examples/ml/tutorial/Step_4_Add_age_fare.java | 110 -
.../examples/ml/tutorial/Step_5_Scaling.java | 128 -
.../ml/tutorial/Step_5_Scaling_with_Pipeline.java | 100 -
.../ignite/examples/ml/tutorial/Step_6_KNN.java | 130 -
.../ml/tutorial/Step_7_Split_train_test.java | 136 -
.../ignite/examples/ml/tutorial/Step_8_CV.java | 199 -
.../ml/tutorial/Step_8_CV_with_Param_Grid.java | 188 -
.../Step_8_CV_with_Param_Grid_and_pipeline.java | 134 -
.../ml/tutorial/Step_9_Scaling_With_Stacking.java | 151 -
.../ignite/examples/ml/tutorial/TitanicUtils.java | 135 -
.../hyperparametertuning/Step_13_RandomSearch.java | 202 -
.../Step_14_Parallel_Brute_Force_Search.java | 204 -
.../Step_15_Parallel_Random_Search.java | 207 -
.../Step_16_Genetic_Programming_Search.java | 198 -
...tep_17_Parallel_Genetic_Programming_Search.java | 204 -
.../hyperparametertuning/package-info.java | 21 -
.../ignite/examples/ml/tutorial/package-info.java | 21 -
.../ignite/examples/ml/util/DatasetHelper.java | 65 -
.../examples/ml/util/MLExamplesCommonArgs.java | 33 -
.../ignite/examples/ml/util/MLSandboxDatasets.java | 115 -
.../ignite/examples/ml/util/SandboxMLCache.java | 248 -
.../ParametricVectorGeneratorExample.java | 65 -
.../util/generators/StandardGeneratorsExample.java | 76 -
.../generators/VectorGeneratorFamilyExample.java | 66 -
.../VectorGeneratorPrimitivesExample.java | 93 -
.../examples/ml/util/generators/package-info.java | 21 -
.../ignite/examples/ml/util/package-info.java | 22 -
examples/src/main/resources/datasets/README.md | 2 -
.../main/resources/datasets/agaricus-test-data.txt | 1611 -
.../datasets/agaricus-test-expected-results.txt | 1611 -
...-challenge-sample-catboost-expected-results.csv | 4 -
.../amazon-employee-access-challenge-sample.csv | 5 -
.../amazon-employee-access-challenge_train.csv | 100 -
...n_housing_dataset-catboost-expected-results.txt | 505 -
.../resources/datasets/boston_housing_dataset.txt | 505 -
.../main/resources/datasets/cleared_machines.csv | 209 -
.../english_vs_scottish_binary_dataset.csv | 14 -
.../main/resources/datasets/fraud_detection.csv | 3336 -
.../resources/datasets/glass_identification.csv | 116 -
examples/src/main/resources/datasets/iris.txt | 150 -
.../src/main/resources/datasets/mixed_dataset.csv | 8 -
.../src/main/resources/datasets/mortalitydata.csv | 53 -
examples/src/main/resources/datasets/mushrooms.csv | 8125 --
examples/src/main/resources/datasets/ratings.csv | 100837 ------------------
examples/src/main/resources/datasets/titanic.csv | 1310 -
.../main/resources/datasets/titanic_10_rows.csv | 11 -
.../src/main/resources/datasets/titanic_test.csv | 1 -
.../src/main/resources/datasets/titanic_train.csv | 1 -
.../resources/datasets/titanic_without_nulls.csv | 1309 -
.../main/resources/datasets/two_classed_iris.csv | 100 -
.../resources/datasets/wholesale_customers.csv | 441 -
examples/src/main/resources/datasets/wine.txt | 178 -
.../main/resources/models/catboost/model_clf.cbm | Bin 1089896 -> 0 bytes
.../main/resources/models/catboost/model_reg.cbm | Bin 1089824 -> 0 bytes
.../resources/models/h2o/agaricus-gbm-mojo.zip | Bin 62818 -> 0 bytes
examples/src/main/resources/models/spark/iris.pmml | 30 -
.../models/spark/serialized/dt/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-48b3-8356-9a26f9a6eb0f-c000.snappy.parquet.crc | Bin 44 -> 0 bytes
.../models/spark/serialized/dt/data/_SUCCESS | 0
...df49-48b3-8356-9a26f9a6eb0f-c000.snappy.parquet | Bin 4193 -> 0 bytes
.../spark/serialized/dt/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../spark/serialized/dt/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../models/spark/serialized/dt/metadata/_SUCCESS | 0
.../models/spark/serialized/dt/metadata/part-00000 | 1 -
.../spark/serialized/dtreg/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4bdd-8b1c-de87e11b3d1b-c000.snappy.parquet.crc | Bin 68 -> 0 bytes
.../models/spark/serialized/dtreg/data/_SUCCESS | 0
...698b-4bdd-8b1c-de87e11b3d1b-c000.snappy.parquet | Bin 7415 -> 0 bytes
.../spark/serialized/dtreg/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../serialized/dtreg/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../spark/serialized/dtreg/metadata/_SUCCESS | 0
.../spark/serialized/dtreg/metadata/part-00000 | 1 -
.../models/spark/serialized/gbt/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4b1f-9716-fbedf7caba2d-c000.snappy.parquet.crc | Bin 288 -> 0 bytes
.../models/spark/serialized/gbt/data/_SUCCESS | 0
...6344-4b1f-9716-fbedf7caba2d-c000.snappy.parquet | Bin 35369 -> 0 bytes
.../spark/serialized/gbt/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../spark/serialized/gbt/metadata/.part-00000.crc | Bin 16 -> 0 bytes
.../models/spark/serialized/gbt/metadata/_SUCCESS | 0
.../spark/serialized/gbt/metadata/part-00000 | 1 -
.../serialized/gbt/treesMetadata/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4d24-9900-be8a4396710b-c000.snappy.parquet.crc | Bin 36 -> 0 bytes
.../spark/serialized/gbt/treesMetadata/_SUCCESS | 0
...e1e6-4d24-9900-be8a4396710b-c000.snappy.parquet | Bin 3370 -> 0 bytes
.../spark/serialized/gbtreg/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4944-b933-7897869a29d3-c000.snappy.parquet.crc | Bin 688 -> 0 bytes
.../models/spark/serialized/gbtreg/data/_SUCCESS | 0
...888b-4944-b933-7897869a29d3-c000.snappy.parquet | Bin 86992 -> 0 bytes
.../spark/serialized/gbtreg/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../serialized/gbtreg/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../spark/serialized/gbtreg/metadata/_SUCCESS | 0
.../spark/serialized/gbtreg/metadata/part-00000 | 1 -
.../serialized/gbtreg/treesMetadata/._SUCCESS.crc | Bin 8 -> 0 bytes
...-48b3-bad7-07c343405928-c000.snappy.parquet.crc | Bin 80 -> 0 bytes
.../spark/serialized/gbtreg/treesMetadata/_SUCCESS | 0
...1326-48b3-bad7-07c343405928-c000.snappy.parquet | Bin 8925 -> 0 bytes
.../spark/serialized/kmeans/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4b9e-879e-de4afd4f65bc-c000.snappy.parquet.crc | Bin 24 -> 0 bytes
.../models/spark/serialized/kmeans/data/_SUCCESS | 0
...c65a-4b9e-879e-de4afd4f65bc-c000.snappy.parquet | Bin 1622 -> 0 bytes
.../spark/serialized/kmeans/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../serialized/kmeans/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../spark/serialized/kmeans/metadata/_SUCCESS | 0
.../spark/serialized/kmeans/metadata/part-00000 | 1 -
.../spark/serialized/linreg/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4ad3-bddd-7cad8378429d-c000.snappy.parquet.crc | Bin 24 -> 0 bytes
.../models/spark/serialized/linreg/data/_SUCCESS | 0
...6cdf-4ad3-bddd-7cad8378429d-c000.snappy.parquet | Bin 1570 -> 0 bytes
.../spark/serialized/linreg/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../serialized/linreg/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../spark/serialized/linreg/metadata/_SUCCESS | 0
.../spark/serialized/linreg/metadata/part-00000 | 1 -
.../spark/serialized/logreg/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4ed7-afe4-a464aabc7f80-c000.snappy.parquet.crc | Bin 40 -> 0 bytes
.../models/spark/serialized/logreg/data/_SUCCESS | 0
...c0a8-4ed7-afe4-a464aabc7f80-c000.snappy.parquet | Bin 3839 -> 0 bytes
.../spark/serialized/logreg/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../serialized/logreg/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../spark/serialized/logreg/metadata/_SUCCESS | 0
.../spark/serialized/logreg/metadata/part-00000 | 1 -
.../models/spark/serialized/rf/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-411c-8811-c3205434f5fc-c000.snappy.parquet.crc | Bin 1256 -> 0 bytes
.../models/spark/serialized/rf/data/_SUCCESS | 0
...bc1b-411c-8811-c3205434f5fc-c000.snappy.parquet | Bin 159358 -> 0 bytes
.../spark/serialized/rf/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../spark/serialized/rf/metadata/.part-00000.crc | Bin 16 -> 0 bytes
.../models/spark/serialized/rf/metadata/_SUCCESS | 0
.../models/spark/serialized/rf/metadata/part-00000 | 1 -
.../serialized/rf/treesMetadata/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4f5a-b7fc-043c9ab56e1d-c000.snappy.parquet.crc | Bin 148 -> 0 bytes
.../spark/serialized/rf/treesMetadata/_SUCCESS | 0
...3d4b-4f5a-b7fc-043c9ab56e1d-c000.snappy.parquet | Bin 17636 -> 0 bytes
.../spark/serialized/rfreg/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4a77-823e-dfd32d1560eb-c000.snappy.parquet.crc | Bin 968 -> 0 bytes
.../models/spark/serialized/rfreg/data/_SUCCESS | 0
...4b81-4a77-823e-dfd32d1560eb-c000.snappy.parquet | Bin 122852 -> 0 bytes
.../spark/serialized/rfreg/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../serialized/rfreg/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../spark/serialized/rfreg/metadata/_SUCCESS | 0
.../spark/serialized/rfreg/metadata/part-00000 | 1 -
.../serialized/rfreg/treesMetadata/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4554-b496-ef7584098d6d-c000.snappy.parquet.crc | Bin 56 -> 0 bytes
.../spark/serialized/rfreg/treesMetadata/_SUCCESS | 0
...0418-4554-b496-ef7584098d6d-c000.snappy.parquet | Bin 5838 -> 0 bytes
.../models/spark/serialized/svm/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4948-8e65-29c9f5c9c5b2-c000.snappy.parquet.crc | Bin 24 -> 0 bytes
.../models/spark/serialized/svm/data/_SUCCESS | 0
...a36c-4948-8e65-29c9f5c9c5b2-c000.snappy.parquet | Bin 1562 -> 0 bytes
.../spark/serialized/svm/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../spark/serialized/svm/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../models/spark/serialized/svm/metadata/_SUCCESS | 0
.../spark/serialized/svm/metadata/part-00000 | 1 -
.../resources/models/xgboost/agaricus-model.txt | 714 -
.../examples/MLTutorialExamplesSelfTest.java | 166 -
.../testsuites/IgniteExamplesMLTestSuite.java | 184 -
.../testsuites/IgniteExamplesSelfTestSuite.java | 5 -
modules/bom/pom.xml | 5 -
modules/dev-utils/ignite-modules-test/build.gradle | 1 -
modules/extdata/p2p/pom.xml | 5 -
.../ignite/tests/p2p/ml/CustomPreprocessor1.java | 41 -
.../ignite/tests/p2p/ml/CustomPreprocessor2.java | 41 -
.../ignite/tests/p2p/ml/CustomVectorizer.java | 50 -
modules/ml/README.txt | 17 -
modules/ml/catboost-model-parser/pom.xml | 95 -
.../ml/catboost/CatboostClassificationModel.java | 75 -
.../CatboostClassificationModelParser.java | 45 -
.../ml/catboost/CatboostRegressionModel.java | 73 -
.../ml/catboost/CatboostRegressionModelParser.java | 45 -
.../apache/ignite/ml/catboost/package-info.java | 23 -
.../ml/catboost/IgniteMLCatboostTestSuite.java | 33 -
.../CatboostClassificationModelParserTest.java | 74 -
.../parser/CatboostRegressionModelParserTest.java | 76 -
...ee-access-challenge-sample-expected-results.csv | 4 -
.../amazon-employee-access-challenge-sample.csv | 5 -
.../datasets/amazon-employee-access-challenge.csv | 1000 -
.../src/test/resources/fit_script/.gitignore | 2 -
.../src/test/resources/fit_script/README.md | 19 -
.../src/test/resources/fit_script/install.txt | 3 -
.../src/test/resources/fit_script/train_clf.py | 71 -
.../src/test/resources/fit_script/train_reg.py | 68 -
.../src/test/resources/models/model_clf.cbm | Bin 1089896 -> 0 bytes
.../src/test/resources/models/model_reg.cbm | Bin 1089824 -> 0 bytes
modules/ml/h2o-model-parser/pom.xml | 94 -
.../org/apache/ignite/ml/h2o/H2OMojoModel.java | 94 -
.../apache/ignite/ml/h2o/H2OMojoModelParser.java | 88 -
.../org/apache/ignite/ml/h2o/package-info.java | 23 -
.../apache/ignite/ml/h2o/H2OMojoParserTest.java | 68 -
.../org/apache/ignite/ml/h2o/H2OMojoTestSuite.java | 30 -
.../src/test/resources/mojos/gbm_prostate.zip | Bin 42484 -> 0 bytes
modules/ml/licenses/apache-2.0.txt | 202 -
modules/ml/licenses/bsd3.txt | 51 -
modules/ml/licenses/mit.txt | 7 -
modules/ml/licenses/netlib-java-bsd3.txt | 51 -
modules/ml/pom.xml | 189 -
modules/ml/spark-model-parser/README.txt | 55 -
modules/ml/spark-model-parser/pom.xml | 108 -
.../ml/sparkmodelparser/SparkModelParser.java | 864 -
.../ml/sparkmodelparser/SupportedSparkModels.java | 75 -
.../UnsupportedSparkModelException.java | 35 -
.../ignite/ml/sparkmodelparser/package-info.java | 23 -
.../IgniteMLSparkModelParserTestSuite.java | 30 -
.../ml/sparkmodelparser/SparkModelParserTest.java | 246 -
.../test/resources/models/gbt/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4b1f-9716-fbedf7caba2d-c000.snappy.parquet.crc | Bin 288 -> 0 bytes
.../src/test/resources/models/gbt/data/_SUCCESS | 0
...6344-4b1f-9716-fbedf7caba2d-c000.snappy.parquet | Bin 35369 -> 0 bytes
.../resources/models/gbt/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../resources/models/gbt/metadata/.part-00000.crc | Bin 16 -> 0 bytes
.../test/resources/models/gbt/metadata/_SUCCESS | 0
.../test/resources/models/gbt/metadata/part-00000 | 1 -
.../models/gbt/treesMetadata/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4d24-9900-be8a4396710b-c000.snappy.parquet.crc | Bin 36 -> 0 bytes
.../resources/models/gbt/treesMetadata/_SUCCESS | 0
...e1e6-4d24-9900-be8a4396710b-c000.snappy.parquet | Bin 3370 -> 0 bytes
.../resources/models/linreg/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4ad3-bddd-7cad8378429d-c000.snappy.parquet.crc | Bin 24 -> 0 bytes
.../src/test/resources/models/linreg/data/_SUCCESS | 0
...6cdf-4ad3-bddd-7cad8378429d-c000.snappy.parquet | Bin 1570 -> 0 bytes
.../resources/models/linreg/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../models/linreg/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../test/resources/models/linreg/metadata/_SUCCESS | 0
.../resources/models/linreg/metadata/part-00000 | 1 -
.../models/nodatafolder/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../models/nodatafolder/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../models/nodatafolder/metadata/_SUCCESS | 0
.../models/nodatafolder/metadata/part-00000 | 1 -
.../models/nometadatafilefolder/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4ad3-bddd-7cad8378429d-c000.snappy.parquet.crc | Bin 24 -> 0 bytes
.../models/nometadatafilefolder/data/_SUCCESS | 0
...6cdf-4ad3-bddd-7cad8378429d-c000.snappy.parquet | Bin 1570 -> 0 bytes
.../nometadatafilefolder/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../nometadatafilefolder/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../models/nometadatafilefolder/metadata/_SUCCESS | 0
.../models/nometadatafolder/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4ad3-bddd-7cad8378429d-c000.snappy.parquet.crc | Bin 24 -> 0 bytes
.../models/nometadatafolder/data/_SUCCESS | 0
...6cdf-4ad3-bddd-7cad8378429d-c000.snappy.parquet | Bin 1570 -> 0 bytes
.../models/nomodelfilefolder/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4ad3-bddd-7cad8378429d-c000.snappy.parquet.crc | Bin 24 -> 0 bytes
.../models/nomodelfilefolder/data/_SUCCESS | 0
.../nomodelfilefolder/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../nomodelfilefolder/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../models/nomodelfilefolder/metadata/_SUCCESS | 0
.../models/nomodelfilefolder/metadata/part-00000 | 1 -
.../models/notreesmetadatafile/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4b1f-9716-fbedf7caba2d-c000.snappy.parquet.crc | Bin 288 -> 0 bytes
.../models/notreesmetadatafile/data/_SUCCESS | 0
...6344-4b1f-9716-fbedf7caba2d-c000.snappy.parquet | Bin 35369 -> 0 bytes
.../notreesmetadatafile/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../notreesmetadatafile/metadata/.part-00000.crc | Bin 16 -> 0 bytes
.../models/notreesmetadatafile/metadata/_SUCCESS | 0
.../models/notreesmetadatafile/metadata/part-00000 | 1 -
.../treesMetadata/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4d24-9900-be8a4396710b-c000.snappy.parquet.crc | Bin 36 -> 0 bytes
.../notreesmetadatafile/treesMetadata/_SUCCESS | 0
.../notreesmetadatafolder/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4b1f-9716-fbedf7caba2d-c000.snappy.parquet.crc | Bin 288 -> 0 bytes
.../models/notreesmetadatafolder/data/_SUCCESS | 0
...6344-4b1f-9716-fbedf7caba2d-c000.snappy.parquet | Bin 35369 -> 0 bytes
.../notreesmetadatafolder/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../notreesmetadatafolder/metadata/.part-00000.crc | Bin 16 -> 0 bytes
.../models/notreesmetadatafolder/metadata/_SUCCESS | 0
.../notreesmetadatafolder/metadata/part-00000 | 1 -
.../models/twomodelfilefolder/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4ad3-bddd-7cad8378429d-c000.snappy.parquet.crc | Bin 24 -> 0 bytes
.../models/twomodelfilefolder/data/_SUCCESS | 0
...6cdf-4ad3-bddd-7cad8378429d-c000.snappy.parquet | Bin 1570 -> 0 bytes
...6cdf-4ad3-bddd-7cad8378429d-c001.snappy.parquet | Bin 1570 -> 0 bytes
.../twomodelfilefolder/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../twomodelfilefolder/metadata/.part-00000.crc | Bin 12 -> 0 bytes
.../models/twomodelfilefolder/metadata/_SUCCESS | 0
.../models/twomodelfilefolder/metadata/part-00000 | 1 -
.../twotreesmetadatafiles/data/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4b1f-9716-fbedf7caba2d-c000.snappy.parquet.crc | Bin 288 -> 0 bytes
.../models/twotreesmetadatafiles/data/_SUCCESS | 0
...6344-4b1f-9716-fbedf7caba2d-c000.snappy.parquet | Bin 35369 -> 0 bytes
.../twotreesmetadatafiles/metadata/._SUCCESS.crc | Bin 8 -> 0 bytes
.../twotreesmetadatafiles/metadata/.part-00000.crc | Bin 16 -> 0 bytes
.../models/twotreesmetadatafiles/metadata/_SUCCESS | 0
.../twotreesmetadatafiles/metadata/part-00000 | 1 -
.../treesMetadata/._SUCCESS.crc | Bin 8 -> 0 bytes
...-4d24-9900-be8a4396710b-c000.snappy.parquet.crc | Bin 36 -> 0 bytes
.../twotreesmetadatafiles/treesMetadata/_SUCCESS | 0
...e1e6-4d24-9900-be8a4396710b-c000.snappy.parquet | Bin 3370 -> 0 bytes
...e1e6-4d24-9900-be8a4396710b-c001.snappy.parquet | Bin 3370 -> 0 bytes
.../main/java/org/apache/ignite/ml/Exportable.java | 33 -
.../main/java/org/apache/ignite/ml/Exporter.java | 38 -
.../java/org/apache/ignite/ml/FileExporter.java | 75 -
.../java/org/apache/ignite/ml/IgniteModel.java | 117 -
.../gmm/CovarianceMatricesAggregator.java | 195 -
.../apache/ignite/ml/clustering/gmm/GmmModel.java | 65 -
.../ignite/ml/clustering/gmm/GmmPartitionData.java | 224 -
.../ignite/ml/clustering/gmm/GmmTrainer.java | 547 -
.../gmm/MeanWithClusterProbAggregator.java | 208 -
.../gmm/NewComponentStatisticsAggregator.java | 169 -
.../ignite/ml/clustering/gmm/package-info.java | 22 -
.../ignite/ml/clustering/kmeans/Clusterer.java | 33 -
.../ml/clustering/kmeans/ClusterizationModel.java | 29 -
.../ignite/ml/clustering/kmeans/KMeansModel.java | 254 -
.../ml/clustering/kmeans/KMeansModelFormat.java | 79 -
.../ignite/ml/clustering/kmeans/KMeansTrainer.java | 386 -
.../ignite/ml/clustering/kmeans/package-info.java | 22 -
.../apache/ignite/ml/clustering/package-info.java | 23 -
.../ignite/ml/composition/CompositionUtils.java | 115 -
.../ignite/ml/composition/DatasetMapping.java | 68 -
.../ml/composition/ModelOnFeaturesSubspace.java | 95 -
.../ignite/ml/composition/ModelsComposition.java | 115 -
.../ml/composition/ModelsCompositionFormat.java | 61 -
.../ignite/ml/composition/bagging/BaggedModel.java | 65 -
.../ml/composition/bagging/BaggedTrainer.java | 198 -
.../ml/composition/bagging/package-info.java | 22 -
.../boosting/GDBBinaryClassifierTrainer.java | 116 -
.../composition/boosting/GDBLearningStrategy.java | 278 -
.../ignite/ml/composition/boosting/GDBModel.java | 123 -
.../composition/boosting/GDBRegressionTrainer.java | 61 -
.../ignite/ml/composition/boosting/GDBTrainer.java | 240 -
.../boosting/convergence/ConvergenceChecker.java | 145 -
.../convergence/ConvergenceCheckerFactory.java | 55 -
.../mean/MeanAbsValueConvergenceChecker.java | 114 -
.../MeanAbsValueConvergenceCheckerFactory.java | 46 -
.../boosting/convergence/mean/package-info.java | 22 -
.../median/MedianOfMedianConvergenceChecker.java | 124 -
.../MedianOfMedianConvergenceCheckerFactory.java | 46 -
.../boosting/convergence/median/package-info.java | 22 -
.../boosting/convergence/package-info.java | 24 -
.../convergence/simple/ConvergenceCheckerStub.java | 77 -
.../simple/ConvergenceCheckerStubFactory.java | 45 -
.../boosting/convergence/simple/package-info.java | 24 -
.../ml/composition/boosting/loss/LogLoss.java | 36 -
.../ignite/ml/composition/boosting/loss/Loss.java | 45 -
.../ml/composition/boosting/loss/SquaredError.java | 36 -
.../ml/composition/boosting/loss/package-info.java | 22 -
.../ml/composition/boosting/package-info.java | 23 -
.../ml/composition/combinators/package-info.java | 22 -
.../parallel/ModelsParallelComposition.java | 67 -
.../parallel/TrainersParallelComposition.java | 143 -
.../combinators/parallel/package-info.java | 22 -
.../sequential/ModelsSequentialComposition.java | 100 -
.../sequential/TrainersSequentialComposition.java | 245 -
.../combinators/sequential/package-info.java | 22 -
.../apache/ignite/ml/composition/package-info.java | 22 -
.../MeanValuePredictionsAggregator.java | 32 -
.../OnMajorityPredictionsAggregator.java | 44 -
.../PredictionsAggregator.java | 42 -
.../WeightedPredictionsAggregator.java | 104 -
.../predictionsaggregator/package-info.java | 23 -
.../stacking/SimpleStackedDatasetTrainer.java | 124 -
.../stacking/StackedDatasetTrainer.java | 376 -
.../ml/composition/stacking/StackedModel.java | 62 -
.../stacking/StackedVectorDatasetTrainer.java | 152 -
.../ml/composition/stacking/package-info.java | 22 -
.../java/org/apache/ignite/ml/dataset/Dataset.java | 216 -
.../apache/ignite/ml/dataset/DatasetBuilder.java | 80 -
.../apache/ignite/ml/dataset/DatasetFactory.java | 573 -
.../ignite/ml/dataset/PartitionContextBuilder.java | 81 -
.../ignite/ml/dataset/PartitionDataBuilder.java | 88 -
.../apache/ignite/ml/dataset/UpstreamEntry.java | 53 -
.../ignite/ml/dataset/UpstreamTransformer.java | 36 -
.../ml/dataset/UpstreamTransformerBuilder.java | 70 -
.../ignite/ml/dataset/feature/BucketMeta.java | 91 -
.../ml/dataset/feature/DistributionComputer.java | 32 -
.../ignite/ml/dataset/feature/FeatureMeta.java | 65 -
.../ignite/ml/dataset/feature/Histogram.java | 64 -
.../ignite/ml/dataset/feature/ObjectHistogram.java | 131 -
.../dataset/feature/extractor/ExtractionUtils.java | 218 -
.../ml/dataset/feature/extractor/Vectorizer.java | 265 -
.../extractor/impl/BinaryObjectVectorizer.java | 150 -
.../extractor/impl/DoubleArrayVectorizer.java | 58 -
.../feature/extractor/impl/DummyVectorizer.java | 59 -
.../extractor/impl/LabeledDummyVectorizer.java | 71 -
.../extractor/impl/ObjectArrayVectorizer.java | 59 -
.../feature/extractor/impl/package-info.java | 23 -
.../ml/dataset/feature/extractor/package-info.java | 24 -
.../ignite/ml/dataset/feature/package-info.java | 24 -
.../bootstrapping/BootstrappedDatasetBuilder.java | 96 -
.../BootstrappedDatasetPartition.java | 68 -
.../impl/bootstrapping/BootstrappedVector.java | 87 -
.../dataset/impl/bootstrapping/package-info.java | 23 -
.../ml/dataset/impl/cache/CacheBasedDataset.java | 227 -
.../impl/cache/CacheBasedDatasetBuilder.java | 220 -
.../ignite/ml/dataset/impl/cache/package-info.java | 23 -
.../ml/dataset/impl/cache/util/ComputeUtils.java | 452 -
.../cache/util/DatasetAffinityFunctionWrapper.java | 75 -
.../IteratorWithConcurrentModificationChecker.java | 80 -
.../impl/cache/util/PartitionDataStorage.java | 65 -
.../ml/dataset/impl/cache/util/package-info.java | 23 -
.../ignite/ml/dataset/impl/local/LocalDataset.java | 104 -
.../ml/dataset/impl/local/LocalDatasetBuilder.java | 224 -
.../ignite/ml/dataset/impl/local/package-info.java | 23 -
.../ignite/ml/dataset/impl/package-info.java | 23 -
.../org/apache/ignite/ml/dataset/package-info.java | 23 -
.../ml/dataset/primitive/DatasetWrapper.java | 64 -
.../FeatureMatrixWithLabelsOnHeapData.java | 57 -
.../FeatureMatrixWithLabelsOnHeapDataBuilder.java | 76 -
.../ignite/ml/dataset/primitive/SimpleDataset.java | 216 -
.../ml/dataset/primitive/SimpleLabeledDataset.java | 39 -
.../builder/context/EmptyContextBuilder.java | 40 -
.../primitive/builder/context/package-info.java | 23 -
.../builder/data/SimpleDatasetDataBuilder.java | 86 -
.../data/SimpleLabeledDatasetDataBuilder.java | 100 -
.../primitive/builder/data/package-info.java | 23 -
.../ml/dataset/primitive/builder/package-info.java | 23 -
.../ml/dataset/primitive/context/EmptyContext.java | 28 -
.../ml/dataset/primitive/context/package-info.java | 23 -
.../dataset/primitive/data/SimpleDatasetData.java | 59 -
.../primitive/data/SimpleLabeledDatasetData.java | 69 -
.../ml/dataset/primitive/data/package-info.java | 23 -
.../ignite/ml/dataset/primitive/package-info.java | 29 -
.../DefaultLearningEnvironmentBuilder.java | 212 -
.../ignite/ml/environment/LearningEnvironment.java | 88 -
.../ml/environment/LearningEnvironmentBuilder.java | 157 -
.../ml/environment/deploy/DeployableObject.java | 33 -
.../ml/environment/deploy/DeployingContext.java | 55 -
.../environment/deploy/DeployingContextImpl.java | 77 -
.../ignite/ml/environment/deploy/package-info.java | 21 -
.../ml/environment/logging/ConsoleLogger.java | 113 -
.../ml/environment/logging/CustomMLLogger.java | 105 -
.../ignite/ml/environment/logging/MLLogger.java | 76 -
.../ignite/ml/environment/logging/NoOpLogger.java | 64 -
.../ml/environment/logging/package-info.java | 21 -
.../apache/ignite/ml/environment/package-info.java | 21 -
.../parallelism/DefaultParallelismStrategy.java | 92 -
.../parallelism/NoParallelismStrategy.java | 94 -
.../parallelism/ParallelismStrategy.java | 72 -
.../ignite/ml/environment/parallelism/Promise.java | 55 -
.../ml/environment/parallelism/package-info.java | 21 -
.../ml/inference/IgniteModelStorageUtil.java | 332 -
.../java/org/apache/ignite/ml/inference/Model.java | 37 -
.../ignite/ml/inference/ModelDescriptor.java | 94 -
.../apache/ignite/ml/inference/ModelSignature.java | 62 -
.../ml/inference/builder/AsyncModelBuilder.java | 43 -
.../builder/IgniteDistributedModelBuilder.java | 368 -
.../ml/inference/builder/SingleModelBuilder.java | 34 -
.../ml/inference/builder/SyncModelBuilder.java | 42 -
.../ml/inference/builder/ThreadedModelBuilder.java | 86 -
.../ignite/ml/inference/builder/package-info.java | 23 -
.../apache/ignite/ml/inference/json/JSONModel.java | 56 -
.../ignite/ml/inference/json/JSONModelMixIn.java | 31 -
.../ignite/ml/inference/json/JSONWritable.java | 40 -
.../ignite/ml/inference/json/JacksonHelper.java | 41 -
.../ignite/ml/inference/json/package-info.java | 22 -
.../apache/ignite/ml/inference/package-info.java | 23 -
.../ml/inference/parser/IgniteModelParser.java | 49 -
.../ignite/ml/inference/parser/ModelParser.java | 38 -
.../ignite/ml/inference/parser/package-info.java | 23 -
.../ml/inference/reader/FileSystemModelReader.java | 61 -
.../ml/inference/reader/InMemoryModelReader.java | 67 -
.../ignite/ml/inference/reader/ModelReader.java | 33 -
.../inference/reader/ModelStorageModelReader.java | 64 -
.../ignite/ml/inference/reader/package-info.java | 23 -
.../descriptor/IgniteModelDescriptorStorage.java | 71 -
.../descriptor/LocalModelDescriptorStorage.java | 57 -
.../storage/descriptor/ModelDescriptorStorage.java | 67 -
.../descriptor/ModelDescriptorStorageFactory.java | 46 -
.../inference/storage/descriptor/package-info.java | 23 -
.../storage/model/DefaultModelStorage.java | 331 -
.../ml/inference/storage/model/Directory.java | 42 -
.../ignite/ml/inference/storage/model/File.java | 48 -
.../inference/storage/model/FileOrDirectory.java | 41 -
.../storage/model/IgniteModelStorageProvider.java | 58 -
.../storage/model/LocalModelStorageProvider.java | 102 -
.../ml/inference/storage/model/ModelStorage.java | 115 -
.../storage/model/ModelStorageFactory.java | 46 -
.../storage/model/ModelStorageProvider.java | 56 -
.../ml/inference/storage/model/package-info.java | 23 -
.../ignite/ml/inference/storage/package-info.java | 23 -
.../ml/inference/util/DirectorySerializer.java | 133 -
.../ignite/ml/inference/util/package-info.java | 23 -
.../java/org/apache/ignite/ml/knn/KNNModel.java | 93 -
.../ignite/ml/knn/KNNPartitionDataBuilder.java | 91 -
.../java/org/apache/ignite/ml/knn/KNNTrainer.java | 141 -
.../ignite/ml/knn/NNClassificationModel.java | 250 -
.../ignite/ml/knn/ann/ANNClassificationModel.java | 331 -
.../ml/knn/ann/ANNClassificationTrainer.java | 370 -
.../apache/ignite/ml/knn/ann/ANNModelFormat.java | 87 -
.../apache/ignite/ml/knn/ann/KNNModelFormat.java | 93 -
.../apache/ignite/ml/knn/ann/ProbableLabel.java | 43 -
.../org/apache/ignite/ml/knn/ann/package-info.java | 22 -
.../knn/classification/KNNClassificationModel.java | 181 -
.../classification/KNNClassificationTrainer.java | 41 -
.../ignite/ml/knn/classification/package-info.java | 22 -
.../org/apache/ignite/ml/knn/package-info.java | 23 -
.../ml/knn/regression/KNNRegressionModel.java | 117 -
.../ml/knn/regression/KNNRegressionTrainer.java | 41 -
.../ignite/ml/knn/regression/package-info.java | 22 -
.../org/apache/ignite/ml/knn/utils/KNNUtils.java | 66 -
.../ignite/ml/knn/utils/PointWithDistance.java | 61 -
.../ignite/ml/knn/utils/PointWithDistanceUtil.java | 95 -
.../ml/knn/utils/indices/ArraySpatialIndex.java | 70 -
.../ml/knn/utils/indices/BallTreeSpatialIndex.java | 393 -
.../ml/knn/utils/indices/KDTreeSpatialIndex.java | 194 -
.../ignite/ml/knn/utils/indices/SpatialIndex.java | 43 -
.../ml/knn/utils/indices/SpatialIndexType.java | 32 -
.../apache/ignite/ml/knn/utils/package-info.java | 22 -
.../main/java/org/apache/ignite/ml/math/Blas.java | 335 -
.../org/apache/ignite/ml/math/Destroyable.java | 30 -
.../org/apache/ignite/ml/math/MetaAttributes.java | 76 -
.../apache/ignite/ml/math/StorageConstants.java | 52 -
.../apache/ignite/ml/math/StorageOpsMetrics.java | 39 -
.../java/org/apache/ignite/ml/math/Tracer.java | 686 -
.../ml/math/distances/BrayCurtisDistance.java | 59 -
.../ignite/ml/math/distances/CanberraDistance.java | 64 -
.../ml/math/distances/ChebyshevDistance.java | 31 -
.../ignite/ml/math/distances/CosineSimilarity.java | 31 -
.../ignite/ml/math/distances/DistanceMeasure.java | 83 -
.../ml/math/distances/EuclideanDistance.java | 57 -
.../ignite/ml/math/distances/HammingDistance.java | 52 -
.../ignite/ml/math/distances/JaccardIndex.java | 41 -
.../ml/math/distances/JensenShannonDistance.java | 95 -
.../ml/math/distances/ManhattanDistance.java | 48 -
.../ml/math/distances/MinkowskiDistance.java | 80 -
.../math/distances/WeightedMinkowskiDistance.java | 105 -
.../ignite/ml/math/distances/package-info.java | 23 -
.../exceptions/UnsupportedOperationException.java | 44 -
.../datastructures/EmptyFileException.java | 37 -
.../datastructures/FileParsingException.java | 39 -
.../datastructures/NoLabelVectorException.java | 37 -
.../exceptions/datastructures/package-info.java | 23 -
.../math/exceptions/math/CardinalityException.java | 36 -
.../math/exceptions/math/ColumnIndexException.java | 35 -
.../ml/math/exceptions/math/IndexException.java | 35 -
.../math/MathIllegalArgumentException.java | 36 -
.../math/exceptions/math/MathRuntimeException.java | 47 -
.../ml/math/exceptions/math/NoDataException.java | 45 -
.../exceptions/math/NonSquareMatrixException.java | 33 -
.../ml/math/exceptions/math/RowIndexException.java | 35 -
.../exceptions/math/SingularMatrixException.java | 33 -
.../ml/math/exceptions/math/package-info.java | 23 -
.../ignite/ml/math/exceptions/package-info.java | 23 -
.../preprocessing/IllegalFeatureTypeException.java | 38 -
.../preprocessing/IllegalLabelTypeException.java | 38 -
.../preprocessing/NonDoubleVectorException.java | 36 -
.../preprocessing/UndefinedLabelException.java | 36 -
.../UnknownCategorialValueException.java | 35 -
.../exceptions/preprocessing/package-info.java | 23 -
.../apache/ignite/ml/math/functions/Functions.java | 282 -
.../ignite/ml/math/functions/IgniteBiConsumer.java | 29 -
.../ignite/ml/math/functions/IgniteBiFunction.java | 35 -
.../ml/math/functions/IgniteBinaryOperator.java | 29 -
.../ignite/ml/math/functions/IgniteConsumer.java | 29 -
.../ml/math/functions/IgniteCurriedBiFunction.java | 28 -
.../math/functions/IgniteCurriedTriFunction.java | 26 -
...IgniteDifferentiableDoubleToDoubleFunction.java | 31 -
...IgniteDifferentiableVectorToDoubleFunction.java | 33 -
.../ml/math/functions/IgniteDoubleConsumer.java | 29 -
.../ml/math/functions/IgniteDoubleFunction.java | 29 -
.../ignite/ml/math/functions/IgniteFunction.java | 64 -
.../IgniteIntDoubleToDoubleBiFunction.java | 27 -
.../functions/IgniteIntIntToIntBiFunction.java | 27 -
.../ignite/ml/math/functions/IgniteSupplier.java | 30 -
.../ml/math/functions/IgniteToDoubleFunction.java | 30 -
.../ml/math/functions/IgniteTriConsumer.java | 40 -
.../ml/math/functions/IgniteTriFunction.java | 36 -
.../ml/math/functions/IntDoubleToVoidFunction.java | 25 -
.../math/functions/IntIntDoubleToVoidFunction.java | 32 -
.../ml/math/functions/IntIntToDoubleFunction.java | 24 -
.../ignite/ml/math/functions/package-info.java | 23 -
.../ml/math/isolve/IterativeSolverResult.java | 64 -
.../ignite/ml/math/isolve/lsqr/AbstractLSQR.java | 362 -
.../ignite/ml/math/isolve/lsqr/LSQROnHeap.java | 127 -
.../ml/math/isolve/lsqr/LSQRPartitionContext.java | 41 -
.../ignite/ml/math/isolve/lsqr/LSQRResult.java | 140 -
.../ignite/ml/math/isolve/lsqr/package-info.java | 23 -
.../apache/ignite/ml/math/isolve/package-info.java | 23 -
.../org/apache/ignite/ml/math/package-info.java | 22 -
.../ml/math/primitives/matrix/AbstractMatrix.java | 936 -
.../ml/math/primitives/matrix/LUDecomposition.java | 383 -
.../ignite/ml/math/primitives/matrix/Matrix.java | 541 -
.../ml/math/primitives/matrix/MatrixStorage.java | 80 -
.../ml/math/primitives/matrix/OrderedMatrix.java | 24 -
.../math/primitives/matrix/impl/DenseMatrix.java | 134 -
.../math/primitives/matrix/impl/SparseMatrix.java | 100 -
.../ml/math/primitives/matrix/impl/ViewMatrix.java | 85 -
.../math/primitives/matrix/impl/package-info.java | 22 -
.../ml/math/primitives/matrix/package-info.java | 22 -
.../matrix/storage/DenseMatrixStorage.java | 214 -
.../matrix/storage/SparseMatrixStorage.java | 249 -
.../matrix/storage/ViewMatrixStorage.java | 202 -
.../primitives/matrix/storage/package-info.java | 22 -
.../ignite/ml/math/primitives/package-info.java | 22 -
.../ml/math/primitives/vector/AbstractVector.java | 980 -
.../ml/math/primitives/vector/NamedVector.java | 50 -
.../ignite/ml/math/primitives/vector/Vector.java | 594 -
.../ml/math/primitives/vector/VectorStorage.java | 80 -
.../ml/math/primitives/vector/VectorUtils.java | 283 -
.../vector/impl/DelegatingNamedVector.java | 94 -
.../primitives/vector/impl/DelegatingVector.java | 418 -
.../math/primitives/vector/impl/DenseVector.java | 114 -
.../math/primitives/vector/impl/SparseVector.java | 115 -
.../ml/math/primitives/vector/impl/VectorView.java | 87 -
.../vector/impl/VectorizedViewMatrix.java | 147 -
.../math/primitives/vector/impl/package-info.java | 22 -
.../ml/math/primitives/vector/package-info.java | 22 -
.../vector/storage/DenseVectorStorage.java | 240 -
.../vector/storage/SparseVectorStorage.java | 174 -
.../vector/storage/VectorViewStorage.java | 169 -
.../storage/VectorizedViewMatrixStorage.java | 202 -
.../primitives/vector/storage/package-info.java | 22 -
.../apache/ignite/ml/math/stat/Distribution.java | 37 -
.../ignite/ml/math/stat/DistributionMixture.java | 107 -
.../stat/MultivariateGaussianDistribution.java | 89 -
.../apache/ignite/ml/math/stat/package-info.java | 21 -
.../org/apache/ignite/ml/math/util/MapUtil.java | 45 -
.../org/apache/ignite/ml/math/util/MatrixUtil.java | 325 -
.../apache/ignite/ml/math/util/package-info.java | 23 -
.../ignite/ml/multiclass/MultiClassModel.java | 115 -
.../ignite/ml/multiclass/OneVsRestTrainer.java | 141 -
.../apache/ignite/ml/multiclass/package-info.java | 22 -
.../apache/ignite/ml/naivebayes/BayesModel.java | 33 -
.../compound/CompoundNaiveBayesModel.java | 238 -
.../compound/CompoundNaiveBayesTrainer.java | 166 -
.../ml/naivebayes/compound/package-info.java | 22 -
.../discrete/DiscreteNaiveBayesModel.java | 208 -
.../discrete/DiscreteNaiveBayesSumsHolder.java | 70 -
.../discrete/DiscreteNaiveBayesTrainer.java | 230 -
.../ml/naivebayes/discrete/package-info.java | 23 -
.../gaussian/GaussianNaiveBayesModel.java | 190 -
.../gaussian/GaussianNaiveBayesSumsHolder.java | 77 -
.../gaussian/GaussianNaiveBayesTrainer.java | 185 -
.../ml/naivebayes/gaussian/package-info.java | 23 -
.../apache/ignite/ml/naivebayes/package-info.java | 23 -
.../java/org/apache/ignite/ml/nn/Activators.java | 81 -
.../java/org/apache/ignite/ml/nn/MLPLayer.java | 48 -
.../java/org/apache/ignite/ml/nn/MLPState.java | 73 -
.../java/org/apache/ignite/ml/nn/MLPTrainer.java | 387 -
.../apache/ignite/ml/nn/MultilayerPerceptron.java | 588 -
.../ignite/ml/nn/ReplicatedVectorMatrix.java | 553 -
.../org/apache/ignite/ml/nn/UpdatesStrategy.java | 95 -
.../ml/nn/architecture/LayerArchitecture.java | 48 -
.../ignite/ml/nn/architecture/MLPArchitecture.java | 152 -
.../TransformationLayerArchitecture.java | 68 -
.../ignite/ml/nn/architecture/package-info.java | 23 -
.../ignite/ml/nn/initializers/MLPInitializer.java | 40 -
.../ml/nn/initializers/RandomInitializer.java | 67 -
.../ignite/ml/nn/initializers/package-info.java | 23 -
.../java/org/apache/ignite/ml/nn/package-info.java | 23 -
.../ignite/ml/optimization/BaseParametrized.java | 58 -
.../ignite/ml/optimization/LossFunctions.java | 123 -
.../ignite/ml/optimization/Parametrized.java | 26 -
.../ignite/ml/optimization/SmoothParametrized.java | 45 -
.../ignite/ml/optimization/package-info.java | 23 -
.../updatecalculators/NesterovParameterUpdate.java | 104 -
.../NesterovUpdateCalculator.java | 87 -
.../ParameterUpdateCalculator.java | 60 -
.../updatecalculators/RPropParameterUpdate.java | 242 -
.../updatecalculators/RPropUpdateCalculator.java | 155 -
.../updatecalculators/SimpleGDParameterUpdate.java | 100 -
.../SimpleGDUpdateCalculator.java | 84 -
.../updatecalculators/package-info.java | 23 -
.../java/org/apache/ignite/ml/package-info.java | 23 -
.../org/apache/ignite/ml/pipeline/Pipeline.java | 168 -
.../org/apache/ignite/ml/pipeline/PipelineMdl.java | 78 -
.../apache/ignite/ml/pipeline/package-info.java | 22 -
.../ml/preprocessing/PreprocessingTrainer.java | 148 -
.../ignite/ml/preprocessing/Preprocessor.java | 42 -
.../binarization/BinarizationPreprocessor.java | 83 -
.../binarization/BinarizationTrainer.java | 62 -
.../preprocessing/binarization/package-info.java | 22 -
.../developer/MappedPreprocessor.java | 62 -
.../developer/PatchedPreprocessor.java | 75 -
.../ml/preprocessing/developer/package-info.java | 22 -
.../encoding/EncoderPartitionData.java | 101 -
.../encoding/EncoderPreprocessor.java | 71 -
.../encoding/EncoderSortingStrategy.java | 31 -
.../ml/preprocessing/encoding/EncoderTrainer.java | 619 -
.../ml/preprocessing/encoding/EncoderType.java | 40 -
.../frequency/FrequencyEncoderPreprocessor.java | 89 -
.../encoding/frequency/package-info.java | 22 -
.../encoding/label/LabelEncoderPreprocessor.java | 84 -
.../preprocessing/encoding/label/package-info.java | 22 -
.../onehotencoder/OneHotEncoderPreprocessor.java | 161 -
.../encoding/onehotencoder/package-info.java | 22 -
.../ml/preprocessing/encoding/package-info.java | 22 -
.../stringencoder/StringEncoderPreprocessor.java | 104 -
.../encoding/stringencoder/package-info.java | 22 -
.../encoding/target/TargetCounter.java | 78 -
.../encoding/target/TargetEncoderPreprocessor.java | 101 -
.../encoding/target/TargetEncodingMeta.java | 56 -
.../encoding/target/package-info.java | 22 -
.../VectorFinalizationPreprocessor.java | 77 -
.../finalization/VectorFinalizationTrainer.java | 39 -
.../preprocessing/finalization/package-info.java | 22 -
.../imputing/ImputerPartitionData.java | 159 -
.../imputing/ImputerPreprocessor.java | 77 -
.../ml/preprocessing/imputing/ImputerTrainer.java | 496 -
.../preprocessing/imputing/ImputingStrategy.java | 42 -
.../ml/preprocessing/imputing/package-info.java | 22 -
.../maxabsscaling/MaxAbsScalerPartitionData.java | 48 -
.../maxabsscaling/MaxAbsScalerPreprocessor.java | 85 -
.../maxabsscaling/MaxAbsScalerTrainer.java | 89 -
.../preprocessing/maxabsscaling/package-info.java | 22 -
.../minmaxscaling/MinMaxScalerPartitionData.java | 58 -
.../minmaxscaling/MinMaxScalerPreprocessor.java | 105 -
.../minmaxscaling/MinMaxScalerTrainer.java | 111 -
.../preprocessing/minmaxscaling/package-info.java | 22 -
.../normalization/NormalizationPreprocessor.java | 106 -
.../normalization/NormalizationTrainer.java | 62 -
.../preprocessing/normalization/package-info.java | 22 -
.../ignite/ml/preprocessing/package-info.java | 23 -
.../standardscaling/StandardScalerData.java | 58 -
.../StandardScalerPreprocessor.java | 100 -
.../standardscaling/StandardScalerTrainer.java | 105 -
.../standardscaling/package-info.java | 23 -
.../ml/recommendation/ObjectSubjectPair.java | 66 -
.../recommendation/ObjectSubjectRatingTriplet.java | 56 -
.../ml/recommendation/RecommendationModel.java | 70 -
.../ml/recommendation/RecommendationTrainer.java | 428 -
.../ignite/ml/recommendation/package-info.java | 22 -
.../util/MatrixFactorizationGradient.java | 104 -
.../RecommendationBinaryDatasetDataBuilder.java | 79 -
.../util/RecommendationDatasetData.java | 149 -
.../util/RecommendationDatasetDataBuilder.java | 57 -
.../ml/recommendation/util/package-info.java | 22 -
.../linear/LinearRegressionLSQRTrainer.java | 100 -
.../regressions/linear/LinearRegressionModel.java | 217 -
.../linear/LinearRegressionSGDTrainer.java | 259 -
.../ignite/ml/regressions/linear/package-info.java | 23 -
.../logistic/LogisticRegressionModel.java | 317 -
.../logistic/LogisticRegressionSGDTrainer.java | 255 -
.../ml/regressions/logistic/package-info.java | 23 -
.../apache/ignite/ml/regressions/package-info.java | 23 -
.../ml/selection/cv/AbstractCrossValidation.java | 446 -
.../ignite/ml/selection/cv/CrossValidation.java | 103 -
.../ml/selection/cv/CrossValidationResult.java | 197 -
.../ml/selection/cv/DebugCrossValidation.java | 102 -
.../ignite/ml/selection/cv/package-info.java | 23 -
.../apache/ignite/ml/selection/package-info.java | 23 -
.../ml/selection/paramgrid/BruteForceStrategy.java | 28 -
.../paramgrid/EvolutionOptimizationStrategy.java | 157 -
.../paramgrid/HyperParameterTuningStrategy.java | 28 -
.../ignite/ml/selection/paramgrid/ParamGrid.java | 100 -
.../selection/paramgrid/ParameterSetGenerator.java | 91 -
.../ml/selection/paramgrid/RandomStrategy.java | 84 -
.../ml/selection/paramgrid/package-info.java | 22 -
.../ignite/ml/selection/scoring/LabelPair.java | 52 -
.../scoring/cursor/CacheBasedLabelPairCursor.java | 149 -
.../selection/scoring/cursor/LabelPairCursor.java | 29 -
.../scoring/cursor/LocalLabelPairCursor.java | 132 -
.../ml/selection/scoring/cursor/package-info.java | 22 -
.../scoring/evaluator/EvaluationResult.java | 94 -
.../ml/selection/scoring/evaluator/Evaluator.java | 641 -
...assificationPointwiseMetricStatsAggregator.java | 250 -
.../ClassificationMetricsAggregator.java | 118 -
.../aggregator/MetricStatsAggregator.java | 63 -
.../RegressionMetricStatsAggregator.java | 195 -
.../scoring/evaluator/aggregator/package-info.java | 21 -
.../BinaryClassificationEvaluationContext.java | 157 -
.../scoring/evaluator/context/EmptyContext.java | 52 -
.../evaluator/context/EvaluationContext.java | 63 -
.../scoring/evaluator/context/package-info.java | 21 -
.../selection/scoring/evaluator/package-info.java | 22 -
.../ignite/ml/selection/scoring/metric/Metric.java | 60 -
.../ml/selection/scoring/metric/MetricName.java | 213 -
.../scoring/metric/classification/Accuracy.java | 74 -
.../metric/classification/BalancedAccuracy.java | 77 -
.../classification/BinaryClassificationMetric.java | 72 -
.../scoring/metric/classification/FMeasure.java | 118 -
.../scoring/metric/classification/FallOut.java | 76 -
.../classification/FalseNegativeAbsoluteValue.java | 75 -
.../classification/FalsePositiveAbsoluteValue.java | 75 -
.../scoring/metric/classification/Fdr.java | 76 -
.../scoring/metric/classification/MissRate.java | 76 -
.../scoring/metric/classification/Npv.java | 76 -
.../scoring/metric/classification/Precision.java | 75 -
.../scoring/metric/classification/Recall.java | 75 -
.../scoring/metric/classification/Specificity.java | 76 -
.../classification/TrueNegativeAbsoluteValue.java | 75 -
.../classification/TruePositiveAbsoluteValue.java | 75 -
.../metric/classification/package-info.java | 21 -
.../ml/selection/scoring/metric/package-info.java | 21 -
.../selection/scoring/metric/regression/Mae.java | 67 -
.../selection/scoring/metric/regression/Mse.java | 67 -
.../ml/selection/scoring/metric/regression/R2.java | 70 -
.../selection/scoring/metric/regression/Rmse.java | 67 -
.../selection/scoring/metric/regression/Rss.java | 67 -
.../scoring/metric/regression/package-info.java | 21 -
.../ignite/ml/selection/scoring/package-info.java | 22 -
.../selection/split/TrainTestDatasetSplitter.java | 122 -
.../ignite/ml/selection/split/TrainTestSplit.java | 59 -
.../split/mapper/SHA256UniformMapper.java | 95 -
.../ml/selection/split/mapper/UniformMapper.java | 38 -
.../ml/selection/split/mapper/package-info.java | 23 -
.../ignite/ml/selection/split/package-info.java | 23 -
.../org/apache/ignite/ml/sql/SQLFunctions.java | 108 -
.../apache/ignite/ml/sql/SqlDatasetBuilder.java | 64 -
.../org/apache/ignite/ml/sql/package-info.java | 23 -
.../org/apache/ignite/ml/structures/Dataset.java | 241 -
.../apache/ignite/ml/structures/DatasetRow.java | 126 -
.../ignite/ml/structures/FeatureMetadata.java | 81 -
.../apache/ignite/ml/structures/LabeledVector.java | 106 -
.../ignite/ml/structures/LabeledVectorSet.java | 200 -
.../structures/LabeledVectorSetTestTrainPair.java | 114 -
.../apache/ignite/ml/structures/package-info.java | 23 -
.../partition/LabelPartitionDataBuilderOnHeap.java | 69 -
.../partition/LabelPartitionDataOnHeap.java | 45 -
.../LabeledDatasetPartitionDataBuilderOnHeap.java | 85 -
.../ml/structures/partition/package-info.java | 23 -
.../preprocessing/LabeledDatasetLoader.java | 132 -
.../ml/structures/preprocessing/package-info.java | 22 -
.../ml/svm/SVMLinearClassificationModel.java | 306 -
.../ml/svm/SVMLinearClassificationTrainer.java | 362 -
.../org/apache/ignite/ml/svm/package-info.java | 23 -
.../ignite/ml/trainers/AdaptableDatasetModel.java | 98 -
.../ml/trainers/AdaptableDatasetTrainer.java | 269 -
.../apache/ignite/ml/trainers/DatasetTrainer.java | 402 -
.../ignite/ml/trainers/FeatureLabelExtractor.java | 62 -
.../ml/trainers/MultiLabelDatasetTrainer.java | 28 -
.../ml/trainers/SingleLabelDatasetTrainer.java | 28 -
.../ignite/ml/trainers/TrainerTransformers.java | 266 -
.../apache/ignite/ml/trainers/package-info.java | 23 -
.../transformers/BaggingUpstreamTransformer.java | 76 -
.../ml/trainers/transformers/package-info.java | 23 -
.../ml/tree/DecisionTreeClassificationTrainer.java | 156 -
.../ml/tree/DecisionTreeConditionalNode.java | 129 -
.../ignite/ml/tree/DecisionTreeLeafNode.java | 64 -
.../apache/ignite/ml/tree/DecisionTreeModel.java | 113 -
.../apache/ignite/ml/tree/DecisionTreeNode.java | 39 -
.../ml/tree/DecisionTreeRegressionTrainer.java | 78 -
.../apache/ignite/ml/tree/DecisionTreeTrainer.java | 345 -
.../java/org/apache/ignite/ml/tree/NodeData.java | 94 -
.../java/org/apache/ignite/ml/tree/TreeFilter.java | 38 -
.../GDBBinaryClassifierOnTreesTrainer.java | 129 -
.../tree/boosting/GDBOnTreesLearningStrategy.java | 113 -
.../tree/boosting/GDBRegressionOnTreesTrainer.java | 129 -
.../ignite/ml/tree/boosting/package-info.java | 22 -
.../ignite/ml/tree/data/DecisionTreeData.java | 167 -
.../ml/tree/data/DecisionTreeDataBuilder.java | 85 -
.../apache/ignite/ml/tree/data/TreeDataIndex.java | 184 -
.../apache/ignite/ml/tree/data/package-info.java | 23 -
.../ignite/ml/tree/impurity/ImpurityMeasure.java | 55 -
.../tree/impurity/ImpurityMeasureCalculator.java | 115 -
.../ml/tree/impurity/gini/GiniImpurityMeasure.java | 115 -
.../gini/GiniImpurityMeasureCalculator.java | 131 -
.../ignite/ml/tree/impurity/gini/package-info.java | 23 -
.../ml/tree/impurity/mse/MSEImpurityMeasure.java | 133 -
.../impurity/mse/MSEImpurityMeasureCalculator.java | 116 -
.../ignite/ml/tree/impurity/mse/package-info.java | 23 -
.../ignite/ml/tree/impurity/package-info.java | 23 -
.../util/SimpleStepFunctionCompressor.java | 149 -
.../ignite/ml/tree/impurity/util/StepFunction.java | 162 -
.../tree/impurity/util/StepFunctionCompressor.java | 55 -
.../ignite/ml/tree/impurity/util/package-info.java | 23 -
.../ml/tree/leaf/DecisionTreeLeafBuilder.java | 38 -
.../ml/tree/leaf/MeanDecisionTreeLeafBuilder.java | 73 -
.../leaf/MostCommonDecisionTreeLeafBuilder.java | 86 -
.../apache/ignite/ml/tree/leaf/package-info.java | 23 -
.../org/apache/ignite/ml/tree/package-info.java | 23 -
.../RandomForestClassifierTrainer.java | 118 -
.../ml/tree/randomforest/RandomForestModel.java | 108 -
.../RandomForestRegressionTrainer.java | 64 -
.../ml/tree/randomforest/RandomForestTrainer.java | 398 -
.../data/FeaturesCountSelectionStrategies.java | 39 -
.../ignite/ml/tree/randomforest/data/NodeId.java | 83 -
.../ml/tree/randomforest/data/NodeSplit.java | 87 -
.../randomforest/data/RandomForestTreeModel.java | 145 -
.../ignite/ml/tree/randomforest/data/TreeNode.java | 215 -
.../randomforest/data/impurity/GiniHistogram.java | 203 -
.../data/impurity/GiniHistogramsComputer.java | 46 -
.../data/impurity/ImpurityComputer.java | 38 -
.../data/impurity/ImpurityHistogram.java | 78 -
.../data/impurity/ImpurityHistogramsComputer.java | 211 -
.../randomforest/data/impurity/MSEHistogram.java | 284 -
.../data/impurity/MSEHistogramComputer.java | 33 -
.../basic/BootstrappedVectorsHistogram.java | 60 -
.../data/impurity/basic/CountersHistogram.java | 57 -
.../data/impurity/basic/package-info.java | 22 -
.../randomforest/data/impurity/package-info.java | 22 -
.../ml/tree/randomforest/data/package-info.java | 22 -
.../statistics/ClassifierLeafValuesComputer.java | 117 -
.../data/statistics/LeafValuesComputer.java | 158 -
.../data/statistics/MeanValueStatistic.java | 72 -
.../statistics/NormalDistributionStatistics.java | 112 -
.../NormalDistributionStatisticsComputer.java | 119 -
.../statistics/RegressionLeafValuesComputer.java | 62 -
.../randomforest/data/statistics/package-info.java | 22 -
.../ignite/ml/tree/randomforest/package-info.java | 22 -
.../java/org/apache/ignite/ml/util/LRUCache.java | 69 -
.../ignite/ml/util/LRUCacheExpirationListener.java | 33 -
.../java/org/apache/ignite/ml/util/MnistUtils.java | 246 -
.../java/org/apache/ignite/ml/util/ModelTrace.java | 132 -
.../main/java/org/apache/ignite/ml/util/Utils.java | 178 -
.../ml/util/generators/DataStreamGenerator.java | 188 -
.../ml/util/generators/DatasetBuilderAdapter.java | 69 -
.../ignite/ml/util/generators/package-info.java | 25 -
.../util/generators/primitives/package-info.java | 22 -
.../primitives/scalar/DiscreteRandomProducer.java | 204 -
.../primitives/scalar/GaussRandomProducer.java | 78 -
.../primitives/scalar/RandomProducer.java | 78 -
.../scalar/RandomProducerWithGenerator.java | 51 -
.../primitives/scalar/UniformRandomProducer.java | 66 -
.../generators/primitives/scalar/package-info.java | 22 -
.../vector/ParametricVectorGenerator.java | 62 -
.../primitives/vector/VectorGenerator.java | 224 -
.../vector/VectorGeneratorPrimitives.java | 154 -
.../primitives/vector/VectorGeneratorsFamily.java | 193 -
.../generators/primitives/vector/package-info.java | 22 -
.../standard/GaussianMixtureDataStream.java | 99 -
.../generators/standard/RegressionDataStream.java | 119 -
.../util/generators/standard/RingsDataStream.java | 90 -
.../standard/TwoSeparableClassesDataStream.java | 95 -
.../ml/util/generators/standard/package-info.java | 22 -
.../apache/ignite/ml/util/genetic/Chromosome.java | 110 -
.../ignite/ml/util/genetic/CrossoverStrategy.java | 35 -
.../ignite/ml/util/genetic/GeneticAlgorithm.java | 452 -
.../apache/ignite/ml/util/genetic/Population.java | 158 -
.../ignite/ml/util/genetic/SelectionStrategy.java | 32 -
.../ignite/ml/util/genetic/package-info.java | 23 -
.../org/apache/ignite/ml/util/package-info.java | 23 -
.../org/apache/ignite/ml/util/plugin/MLPlugin.java | 30 -
.../ml/util/plugin/MLPluginConfiguration.java | 77 -
.../ignite/ml/util/plugin/MLPluginProvider.java | 197 -
.../apache/ignite/ml/util/plugin/package-info.java | 22 -
.../org.apache.ignite.plugin.PluginProvider | 1 -
.../apache/ignite/ml/math/d3-dataset-template.html | 112 -
.../apache/ignite/ml/math/d3-matrix-template.html | 121 -
.../apache/ignite/ml/math/d3-vector-template.html | 106 -
.../org/apache/ignite/ml/IgniteMLTestSuite.java | 75 -
.../test/java/org/apache/ignite/ml/TestUtils.java | 481 -
.../ignite/ml/clustering/ClusteringTestSuite.java | 49 -
.../ignite/ml/clustering/KMeansModelTest.java | 60 -
.../ignite/ml/clustering/KMeansTrainerTest.java | 115 -
.../gmm/CovarianceMatricesAggregatorTest.java | 161 -
.../ignite/ml/clustering/gmm/GmmModelTest.java | 88 -
.../ml/clustering/gmm/GmmPartitionDataTest.java | 90 -
.../clustering/gmm/GmmTrainerIntegrationTest.java | 94 -
.../ignite/ml/clustering/gmm/GmmTrainerTest.java | 106 -
.../gmm/MeanWithClusterProbAggregatorTest.java | 131 -
.../gmm/NewComponentStatisticsAggregatorTest.java | 147 -
.../apache/ignite/ml/common/CollectionsTest.java | 127 -
.../apache/ignite/ml/common/CommonTestSuite.java | 35 -
.../apache/ignite/ml/common/ExternalizeTest.java | 101 -
.../apache/ignite/ml/common/KeepBinaryTest.java | 109 -
.../apache/ignite/ml/common/LocalModelsTest.java | 188 -
.../org/apache/ignite/ml/common/ModelTest.java | 45 -
.../org/apache/ignite/ml/common/TrainerTest.java | 1189 -
.../ml/composition/CompositionTestSuite.java | 45 -
.../apache/ignite/ml/composition/StackingTest.java | 168 -
.../ignite/ml/composition/bagging/BaggingTest.java | 239 -
.../ml/composition/boosting/GDBTrainerTest.java | 210 -
.../convergence/ConvergenceCheckerTest.java | 80 -
.../mean/MeanAbsValueConvergenceCheckerTest.java | 84 -
.../MedianOfMedianConvergenceCheckerTest.java | 66 -
.../MeanValuePredictionsAggregatorTest.java | 34 -
.../OnMajorityPredictionsAggregatorTest.java | 36 -
.../WeightedPredictionsAggregatorTest.java | 65 -
.../apache/ignite/ml/dataset/DatasetTestSuite.java | 55 -
.../ml/dataset/feature/ObjectHistogramTest.java | 215 -
.../dataset/feature/extractor/VectorizerTest.java | 92 -
.../impl/cache/CacheBasedDatasetBuilderTest.java | 150 -
.../dataset/impl/cache/CacheBasedDatasetTest.java | 363 -
.../dataset/impl/cache/util/ComputeUtilsTest.java | 323 -
.../util/DatasetAffinityFunctionWrapperTest.java | 110 -
...ratorWithConcurrentModificationCheckerTest.java | 91 -
.../impl/cache/util/PartitionDataStorageTest.java | 49 -
.../impl/local/LocalDatasetBuilderTest.java | 137 -
.../ml/dataset/primitive/DatasetWrapperTest.java | 138 -
.../ml/dataset/primitive/SimpleDatasetTest.java | 81 -
.../primitive/SimpleLabeledDatasetTest.java | 97 -
.../ml/environment/EnvironmentTestSuite.java | 37 -
.../LearningEnvironmentBuilderTest.java | 91 -
.../ml/environment/LearningEnvironmentTest.java | 179 -
.../apache/ignite/ml/environment/PromiseTest.java | 79 -
.../deploy/DeployingContextImplTest.java | 150 -
.../ml/environment/deploy/MLDeployingTest.java | 245 -
.../ml/inference/IgniteModelStorageUtilTest.java | 81 -
.../ignite/ml/inference/InferenceTestSuite.java | 41 -
.../builder/IgniteDistributedModelBuilderTest.java | 67 -
.../ml/inference/builder/ModelBuilderTestUtil.java | 53 -
.../inference/builder/SingleModelBuilderTest.java | 42 -
.../builder/ThreadedModelBuilderTest.java | 44 -
.../storage/model/AbstractModelStorageTest.java | 142 -
.../storage/model/DefaultModelStorageTest.java | 145 -
.../ml/inference/util/DirectorySerializerTest.java | 126 -
.../ignite/ml/knn/ANNClassificationTest.java | 119 -
.../ignite/ml/knn/KNNClassificationTest.java | 197 -
.../apache/ignite/ml/knn/KNNRegressionTest.java | 150 -
.../org/apache/ignite/ml/knn/KNNTestSuite.java | 39 -
.../apache/ignite/ml/knn/LabeledDatasetHelper.java | 56 -
.../ignite/ml/knn/utils/ArraySpatialIndexTest.java | 32 -
.../ml/knn/utils/BallTreeSpatialIndexTest.java | 32 -
.../ml/knn/utils/KDTreeSpatialIndexTest.java | 32 -
.../ignite/ml/knn/utils/SpatialIndexTest.java | 104 -
.../java/org/apache/ignite/ml/math/BlasTest.java | 361 -
.../apache/ignite/ml/math/ExternalizableTest.java | 67 -
.../org/apache/ignite/ml/math/ExternalizeTest.java | 68 -
.../ignite/ml/math/MathImplLocalTestSuite.java | 91 -
.../ignite/ml/math/MathImplMainTestSuite.java | 36 -
.../java/org/apache/ignite/ml/math/TracerTest.java | 248 -
.../org/apache/ignite/ml/math/VectorUtilsTest.java | 69 -
.../ml/math/distances/BrayCurtisDistanceTest.java | 110 -
.../ml/math/distances/CanberraDistanceTest.java | 110 -
.../ml/math/distances/CosineSimilarityTest.java | 41 -
.../ignite/ml/math/distances/DistanceTest.java | 230 -
.../ml/math/distances/DistancesTestSuite.java | 35 -
.../ignite/ml/math/distances/JaccardIndexTest.java | 43 -
.../math/distances/JensenShannonDistanceTest.java | 113 -
.../distances/WeightedMinkowskiDistanceTest.java | 121 -
.../ignite/ml/math/isolve/lsqr/LSQROnHeapTest.java | 154 -
.../ml/math/primitives/MathTestConstants.java | 88 -
.../matrix/DenseMatrixConstructorTest.java | 71 -
.../primitives/matrix/LUDecompositionTest.java | 254 -
.../primitives/matrix/MatrixArrayStorageTest.java | 57 -
.../primitives/matrix/MatrixAttributeTest.java | 135 -
.../primitives/matrix/MatrixBaseStorageTest.java | 88 -
.../primitives/matrix/MatrixStorageFixtures.java | 148 -
.../matrix/MatrixStorageImplementationTest.java | 77 -
.../matrix/MatrixViewConstructorTest.java | 112 -
.../matrix/SparseMatrixConstructorTest.java | 53 -
.../math/primitives/vector/AbstractVectorTest.java | 528 -
.../vector/DelegatingVectorConstructorTest.java | 65 -
.../vector/DenseVectorConstructorTest.java | 158 -
.../primitives/vector/MatrixVectorViewTest.java | 218 -
.../vector/SparseVectorConstructorTest.java | 57 -
.../primitives/vector/VectorArrayStorageTest.java | 59 -
.../primitives/vector/VectorAttributesTest.java | 175 -
.../primitives/vector/VectorBaseStorageTest.java | 68 -
.../math/primitives/vector/VectorFoldMapTest.java | 121 -
.../vector/VectorImplementationsFixtures.java | 427 -
.../vector/VectorImplementationsTest.java | 850 -
.../primitives/vector/VectorNormCasesTest.java | 114 -
.../ml/math/primitives/vector/VectorNormTest.java | 239 -
.../math/primitives/vector/VectorToMatrixTest.java | 261 -
.../ml/math/primitives/vector/VectorViewTest.java | 163 -
.../vector/storage/AbstractStorageTest.java | 147 -
.../vector/storage/DenseVectorStorageTest.java | 60 -
.../vector/storage/SparseVectorStorageTest.java | 47 -
.../ml/math/stat/DistributionMixtureTest.java | 84 -
.../stat/MultivariateGaussianDistributionTest.java | 40 -
.../apache/ignite/ml/math/stat/StatsTestSuite.java | 32 -
.../ignite/ml/multiclass/MultiClassTestSuite.java | 32 -
.../ignite/ml/multiclass/OneVsRestTrainerTest.java | 124 -
.../ignite/ml/naivebayes/NaiveBayesTestSuite.java | 48 -
.../compound/CompoundNaiveBayesModelTest.java | 94 -
.../compound/CompoundNaiveBayesTest.java | 64 -
.../compound/CompoundNaiveBayesTrainerTest.java | 107 -
.../apache/ignite/ml/naivebayes/compound/Data.java | 87 -
.../discrete/DiscreteNaiveBayesModelTest.java | 46 -
.../discrete/DiscreteNaiveBayesTest.java | 70 -
.../discrete/DiscreteNaiveBayesTrainerTest.java | 183 -
.../gaussian/GaussianNaiveBayesModelTest.java | 49 -
.../gaussian/GaussianNaiveBayesTest.java | 85 -
.../gaussian/GaussianNaiveBayesTrainerTest.java | 183 -
.../org/apache/ignite/ml/nn/LossFunctionsTest.java | 92 -
.../apache/ignite/ml/nn/MLPConstInitializer.java | 67 -
.../test/java/org/apache/ignite/ml/nn/MLPTest.java | 265 -
.../java/org/apache/ignite/ml/nn/MLPTestSuite.java | 34 -
.../ignite/ml/nn/MLPTrainerIntegrationTest.java | 158 -
.../org/apache/ignite/ml/nn/MLPTrainerTest.java | 260 -
.../MLPTrainerMnistIntegrationTest.java | 114 -
.../ml/nn/performance/MLPTrainerMnistTest.java | 86 -
.../ignite/ml/nn/performance/MnistMLPTestUtil.java | 96 -
.../apache/ignite/ml/pipeline/PipelineMdlTest.java | 79 -
.../apache/ignite/ml/pipeline/PipelineTest.java | 85 -
.../ignite/ml/pipeline/PipelineTestSuite.java | 33 -
.../ml/preprocessing/PreprocessingTestSuite.java | 69 -
.../binarization/BinarizationPreprocessorTest.java | 55 -
.../binarization/BinarizationTrainerTest.java | 93 -
.../preprocessing/encoding/EncoderTrainerTest.java | 285 -
.../encoding/FrequencyEncoderPreprocessorTest.java | 74 -
.../encoding/LabelEncoderPreprocessorTest.java | 62 -
.../encoding/OneHotEncoderPreprocessorTest.java | 207 -
.../encoding/StringEncoderPreprocessorTest.java | 74 -
.../encoding/TargetEncoderPreprocessorTest.java | 104 -
.../imputing/ImputerPreprocessorTest.java | 56 -
.../preprocessing/imputing/ImputerTrainerTest.java | 183 -
.../MaxAbsScalerPreprocessorTest.java | 58 -
.../maxabsscaling/MaxAbsScalerTrainerTest.java | 61 -
.../MinMaxScalerPreprocessorTest.java | 75 -
.../minmaxscaling/MinMaxScalerTrainerTest.java | 62 -
.../NormalizationPreprocessorTest.java | 56 -
.../normalization/NormalizationTrainerTest.java | 68 -
.../StandardScalerPreprocessorTest.java | 62 -
.../standardscaling/StandardScalerTrainerTest.java | 93 -
.../ml/recommendation/RecommendationTestSuite.java | 34 -
.../RecommendationTrainerSQLTest.java | 126 -
.../recommendation/RecommendationTrainerTest.java | 211 -
.../ml/regressions/RegressionsTestSuite.java | 41 -
.../linear/LinearRegressionLSQRTrainerTest.java | 152 -
.../linear/LinearRegressionModelTest.java | 72 -
.../linear/LinearRegressionSGDTrainerTest.java | 130 -
.../logistic/LogisticRegressionModelTest.java | 95 -
.../logistic/LogisticRegressionSGDTrainerTest.java | 106 -
.../ignite/ml/selection/SelectionTestSuite.java | 56 -
.../ml/selection/cv/CrossValidationTest.java | 344 -
.../paramgrid/ParameterSetGeneratorTest.java | 57 -
.../ml/selection/scoring/TestLabelPairCursor.java | 91 -
.../cursor/CacheBasedLabelPairCursorTest.java | 79 -
.../scoring/cursor/LocalLabelPairCursorTest.java | 58 -
.../BinaryClassificationEvaluatorTest.java | 93 -
.../scoring/evaluator/RegressionEvaluatorTest.java | 122 -
...ficationPointwiseMetricStatsAggregatorTest.java | 104 -
.../RegressionMetricStatsAggregatorTest.java | 96 -
.../BinaryClassificationEvaluationContextTest.java | 149 -
.../BinaryClassificationMetricsTest.java | 87 -
.../metric/regression/RegressionMetricsTest.java | 65 -
.../split/TrainTestDatasetSplitterTest.java | 46 -
.../split/mapper/SHA256UniformMapperTest.java | 70 -
.../ignite/ml/structures/DatasetStructureTest.java | 50 -
.../ignite/ml/structures/LabeledVectorSetTest.java | 291 -
.../ignite/ml/structures/StructuresTestSuite.java | 32 -
.../apache/ignite/ml/svm/SVMBinaryTrainerTest.java | 93 -
.../org/apache/ignite/ml/svm/SVMModelTest.java | 118 -
.../org/apache/ignite/ml/svm/SVMTestSuite.java | 33 -
...onTreeClassificationTrainerIntegrationTest.java | 93 -
.../DecisionTreeClassificationTrainerTest.java | 103 -
...cisionTreeRegressionTrainerIntegrationTest.java | 102 -
.../ml/tree/DecisionTreeRegressionTrainerTest.java | 94 -
.../ignite/ml/tree/DecisionTreeTestSuite.java | 50 -
.../ignite/ml/tree/data/DecisionTreeDataTest.java | 76 -
.../ignite/ml/tree/data/TreeDataIndexTest.java | 159 -
.../gini/GiniImpurityMeasureCalculatorTest.java | 120 -
.../impurity/gini/GiniImpurityMeasureTest.java | 129 -
.../mse/MSEImpurityMeasureCalculatorTest.java | 76 -
.../tree/impurity/mse/MSEImpurityMeasureTest.java | 109 -
.../util/SimpleStepFunctionCompressorTest.java | 108 -
.../ml/tree/impurity/util/StepFunctionTest.java | 71 -
.../ml/tree/impurity/util/TestImpurityMeasure.java | 88 -
.../DecisionTreeMNISTIntegrationTest.java | 95 -
.../ml/tree/performance/DecisionTreeMNISTTest.java | 64 -
.../RandomForestClassifierTrainerTest.java | 100 -
.../randomforest/RandomForestIntegrationTest.java | 92 -
.../RandomForestRegressionTrainerTest.java | 95 -
.../ml/tree/randomforest/RandomForestTest.java | 78 -
.../randomforest/RandomForestTreeTestSuite.java | 42 -
.../ml/tree/randomforest/data/TreeNodeTest.java | 78 -
.../data/impurity/GiniFeatureHistogramTest.java | 257 -
.../data/impurity/ImpurityHistogramTest.java | 90 -
.../data/impurity/MSEHistogramTest.java | 139 -
.../NormalDistributionStatisticsComputerTest.java | 131 -
.../org/apache/ignite/ml/util/LRUCacheTest.java | 68 -
.../org/apache/ignite/ml/util/UtilTestSuite.java | 35 -
.../DataStreamGeneratorFillCacheTest.java | 123 -
.../util/generators/DataStreamGeneratorTest.java | 208 -
.../generators/DataStreamGeneratorTestSuite.java | 50 -
.../scalar/DiscreteRandomProducerTest.java | 102 -
.../primitives/scalar/GaussRandomProducerTest.java | 66 -
.../primitives/scalar/RandomProducerTest.java | 79 -
.../scalar/UniformRandomProducerTest.java | 67 -
.../vector/ParametricVectorGeneratorTest.java | 50 -
.../vector/VectorGeneratorPrimitivesTest.java | 110 -
.../primitives/vector/VectorGeneratorTest.java | 194 -
.../vector/VectorGeneratorsFamilyTest.java | 116 -
.../ml/util/genetic/GeneticAlgorithmTest.java | 100 -
.../ignite/ml/util/genetic/PopulationTest.java | 126 -
modules/ml/src/test/resources/datasets/README.md | 5 -
.../resources/datasets/knn/cleared_machines.txt | 209 -
.../ml/src/test/resources/datasets/knn/empty.txt | 0
.../ml/src/test/resources/datasets/knn/iris.txt | 150 -
.../test/resources/datasets/knn/iris_incorrect.txt | 150 -
.../test/resources/datasets/knn/machine.data.txt | 209 -
.../test/resources/datasets/knn/missed_data.txt | 3 -
.../ml/src/test/resources/datasets/knn/no_data.txt | 6 -
.../test/resources/datasets/regression/README.md | 98 -
.../test/resources/datasets/regression/boston.csv | 506 -
.../resources/datasets/regression/diabetes.csv | 442 -
.../trees/columntrees.manualrun.properties | 21 -
modules/ml/xgboost-model-parser/pom.xml | 94 -
.../ignite/ml/xgboost/XGModelComposition.java | 113 -
.../org/apache/ignite/ml/xgboost/package-info.java | 23 -
.../ml/xgboost/parser/XGBoostModelBaseVisitor.java | 90 -
.../ml/xgboost/parser/XGBoostModelLexer.java | 264 -
.../ml/xgboost/parser/XGBoostModelListener.java | 98 -
.../ml/xgboost/parser/XGBoostModelParser.java | 1033 -
.../ml/xgboost/parser/XGBoostModelVisitor.java | 71 -
.../ignite/ml/xgboost/parser/XGModelParser.java | 86 -
.../ignite/ml/xgboost/parser/package-info.java | 23 -
.../ml/xgboost/parser/visitor/XGModelVisitor.java | 75 -
.../parser/visitor/XGTreeDictionaryVisitor.java | 40 -
.../ml/xgboost/parser/visitor/XGTreeVisitor.java | 95 -
.../ml/xgboost/parser/visitor/package-info.java | 23 -
.../ml/xgboost/IgniteMLXGBoostTestSuite.java | 31 -
.../ml/xgboost/parser/XGBoostModelParserTest.java | 85 -
.../src/test/resources/datasets/agaricus-model.txt | 714 -
.../test/resources/datasets/agaricus-test-data.txt | 1611 -
.../datasets/agaricus-test-expected-results.txt | 1611 -
modules/yardstick/config/benchmark-ml.properties | 95 -
modules/yardstick/pom.xml | 5 -
parent-internal/pom.xml | 4 -
parent/pom.xml | 2 -
pom.xml | 5 -
1304 files changed, 1 insertion(+), 238375 deletions(-)
diff --git a/.gitignore b/.gitignore
index 36a547edb64..24c79d3ea0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,9 +73,6 @@ CMakeSettings.json
#CMake temp files
/modules/platforms/cpp/**/cmake-build**
-#Files related to ML manual-runnable tests
-/modules/ml/src/test/resources/manualrun/trees/columntrees.manualrun.properties
-
#NodeJs files
/modules/platforms/nodejs/node_modules
diff --git a/README.md b/README.md
index a8600192a99..9e4c513c632 100644
--- a/README.md
+++ b/README.md
@@ -46,8 +46,6 @@ Apache Ignite comes with a ANSI-99 compliant, horizontally scalable, and fault-t
[Read More](https://ignite.apache.org/features/sql.html)
-## Machine Learning and High-Performance Computing
-[Apache Ignite Machine Learning](https://ignite.apache.org/features/machinelearning.html) is a set of simple, scalable, and efficient tools that allow building predictive machine learning models without costly data transfers. The rationale for adding machine and deep learning to Apache Ignite is quite simple. Today's data scientists have to deal with two major factors that keep ML from mainstream adoption.
-
+## High-Performance Computing
High-performance computing (HPC) is the ability to process data and perform complex calculations at high speeds. Using Apache Ignite as a [high-performance compute cluster](https://ignite.apache.org/use-cases/hpc.html), you can turn a group of commodity machines or a cloud environment into a distributed supercomputer of interconnected Ignite nodes. Ignite enables speed and scale by processing records in memory and reducing network utilization with APIs for data and compute-intensive calc [...]
diff --git a/assembly/dependencies-apache-ignite-slim.xml b/assembly/dependencies-apache-ignite-slim.xml
index 21d345eda95..2604925c5c7 100644
--- a/assembly/dependencies-apache-ignite-slim.xml
+++ b/assembly/dependencies-apache-ignite-slim.xml
@@ -140,11 +140,6 @@
<exclude>${project.groupId}:ignite-cassandra-store</exclude>
<exclude>${project.groupId}:ignite-direct-io</exclude>
<exclude>${project.groupId}:ignite-jcl</exclude>
- <exclude>${project.groupId}:ignite-ml</exclude>
- <exclude>${project.groupId}:ignite-ml-h2o-model-parser</exclude>
- <exclude>${project.groupId}:ignite-ml-spark-model-parser</exclude>
- <exclude>${project.groupId}:ignite-ml-xgboost-model-parser</exclude>
- <exclude>${project.groupId}:ignite-ml-catboost-model-parser</exclude>
<exclude>${project.groupId}:ignite-web</exclude>
<exclude>${project.groupId}:ignite-zookeeper</exclude>
<exclude>${project.groupId}:ignite-control-utility</exclude>
diff --git a/examples/config/example-ignite-ml.xml b/examples/config/example-ignite-ml.xml
deleted file mode 100644
index a8ac7059abb..00000000000
--- a/examples/config/example-ignite-ml.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- 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.
--->
-
-<!--
- Ignite configuration with all defaults and enabled p2p deployment and enabled events.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <!-- Imports default Ignite configuration -->
- <import resource="example-default.xml"/>
-
- <bean parent="ignite.cfg">
- <property name="pluginConfigurations">
- <bean class="org.apache.ignite.ml.util.plugin.MLPluginConfiguration">
- <property name="withMdlStorage" value="#{true}" />
- <property name="withMdlDescStorage" value="#{true}" />
- </bean>
- </property>
- </bean>
-</beans>
diff --git a/examples/pom-standalone-lgpl.xml b/examples/pom-standalone-lgpl.xml
index 2499ad5e9e1..67969815bec 100644
--- a/examples/pom-standalone-lgpl.xml
+++ b/examples/pom-standalone-lgpl.xml
@@ -97,36 +97,6 @@
<version>0.3.0</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-xgboost-model-parser</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-catboost-model-parser</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-spark-model-parser</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-h2o-model-parser</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
index 2499ad5e9e1..67969815bec 100644
--- a/examples/pom-standalone.xml
+++ b/examples/pom-standalone.xml
@@ -97,36 +97,6 @@
<version>0.3.0</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-xgboost-model-parser</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-catboost-model-parser</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-spark-model-parser</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-h2o-model-parser</artifactId>
- <version>to_be_replaced_by_ignite_version</version>
- </dependency>
-
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
diff --git a/examples/pom.xml b/examples/pom.xml
index 730ba8e1203..c350b42b73f 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -101,41 +101,6 @@
<version>0.3.0</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml</artifactId>
- <exclusions>
- <exclusion>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-xgboost-model-parser</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-catboost-model-parser</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-h2o-model-parser</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ignite-ml-spark-model-parser</artifactId>
- <version>${project.version}</version>
- </dependency>
-
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ignite-kubernetes</artifactId>
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/TrainingWithBinaryObjectExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/TrainingWithBinaryObjectExample.java
deleted file mode 100644
index 5e388018f0d..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/TrainingWithBinaryObjectExample.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.clustering.kmeans.KMeansModel;
-import org.apache.ignite.ml.clustering.kmeans.KMeansTrainer;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.BinaryObjectVectorizer;
-import org.apache.ignite.ml.dataset.impl.cache.CacheBasedDatasetBuilder;
-
-/**
- * Example of support model training with binary objects.
- */
-public class TrainingWithBinaryObjectExample {
- /**
- * Run example.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Model training over cached dataset with binary objects usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, BinaryObject> dataCache = null;
- try {
- dataCache = populateCache(ignite);
-
- // Create dataset builder with enabled support of keeping binary for upstream cache.
- CacheBasedDatasetBuilder<Integer, BinaryObject> datasetBuilder =
- new CacheBasedDatasetBuilder<>(ignite, dataCache).withKeepBinary(true);
-
- Vectorizer<Integer, BinaryObject, String, Double> vectorizer =
- new BinaryObjectVectorizer<Integer>("feature1").labeled("label");
-
- KMeansTrainer trainer = new KMeansTrainer();
- KMeansModel mdl = trainer.fit(datasetBuilder, vectorizer);
-
- System.out.println(">>> Model trained over binary objects. Model " + mdl);
- }
- finally {
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Populate cache with some binary objects.
- */
- private static IgniteCache<Integer, BinaryObject> populateCache(Ignite ignite) {
- CacheConfiguration<Integer, BinaryObject> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, BinaryObject> cache = ignite.createCache(cacheConfiguration).withKeepBinary();
-
- BinaryObjectBuilder builder = ignite.binary().builder("testType");
-
- for (int i = 0; i < 100; i++) {
- if (i > 50)
- cache.put(i, builder.setField("feature1", 0.0).setField("label", 0.0).build());
- else
- cache.put(i, builder.setField("feature1", 1.0).setField("label", 1.0).build());
- }
- return cache;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/CustomersClusterizationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/CustomersClusterizationExample.java
deleted file mode 100644
index 5c0b8b1ccea..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/CustomersClusterizationExample.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.clustering;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.ml.clustering.kmeans.KMeansModel;
-import org.apache.ignite.ml.clustering.kmeans.KMeansTrainer;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.split.TrainTestDatasetSplitter;
-import org.apache.ignite.ml.selection.split.TrainTestSplit;
-import org.apache.ignite.ml.structures.LabeledVector;
-
-/**
- * Example of using KMeans clusterization to determine the optimal count of clusters in data.
- * <p>
- * Description of model can be found in: https://en.wikipedia.org/wiki/Kmeans . Original dataset can be downloaded from:
- * https://archive.ics.uci.edu/ml/datasets/Wholesale+customers . Copy of dataset are stored in:
- * modules/ml/src/main/resources/datasets/wholesale_customers.csv . Score for clusterizer estimation: mean of entropy in
- * clusters. Description of entropy can be found in: https://en.wikipedia.org/wiki/Entropy_(information_theory) .
- */
-public class CustomersClusterizationExample {
- /**
- * Runs example.
- */
- public static void main(String[] args) throws IOException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- System.out.println(">>> Fill dataset cache.");
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.WHOLESALE_CUSTOMERS);
-
- System.out.println(">>> Start training and scoring.");
- for (int amountOfClusters = 1; amountOfClusters < 10; amountOfClusters++) {
- KMeansTrainer trainer = new KMeansTrainer()
- .withAmountOfClusters(amountOfClusters)
- .withDistance(new EuclideanDistance())
- .withEnvironmentBuilder(LearningEnvironmentBuilder.defaultBuilder().withRNGSeed(0))
- .withMaxIterations(50);
-
- // This vectorizer works with values in cache of Vector class.
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST); // FIRST means "label are stored at first coordinate of vector"
-
- // Splits dataset to train and test samples with 80/20 proportion.
- TrainTestSplit<Integer, Vector> split = new TrainTestDatasetSplitter<Integer, Vector>().split(0.8);
-
- KMeansModel mdl = trainer.fit(
- ignite, dataCache,
- split.getTrainFilter(),
- vectorizer
- );
-
- double entropy = computeMeanEntropy(dataCache, split.getTestFilter(), vectorizer, mdl);
- System.out.println(String.format(">> Clusters mean entropy [%d clusters]: %.2f", amountOfClusters, entropy));
- }
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Computes mean entropy in clusters.
- *
- * @param cache Dataset cache.
- * @param filter Test dataset filter.
- * @param vectorizer Upstream vectorizer.
- * @param mdl KMeans model.
- * @return Score.
- */
- private static double computeMeanEntropy(IgniteCache<Integer, Vector> cache,
- IgniteBiPredicate<Integer, Vector> filter,
- Vectorizer<Integer, Vector, Integer, Double> vectorizer,
- KMeansModel mdl) {
-
- Map<Integer, Map<Integer, AtomicInteger>> clusterUniqueLbCounts = new HashMap<>();
- try (QueryCursor<Cache.Entry<Integer, Vector>> cursor = cache.query(new ScanQuery<>(filter))) {
- for (Cache.Entry<Integer, Vector> ent : cursor) {
- LabeledVector<Double> vec = vectorizer.apply(ent.getKey(), ent.getValue());
- int cluster = mdl.predict(vec.features());
- int ch = vec.label().intValue();
-
- if (!clusterUniqueLbCounts.containsKey(cluster))
- clusterUniqueLbCounts.put(cluster, new HashMap<>());
-
- if (!clusterUniqueLbCounts.get(cluster).containsKey(ch))
- clusterUniqueLbCounts.get(cluster).put(ch, new AtomicInteger());
-
- clusterUniqueLbCounts.get(cluster).get(ch).incrementAndGet();
- }
- }
-
- double sumOfClusterEntropies = 0.0;
- for (Integer cluster : clusterUniqueLbCounts.keySet()) {
- Map<Integer, AtomicInteger> lbCounters = clusterUniqueLbCounts.get(cluster);
- int sizeOfCluster = lbCounters.values().stream().mapToInt(AtomicInteger::get).sum();
- double entropyInCluster = lbCounters.values().stream()
- .mapToDouble(AtomicInteger::get)
- .map(lblsCount -> lblsCount / sizeOfCluster)
- .map(lblProb -> -lblProb * Math.log(lblProb))
- .sum();
-
- sumOfClusterEntropies += entropyInCluster;
- }
-
- return sumOfClusterEntropies / clusterUniqueLbCounts.size();
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/GmmClusterizationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/GmmClusterizationExample.java
deleted file mode 100644
index 549f294100b..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/GmmClusterizationExample.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.clustering;
-
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.clustering.gmm.GmmModel;
-import org.apache.ignite.ml.clustering.gmm.GmmTrainer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.LabeledDummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-import org.apache.ignite.ml.math.stat.MultivariateGaussianDistribution;
-import org.apache.ignite.ml.structures.LabeledVector;
-import org.apache.ignite.ml.util.generators.DataStreamGenerator;
-import org.apache.ignite.ml.util.generators.primitives.scalar.GaussRandomProducer;
-import org.apache.ignite.ml.util.generators.primitives.scalar.RandomProducer;
-import org.apache.ignite.ml.util.generators.primitives.vector.VectorGeneratorsFamily;
-
-/**
- * Example of using GMM clusterization algorithm. Gaussian Mixture Algorithm (GMM, see {@link GmmModel}, {@link
- * GmmTrainer}) can be used for input dataset data distribution representation as mixture of multivariate gaussians.
- * More info: https://en.wikipedia.org/wiki/Mixture_model#Gaussian_mixture_model .
- * <p>
- * In this example GMM are used for gaussians shape recovering - means and covariances of them.
- */
-public class GmmClusterizationExample {
- /**
- * Runs example.
- *
- * @param args Command line arguments.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> GMM clustering algorithm over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- long seed = 0;
-
- IgniteCache<Integer, LabeledVector<Double>> dataCache = null;
- try {
- dataCache = ignite.createCache(
- new CacheConfiguration<Integer, LabeledVector<Double>>("GMM_EXAMPLE_CACHE")
- .setAffinity(new RendezvousAffinityFunction(false, 10))
- );
-
- // Dataset consists of three gaussians where two from them are rotated onto PI/4.
- DataStreamGenerator dataStream = new VectorGeneratorsFamily.Builder().add(
- RandomProducer.vectorize(
- new GaussRandomProducer(0, 2., seed++),
- new GaussRandomProducer(0, 3., seed++)
- ).rotate(Math.PI / 4).move(VectorUtils.of(10., 10.))).add(
- RandomProducer.vectorize(
- new GaussRandomProducer(0, 1., seed++),
- new GaussRandomProducer(0, 2., seed++)
- ).rotate(-Math.PI / 4).move(VectorUtils.of(-10., 10.))).add(
- RandomProducer.vectorize(
- new GaussRandomProducer(0, 3., seed++),
- new GaussRandomProducer(0, 3., seed++)
- ).move(VectorUtils.of(0., -10.))
- ).build(seed++).asDataStream();
-
- AtomicInteger keyGen = new AtomicInteger();
- dataStream.fillCacheWithCustomKey(50000, dataCache, v -> keyGen.getAndIncrement());
- GmmTrainer trainer = new GmmTrainer(1);
-
- GmmModel mdl = trainer
- .withMaxCountIterations(10)
- .withMaxCountOfClusters(4)
- .withEnvironmentBuilder(LearningEnvironmentBuilder.defaultBuilder().withRNGSeed(seed))
- .fit(ignite, dataCache, new LabeledDummyVectorizer<>());
-
- System.out.println(">>> GMM means and covariances");
- for (int i = 0; i < mdl.countOfComponents(); i++) {
- MultivariateGaussianDistribution distribution = mdl.distributions().get(i);
- System.out.println();
- System.out.println("============");
- System.out.println("Component #" + i);
- System.out.println("============");
- System.out.println("Mean vector = ");
- Tracer.showAscii(distribution.mean());
- System.out.println();
- System.out.println("Covariance matrix = ");
- Tracer.showAscii(distribution.covariance());
- }
-
- System.out.println(">>>");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansClusterizationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansClusterizationExample.java
deleted file mode 100644
index b834529280f..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/KMeansClusterizationExample.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.clustering;
-
-import java.io.IOException;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.clustering.kmeans.KMeansModel;
-import org.apache.ignite.ml.clustering.kmeans.KMeansTrainer;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.Tracer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-
-/**
- * Run KMeans clustering algorithm ({@link KMeansTrainer}) over distributed dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the model based on the specified data using
- * <a href="https://en.wikipedia.org/wiki/K-means_clustering">KMeans</a> algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict what cluster does
- * this point belong to, and compares prediction to expected outcome (ground truth).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class KMeansClusterizationExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> KMeans clustering algorithm over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.TWO_CLASSED_IRIS);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer =
- new DummyVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST);
-
- KMeansTrainer trainer = new KMeansTrainer();
-
- KMeansModel mdl = trainer.fit(
- ignite,
- dataCache,
- vectorizer
- );
-
- System.out.println(">>> KMeans centroids");
- Tracer.showAscii(mdl.centers()[0]);
- Tracer.showAscii(mdl.centers()[1]);
- System.out.println(">>>");
-
- System.out.println(">>> --------------------------------------------");
- System.out.println(">>> | Predicted cluster\t| Erased class label\t|");
- System.out.println(">>> --------------------------------------------");
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- Vector val = observation.getValue();
- Vector inputs = val.copyOfRange(1, val.size());
- double groundTruth = val.get(0);
-
- double prediction = mdl.predict(inputs);
-
- System.out.printf(">>> | %.4f\t\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> KMeans clustering algorithm over cached dataset usage example completed.");
- }
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/clustering/package-info.java
deleted file mode 100644
index 4844f887045..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/clustering/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> ML clustering examples.
- */
-package org.apache.ignite.examples.ml.clustering;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/AlgorithmSpecificDatasetExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/dataset/AlgorithmSpecificDatasetExample.java
deleted file mode 100644
index 85102f42242..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/AlgorithmSpecificDatasetExample.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.dataset;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import com.github.fommil.netlib.BLAS;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.dataset.Dataset;
-import org.apache.ignite.ml.dataset.DatasetFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.dataset.primitive.DatasetWrapper;
-import org.apache.ignite.ml.dataset.primitive.builder.data.SimpleLabeledDatasetDataBuilder;
-import org.apache.ignite.ml.dataset.primitive.data.SimpleLabeledDatasetData;
-import org.apache.ignite.ml.math.functions.IgniteBiFunction;
-import org.apache.ignite.ml.math.functions.IgniteFunction;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.developer.PatchedPreprocessor;
-import org.apache.ignite.ml.structures.LabeledVector;
-
-/**
- * Example that shows how to implement your own algorithm (<a href="https://en.wikipedia.org/wiki/Gradient_descent">gradient</a>
- * descent trainer for linear regression) which uses dataset as an underlying infrastructure.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it creates an algorithm specific dataset to perform linear regression as described in more detail
- * below.</p>
- * <p>
- * Finally, this example trains linear regression model using gradient descent and outputs the result.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this functionality further.</p>
- * <p>
- * The common idea behind using algorithm specific datasets is to write a simple local version algorithm at first, then
- * find operations which involve data manipulations, and finally define algorithm specific version of the dataset
- * extended by introducing these new operations. As a result your algorithm will work with extended dataset (based on
- * {@link DatasetWrapper}) in a sequential manner.</p>
- * <p>
- * In this example we need to implement gradient descent. This is iterative method that involves calculation of gradient
- * on every step. In according with the common idea we define {@link AlgorithmSpecificDatasetExample.AlgorithmSpecificDataset}
- * - extended version of {@code Dataset} with {@code gradient} method. As a result our gradient descent method looks
- * like a simple loop where every iteration includes call of the {@code gradient} method. In the example we want to keep
- * iteration number as well for logging. Iteration number cannot be recovered from the {@code upstream} data and we need
- * to keep it in the custom partition {@code context} which is represented by {@link
- * AlgorithmSpecificDatasetExample.AlgorithmSpecificPartitionContext} class.</p>
- */
-public class AlgorithmSpecificDatasetExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Algorithm Specific Dataset example started.");
-
- IgniteCache<Integer, Vector> persons = null;
- try {
- persons = createCache(ignite);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<>(1);
-
- IgniteFunction<LabeledVector<Double>, LabeledVector<double[]>> func =
- lv -> new LabeledVector<>(lv.features(), new double[] {lv.label()});
-
- //NOTE: This class is part of Developer API and all lambdas should be loaded on server manually.
- Preprocessor<Integer, Vector> preprocessor = new PatchedPreprocessor<>(func, vectorizer);
- // Creates a algorithm specific dataset to perform linear regression. Here we define the way features and
- // labels are extracted, and partition data and context are created.
- SimpleLabeledDatasetDataBuilder<Integer, Vector, AlgorithmSpecificPartitionContext> builder =
- new SimpleLabeledDatasetDataBuilder<>(preprocessor);
-
- IgniteBiFunction<SimpleLabeledDatasetData, AlgorithmSpecificPartitionContext, SimpleLabeledDatasetData> builderFun =
- (data, ctx) -> {
- double[] features = data.getFeatures();
- int rows = data.getRows();
-
- // Makes a copy of features to supplement it by columns with values equal to 1.0.
- double[] a = new double[features.length + rows];
- Arrays.fill(a, 1.0);
-
- System.arraycopy(features, 0, a, rows, features.length);
-
- return new SimpleLabeledDatasetData(a, data.getLabels(), rows);
- };
-
- try (AlgorithmSpecificDataset dataset = DatasetFactory.create(
- ignite,
- persons,
- (env, upstream, upstreamSize) -> new AlgorithmSpecificPartitionContext(),
- builder.andThen(builderFun)
- ).wrap(AlgorithmSpecificDataset::new)) {
- // Trains linear regression model using gradient descent.
- double[] linearRegressionMdl = new double[2];
-
- for (int i = 0; i < 1000; i++) {
- double[] gradient = dataset.gradient(linearRegressionMdl);
-
- if (BLAS.getInstance().dnrm2(gradient.length, gradient, 1) < 1e-4)
- break;
-
- for (int j = 0; j < gradient.length; j++)
- linearRegressionMdl[j] -= 0.1 / persons.size() * gradient[j];
- }
-
- System.out.println("Linear Regression Model: " + Arrays.toString(linearRegressionMdl));
- }
-
- System.out.println(">>> Algorithm Specific Dataset example completed.");
- }
- finally {
- persons.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Algorithm specific dataset. Extended version of {@code Dataset} with {@code gradient} method.
- */
- private static class AlgorithmSpecificDataset
- extends DatasetWrapper<AlgorithmSpecificPartitionContext, SimpleLabeledDatasetData> {
- /**
- * BLAS (Basic Linear Algebra Subprograms) instance.
- */
- private static final BLAS blas = BLAS.getInstance();
-
- /**
- * Constructs a new instance of dataset wrapper that delegates {@code compute} actions to the actual delegate.
- *
- * @param delegate Delegate that performs {@code compute} actions.
- */
- AlgorithmSpecificDataset(
- Dataset<AlgorithmSpecificPartitionContext, SimpleLabeledDatasetData> delegate) {
- super(delegate);
- }
-
- /**
- * Calculate gradient.
- */
- double[] gradient(double[] x) {
- return computeWithCtx((ctx, data, partIdx) -> {
- double[] tmp = Arrays.copyOf(data.getLabels(), data.getRows());
- int featureCols = data.getFeatures().length / data.getRows();
- blas.dgemv("N", data.getRows(), featureCols, 1.0, data.getFeatures(),
- Math.max(1, data.getRows()), x, 1, -1.0, tmp, 1);
-
- double[] res = new double[featureCols];
- blas.dgemv("T", data.getRows(), featureCols, 1.0, data.getFeatures(),
- Math.max(1, data.getRows()), tmp, 1, 0.0, res, 1);
-
- int iteration = ctx.getIteration();
-
- System.out.println("Iteration " + iteration + " on partition " + partIdx
- + " completed with local result " + Arrays.toString(res));
-
- ctx.setIteration(iteration + 1);
-
- return res;
- }, this::sum);
- }
-
- /**
- * Sum of two vectors.
- */
- public double[] sum(double[] a, double[] b) {
- if (a == null)
- return b;
-
- if (b == null)
- return a;
-
- blas.daxpy(a.length, 1.0, a, 1, b, 1);
-
- return b;
- }
- }
-
- /**
- * Algorithm specific partition context which keeps iteration number.
- */
- private static class AlgorithmSpecificPartitionContext implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 1887368924266684044L;
-
- /**
- * Iteration number.
- */
- private int iteration;
-
- /**
- *
- */
- int getIteration() {
- return iteration;
- }
-
- /**
- *
- */
- void setIteration(int iteration) {
- this.iteration = iteration;
- }
- }
-
- /**
- *
- */
- private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
- CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
-
- persons.put(1, new DenseVector(new Serializable[] {"Mike", 42, 10000}));
- persons.put(2, new DenseVector(new Serializable[] {"John", 32, 64000}));
- persons.put(3, new DenseVector(new Serializable[] {"George", 53, 120000}));
- persons.put(4, new DenseVector(new Serializable[] {"Karl", 24, 70000}));
-
- return persons;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/CacheBasedDatasetExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/dataset/CacheBasedDatasetExample.java
deleted file mode 100644
index b2cdc545ff8..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/CacheBasedDatasetExample.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.dataset;
-
-import java.io.Serializable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.DatasetHelper;
-import org.apache.ignite.ml.dataset.DatasetFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.dataset.primitive.SimpleDataset;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-
-/**
- * Example that shows how to create dataset based on an existing Ignite Cache and then use it to calculate {@code mean}
- * and {@code std} values as well as {@code covariance} and {@code correlation} matrices.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it creates the dataset based on the data in the cache and uses Dataset API to find and output various
- * statistical metrics of the data.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this functionality further.</p>
- */
-public class CacheBasedDatasetExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Cache Based Dataset example started.");
-
- IgniteCache<Integer, Vector> persons = null;
- try {
- persons = createCache(ignite);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<>(1, 2);
-
- // Creates a cache based simple dataset containing features and providing standard dataset API.
- try (SimpleDataset<?> dataset = DatasetFactory.createSimpleDataset(
- ignite,
- persons,
- vectorizer
- )) {
- new DatasetHelper(dataset).describe();
- }
-
- System.out.println(">>> Cache Based Dataset example completed.");
- }
- finally {
- persons.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- *
- */
- private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
- CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
-
- persons.put(1, new DenseVector(new Serializable[] {"Mike", 42, 10000}));
- persons.put(2, new DenseVector(new Serializable[] {"John", 32, 64000}));
- persons.put(3, new DenseVector(new Serializable[] {"George", 53, 120000}));
- persons.put(4, new DenseVector(new Serializable[] {"Karl", 24, 70000}));
-
- return persons;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/model/Person.java b/examples/src/main/java/org/apache/ignite/examples/ml/dataset/model/Person.java
deleted file mode 100644
index 84b90ae5b38..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/model/Person.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.dataset.model;
-
-/**
- * Person model.
- */
-public class Person {
- /**
- * Name.
- */
- private final String name;
-
- /**
- * Age.
- */
- private final double age;
-
- /**
- * Salary.
- */
- private final double salary;
-
- /**
- * Constructs a new instance of person.
- *
- * @param name Name.
- * @param age Age.
- * @param salary Salary.
- */
- public Person(String name, double age, double salary) {
- this.name = name;
- this.age = age;
- this.salary = salary;
- }
-
- /**
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- *
- */
- public double getAge() {
- return age;
- }
-
- /**
- *
- */
- public double getSalary() {
- return salary;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/model/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/dataset/model/package-info.java
deleted file mode 100644
index 27491c977a2..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/model/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Models used in machine learning dataset examples.
- */
-
-package org.apache.ignite.examples.ml.dataset.model;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/dataset/package-info.java
deleted file mode 100644
index a6bceb48c30..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/dataset/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Machine learning dataset examples.
- */
-
-package org.apache.ignite.examples.ml.dataset;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/environment/TrainingWithCustomPreprocessorsExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/environment/TrainingWithCustomPreprocessorsExample.java
deleted file mode 100644
index 878fe3c29b3..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/environment/TrainingWithCustomPreprocessorsExample.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.environment;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.DatasetBuilder;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-import org.apache.ignite.ml.pipeline.Pipeline;
-import org.apache.ignite.ml.pipeline.PipelineMdl;
-import org.apache.ignite.ml.preprocessing.PreprocessingTrainer;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.imputing.ImputerTrainer;
-import org.apache.ignite.ml.preprocessing.minmaxscaling.MinMaxScalerTrainer;
-import org.apache.ignite.ml.preprocessing.normalization.NormalizationTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-import org.apache.ignite.ml.structures.LabeledVector;
-import org.apache.ignite.ml.tree.DecisionTreeClassificationTrainer;
-
-/**
- * This example demonstrates an ability of using custom client classes in cluster in case of absence of these classes on
- * server nodes. Preprocessors (see {@link Preprocessor}, preprocessor trainers (see {@link PreprocessingTrainer} and
- * vectorizers (see {@link Vectorizer}) can be defined in client code and deployed to server nodes during training
- * phase.
- * <p>
- * For demonstrating of deployment abilities of ml-related classes you can run this example with binary build. NOTE:
- * This binary build should be run with copied basic ml libs from optional directory (ignite-ml at least).
- */
-public class TrainingWithCustomPreprocessorsExample {
- /**
- * Run example.
- *
- * @param args Command line arguments.
- * @throws Exception Exception.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- IgniteCache<Integer, Vector> trainingSet = null;
- try {
- trainingSet = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.BOSTON_HOUSE_PRICES);
-
- Vectorizer<Integer, Vector, Integer, Double> basicVectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- Preprocessor<Integer, Vector> imputingPreprocessor = new ImputerTrainer<Integer, Vector>()
- .fit(ignite, trainingSet, basicVectorizer);
-
- // In-place definition of custom preprocessor by lambda expression.
- Preprocessor<Integer, Vector> customPreprocessor = (k, v) -> {
- LabeledVector res = imputingPreprocessor.apply(k, v);
- double fifthFeature = res.features().get(5);
-
- Vector updatedVector = res.features().set(5, fifthFeature > 0 ? Math.log(fifthFeature) : -1);
- return updatedVector.labeled(res.label());
- };
-
- Vectorizer9000 customVectorizer = new Vectorizer9000(customPreprocessor);
-
- PipelineMdl<Integer, Vector> mdl = new Pipeline<Integer, Vector, Integer, Double>()
- .addVectorizer(customVectorizer)
- .addPreprocessingTrainer(new MinMaxScalerTrainer<Integer, Vector>())
- .addPreprocessingTrainer(new NormalizationTrainer<Integer, Vector>().withP(1))
- .addPreprocessingTrainer(getCustomTrainer())
- .addTrainer(new DecisionTreeClassificationTrainer(5, 0))
- .fit(ignite, trainingSet);
-
- System.out.println(">>> Perform scoring.");
- double score = Evaluator.evaluate(trainingSet,
- mdl, mdl.getPreprocessor(), MetricName.R2
- );
-
- System.out.println(">>> R^2 score: " + score);
- }
- finally {
- if (trainingSet != null)
- trainingSet.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Custom trainer for preprocessor. This trainer just returns custom preprocessor based on given preprocessor. Such
- * trainers could be used for injecting custom preprocessors to Pipelines.
- *
- * @return Trainer for preprocessor that normalizes given vectors.
- */
- private static PreprocessingTrainer<Integer, Vector> getCustomTrainer() {
- return new PreprocessingTrainer<Integer, Vector>() {
- @Override public Preprocessor<Integer, Vector> fit(LearningEnvironmentBuilder envBuilder,
- DatasetBuilder<Integer, Vector> datasetBuilder,
- Preprocessor<Integer, Vector> basePreprocessor) {
- return (k, v) -> {
- LabeledVector res = basePreprocessor.apply(k, v);
- return res.features().normalize().labeled(res.label());
- };
- }
- };
- }
-
- /**
- * Custom vectorizer based on preprocessor. This vectorizer extends given vectors by values equal to log(feature)
- * for each feature in vector.
- */
- private static class Vectorizer9000 extends Vectorizer.VectorizerAdapter<Integer, Vector, Integer, Double> {
- /**
- * Base preprocessor.
- */
- private final Preprocessor<Integer, Vector> basePreprocessor;
-
- /**
- * Creates an instance of vectorizer.
- *
- * @param basePreprocessor Base preprocessor.
- */
- public Vectorizer9000(Preprocessor<Integer, Vector> basePreprocessor) {
- this.basePreprocessor = basePreprocessor;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public LabeledVector<Double> apply(Integer key, Vector val) {
- LabeledVector<Double> baseVec = basePreprocessor.apply(key, val);
- double[] features = new double[baseVec.size() * 2];
- for (int i = 0; i < baseVec.size(); i++) {
- features[i] = baseVec.get(i);
- double logVal = Math.log(baseVec.get(i));
- features[i + baseVec.size()] = Double.isInfinite(logVal) || Double.isNaN(logVal) ? -1. : logVal;
- }
-
- return VectorUtils.of(features).labeled(baseVec.label());
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/environment/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/environment/package-info.java
deleted file mode 100644
index 93e18b8b4dc..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/environment/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> This package contains examples of learning environment features.
- */
-package org.apache.ignite.examples.ml.environment;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/IgniteModelDistributedInferenceExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/IgniteModelDistributedInferenceExample.java
deleted file mode 100644
index deb7de23c99..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/IgniteModelDistributedInferenceExample.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.regression.linear.LinearRegressionLSQRTrainerExample;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.inference.Model;
-import org.apache.ignite.ml.inference.builder.IgniteDistributedModelBuilder;
-import org.apache.ignite.ml.inference.parser.IgniteModelParser;
-import org.apache.ignite.ml.inference.parser.ModelParser;
-import org.apache.ignite.ml.inference.reader.InMemoryModelReader;
-import org.apache.ignite.ml.inference.reader.ModelReader;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionLSQRTrainer;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
-
-/**
- * This example is based on {@link LinearRegressionLSQRTrainerExample}, but to perform inference it uses an approach
- * implemented in {@link org.apache.ignite.ml.inference} package.
- */
-public class IgniteModelDistributedInferenceExample {
- /**
- * Run example.
- */
- public static void main(String... args) throws IOException, ExecutionException, InterruptedException {
- System.out.println();
- System.out.println(">>> Linear regression model over cache based dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.MORTALITY_DATA);
-
- System.out.println(">>> Create new linear regression trainer object.");
- LinearRegressionLSQRTrainer trainer = new LinearRegressionLSQRTrainer();
-
- System.out.println(">>> Perform the training to get the model.");
- LinearRegressionModel mdl = trainer.fit(
- ignite,
- dataCache,
- new DummyVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST)
- );
-
- System.out.println(">>> Linear regression model: " + mdl);
-
- System.out.println(">>> Preparing model reader and model parser.");
- ModelReader reader = new InMemoryModelReader(mdl);
- ModelParser<Vector, Double, ?> parser = new IgniteModelParser<>();
- try (Model<Vector, Future<Double>> infMdl = new IgniteDistributedModelBuilder(ignite, 4, 4)
- .build(reader, parser)) {
- System.out.println(">>> Inference model is ready.");
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- Vector val = observation.getValue();
- Vector inputs = val.copyOfRange(1, val.size());
- double groundTruth = val.get(0);
-
- double prediction = infMdl.predict(inputs).get();
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
- }
- }
-
- System.out.println(">>> ---------------------------------");
-
- System.out.println(">>> Linear regression model over cache based dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/ModelStorageExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/ModelStorageExample.java
deleted file mode 100644
index 37c52918c6e..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/ModelStorageExample.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.ml.IgniteModel;
-import org.apache.ignite.ml.inference.Model;
-import org.apache.ignite.ml.inference.ModelDescriptor;
-import org.apache.ignite.ml.inference.ModelSignature;
-import org.apache.ignite.ml.inference.builder.SingleModelBuilder;
-import org.apache.ignite.ml.inference.parser.IgniteModelParser;
-import org.apache.ignite.ml.inference.reader.ModelStorageModelReader;
-import org.apache.ignite.ml.inference.storage.descriptor.ModelDescriptorStorage;
-import org.apache.ignite.ml.inference.storage.descriptor.ModelDescriptorStorageFactory;
-import org.apache.ignite.ml.inference.storage.model.ModelStorage;
-import org.apache.ignite.ml.inference.storage.model.ModelStorageFactory;
-
-/**
- * This example demonstrates how to work with {@link ModelStorage}.
- */
-public class ModelStorageExample {
- /**
- * Run example.
- */
- public static void main(String... args) throws IOException, ClassNotFoundException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite-ml.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- ModelStorage storage = new ModelStorageFactory().getModelStorage(ignite);
- ModelDescriptorStorage descStorage = new ModelDescriptorStorageFactory().getModelDescriptorStorage(ignite);
-
- System.out.println("Saving model into model storage...");
- byte[] mdl = serialize((IgniteModel<byte[], byte[]>)i -> i);
- storage.mkdirs("/");
- storage.putFile("/my_model", mdl);
-
- System.out.println("Saving model descriptor into model descriptor storage...");
- ModelDescriptor desc = new ModelDescriptor(
- "MyModel",
- "My Cool Model",
- new ModelSignature("", "", ""),
- new ModelStorageModelReader("/my_model"),
- new IgniteModelParser<>()
- );
- descStorage.put("my_model", desc);
-
- System.out.println("List saved models...");
- for (IgniteBiTuple<String, ModelDescriptor> model : descStorage)
- System.out.println("-> {'" + model.getKey() + "' : " + model.getValue() + "}");
-
- System.out.println("Load saved model descriptor...");
- desc = descStorage.get("my_model");
-
- System.out.println("Build inference model...");
- SingleModelBuilder mdlBuilder = new SingleModelBuilder();
- try (Model<byte[], byte[]> infMdl = mdlBuilder.build(desc.getReader(), desc.getParser())) {
-
- System.out.println("Make inference...");
- for (int i = 0; i < 10; i++) {
- Integer res = deserialize(infMdl.predict(serialize(i)));
- System.out.println(i + " -> " + res);
- }
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Serialized the specified object.
- *
- * @param o Object to be serialized.
- * @return Serialized object as byte array.
- * @throws IOException In case of exception.
- */
- private static <T extends Serializable> byte[] serialize(T o) throws IOException {
- try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos)) {
- oos.writeObject(o);
- oos.flush();
-
- return baos.toByteArray();
- }
- }
-
- /**
- * Deserialized object represented as a byte array.
- *
- * @param o Serialized object.
- * @param <T> Type of serialized object.
- * @return Deserialized object.
- * @throws IOException In case of exception.
- * @throws ClassNotFoundException In case of exception.
- */
- @SuppressWarnings("unchecked")
- private static <T extends Serializable> T deserialize(byte[] o) throws IOException, ClassNotFoundException {
- try (ByteArrayInputStream bais = new ByteArrayInputStream(o);
- ObjectInputStream ois = new ObjectInputStream(bais)) {
-
- return (T)ois.readObject();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/CatboostClassificationModelParserExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/CatboostClassificationModelParserExample.java
deleted file mode 100644
index ecf73f4473d..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/CatboostClassificationModelParserExample.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.catboost;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Scanner;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.ml.catboost.CatboostClassificationModelParser;
-import org.apache.ignite.ml.inference.Model;
-import org.apache.ignite.ml.inference.builder.AsyncModelBuilder;
-import org.apache.ignite.ml.inference.builder.IgniteDistributedModelBuilder;
-import org.apache.ignite.ml.inference.reader.FileSystemModelReader;
-import org.apache.ignite.ml.inference.reader.ModelReader;
-import org.apache.ignite.ml.math.primitives.vector.NamedVector;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-
-/**
- * This example demonstrates how to import Catboost model and use imported model for distributed inference in Apache
- * Ignite.
- */
-public class CatboostClassificationModelParserExample {
- /**
- * Test model resource name.
- */
- private static final String TEST_MODEL_RES = "examples/src/main/resources/models/catboost/model_clf.cbm";
-
- /**
- * Test data.
- */
- private static final String TEST_DATA_RES = "examples/src/main/resources/datasets/amazon-employee-access-challenge-sample.csv";
-
- /**
- * Test expected results.
- */
- private static final String TEST_ER_RES =
- "examples/src/main/resources/datasets/amazon-employee-access-challenge-sample-catboost-expected-results.csv";
-
- /**
- * Parser.
- */
- private static final CatboostClassificationModelParser parser = new CatboostClassificationModelParser();
-
- /**
- * Run example.
- */
- public static void main(String... args) throws ExecutionException, InterruptedException,
- FileNotFoundException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- File mdlRsrc = IgniteUtils.resolveIgnitePath(TEST_MODEL_RES);
- if (mdlRsrc == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_MODEL_RES + "]");
-
- ModelReader reader = new FileSystemModelReader(mdlRsrc.getPath());
-
- AsyncModelBuilder mdlBuilder = new IgniteDistributedModelBuilder(ignite, 4, 4);
-
- File testData = IgniteUtils.resolveIgnitePath(TEST_DATA_RES);
- if (testData == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_DATA_RES + "]");
-
- File testExpRes = IgniteUtils.resolveIgnitePath(TEST_ER_RES);
- if (testExpRes == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_ER_RES + "]");
-
- try (Model<NamedVector, Future<Double>> mdl = mdlBuilder.build(reader, parser);
- Scanner testDataScanner = new Scanner(testData);
- Scanner testExpResultsScanner = new Scanner(testExpRes)) {
- String header = testDataScanner.nextLine();
- String[] columns = header.split(",");
-
- while (testDataScanner.hasNextLine()) {
- String testDataStr = testDataScanner.nextLine();
- String testExpResultsStr = testExpResultsScanner.nextLine();
-
- HashMap<String, Double> testObj = new HashMap<>();
- String[] values = testDataStr.split(",");
-
- for (int i = 0; i < columns.length; i++) {
- testObj.put(columns[i], Double.valueOf(values[i]));
- }
-
- double prediction = mdl.predict(VectorUtils.of(testObj)).get();
- double expPrediction = Double.parseDouble(testExpResultsStr);
-
- System.out.println("Expected: " + expPrediction + ", prediction: " + prediction);
- }
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/CatboostRegressionModelParserExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/CatboostRegressionModelParserExample.java
deleted file mode 100644
index ac1f979bbe8..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/CatboostRegressionModelParserExample.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.catboost;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Scanner;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.ml.catboost.CatboostRegressionModelParser;
-import org.apache.ignite.ml.inference.Model;
-import org.apache.ignite.ml.inference.builder.AsyncModelBuilder;
-import org.apache.ignite.ml.inference.builder.IgniteDistributedModelBuilder;
-import org.apache.ignite.ml.inference.reader.FileSystemModelReader;
-import org.apache.ignite.ml.inference.reader.ModelReader;
-import org.apache.ignite.ml.math.primitives.vector.NamedVector;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-
-/**
- * This example demonstrates how to import Catboost model and use imported model for distributed inference in Apache
- * Ignite.
- */
-public class CatboostRegressionModelParserExample {
- /**
- * Test model resource name.
- * */
- private static final String TEST_MODEL_RES = "examples/src/main/resources/models/catboost/model_reg.cbm";
-
- /**
- * Test data.
- */
- private static final String TEST_DATA_RES = "examples/src/main/resources/datasets/boston_housing_dataset.txt";
-
- /**
- * Test expected results.
- */
- private static final String TEST_ER_RES = "examples/src/main/resources/datasets/boston_housing_dataset-catboost-expected-results.txt";
-
- /**
- * Parser.
- */
- private static final CatboostRegressionModelParser parser = new CatboostRegressionModelParser();
-
- /**
- * Run example.
- */
- public static void main(String... args) throws ExecutionException, InterruptedException,
- FileNotFoundException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- File mdlRsrc = IgniteUtils.resolveIgnitePath(TEST_MODEL_RES);
- if (mdlRsrc == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_MODEL_RES + "]");
-
- ModelReader reader = new FileSystemModelReader(mdlRsrc.getPath());
- AsyncModelBuilder mdlBuilder = new IgniteDistributedModelBuilder(ignite, 4, 4);
-
- File testData = IgniteUtils.resolveIgnitePath(TEST_DATA_RES);
- if (testData == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_DATA_RES + "]");
-
- File testExpRes = IgniteUtils.resolveIgnitePath(TEST_ER_RES);
- if (testExpRes == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_ER_RES + "]");
-
- try (Model<NamedVector, Future<Double>> mdl = mdlBuilder.build(reader, parser);
- Scanner testDataScanner = new Scanner(testData);
- Scanner testExpResultsScanner = new Scanner(testExpRes)) {
- String[] columns = new String[] {
- "f_0",
- "f_1",
- "f_2",
- "f_3",
- "f_4",
- "f_5",
- "f_6",
- "f_7",
- "f_8",
- "f_9",
- "f_10",
- "f_11",
- "f_12",
- };
-
- while (testDataScanner.hasNextLine()) {
- String testDataStr = testDataScanner.nextLine();
- String testExpResultsStr = testExpResultsScanner.nextLine();
-
- HashMap<String, Double> testObj = new HashMap<>();
- String[] values = testDataStr.split(",");
-
- for (int i = 0; i < columns.length; i++) {
- testObj.put(columns[i], Double.valueOf(values[i]));
- }
-
- double prediction = mdl.predict(VectorUtils.of(testObj)).get();
- double expPrediction = Double.parseDouble(testExpResultsStr);
-
- System.out.println("Expected: " + expPrediction + ", prediction: " + prediction);
- }
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/package-info.java
deleted file mode 100644
index 70bbbd2b8b9..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/catboost/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> XGBoost model inference examples.
- */
-
-package org.apache.ignite.examples.ml.inference.catboost;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/ANNClassificationExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/ANNClassificationExportImportExample.java
deleted file mode 100644
index 516dbb16ac2..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/ANNClassificationExportImportExample.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.UUID;
-import javax.cache.Cache;
-import org.apache.commons.math3.util.Precision;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DoubleArrayVectorizer;
-import org.apache.ignite.ml.knn.NNClassificationModel;
-import org.apache.ignite.ml.knn.ann.ANNClassificationModel;
-import org.apache.ignite.ml.knn.ann.ANNClassificationTrainer;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.distances.ManhattanDistance;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-
-/**
- * Run ANN multi-class classification trainer ({@link ANNClassificationTrainer}) over distributed dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the model based on the specified data using
- * <a href="https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm">kNN</a> algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict what cluster does
- * this point belong to, and compares prediction to expected outcome (ground truth).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class ANNClassificationExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> ANN multi-class classification algorithm over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, double[]> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = getTestCache(ignite);
-
- ANNClassificationTrainer trainer = new ANNClassificationTrainer()
- .withDistance(new ManhattanDistance())
- .withK(50)
- .withMaxIterations(1000)
- .withEpsilon(1e-2);
-
- ANNClassificationModel mdl = (ANNClassificationModel)trainer.fit(
- ignite,
- dataCache,
- new DoubleArrayVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST)
- ).withK(5)
- .withDistanceMeasure(new EuclideanDistance())
- .withWeighted(true);
-
- System.out.println("\n>>> Exported ANN model: " + mdl.toString(true));
-
- double accuracy = evaluateModel(dataCache, mdl);
-
- System.out.println("\n>>> Accuracy for exported ANN model:" + accuracy);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- ANNClassificationModel modelImportedFromJSON = ANNClassificationModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported ANN model: " + modelImportedFromJSON.toString(true));
-
- accuracy = evaluateModel(dataCache, modelImportedFromJSON);
-
- System.out.println("\n>>> Accuracy for imported ANN model:" + accuracy);
-
- System.out.println(">>> ANN multi-class classification algorithm over cached dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /** */
- private static double evaluateModel(IgniteCache<Integer, double[]> dataCache, NNClassificationModel knnMdl) {
- int amountOfErrors = 0;
- int totalAmount = 0;
-
- double accuracy;
- try (QueryCursor<Cache.Entry<Integer, double[]>> observations = dataCache.query(new ScanQuery<>())) {
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
-
- for (Cache.Entry<Integer, double[]> observation : observations) {
- double[] val = observation.getValue();
- double[] inputs = Arrays.copyOfRange(val, 1, val.length);
- double groundTruth = val[0];
-
- double prediction = knnMdl.predict(new DenseVector(inputs));
-
- totalAmount++;
- if (!Precision.equals(groundTruth, prediction, Precision.EPSILON))
- amountOfErrors++;
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
-
- System.out.println(">>> ---------------------------------");
-
- accuracy = 1 - amountOfErrors / (double)totalAmount;
-
- }
- return accuracy;
- }
-
- /**
- * Fills cache with data and returns it.
- *
- * @param ignite Ignite instance.
- * @return Filled Ignite Cache.
- */
- private static IgniteCache<Integer, double[]> getTestCache(Ignite ignite) {
- CacheConfiguration<Integer, double[]> cacheConfiguration = new CacheConfiguration<>();
- cacheConfiguration.setName("TEST_" + UUID.randomUUID());
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- IgniteCache<Integer, double[]> cache = ignite.createCache(cacheConfiguration);
-
- for (int k = 0; k < 10; k++) { // multiplies the Iris dataset k times.
- for (int i = 0; i < data.length; i++)
- cache.put(k * 10000 + i, mutate(data[i], k));
- }
-
- return cache;
- }
-
- /**
- * Tiny changing of data depending on k parameter.
- *
- * @param datum The vector data.
- * @param k The passed parameter.
- * @return The changed vector data.
- */
- private static double[] mutate(double[] datum, int k) {
- for (int i = 0; i < datum.length; i++)
- datum[i] += k / 100000;
- return datum;
- }
-
- /**
- * The Iris dataset.
- */
- private static final double[][] data = {
- {1, 5.1, 3.5, 1.4, 0.2},
- {1, 4.9, 3, 1.4, 0.2},
- {1, 4.7, 3.2, 1.3, 0.2},
- {1, 4.6, 3.1, 1.5, 0.2},
- {1, 5, 3.6, 1.4, 0.2},
- {1, 5.4, 3.9, 1.7, 0.4},
- {1, 4.6, 3.4, 1.4, 0.3},
- {1, 5, 3.4, 1.5, 0.2},
- {1, 4.4, 2.9, 1.4, 0.2},
- {1, 4.9, 3.1, 1.5, 0.1},
- {1, 5.4, 3.7, 1.5, 0.2},
- {1, 4.8, 3.4, 1.6, 0.2},
- {1, 4.8, 3, 1.4, 0.1},
- {1, 4.3, 3, 1.1, 0.1},
- {1, 5.8, 4, 1.2, 0.2},
- {1, 5.7, 4.4, 1.5, 0.4},
- {1, 5.4, 3.9, 1.3, 0.4},
- {1, 5.1, 3.5, 1.4, 0.3},
- {1, 5.7, 3.8, 1.7, 0.3},
- {1, 5.1, 3.8, 1.5, 0.3},
- {1, 5.4, 3.4, 1.7, 0.2},
- {1, 5.1, 3.7, 1.5, 0.4},
- {1, 4.6, 3.6, 1, 0.2},
- {1, 5.1, 3.3, 1.7, 0.5},
- {1, 4.8, 3.4, 1.9, 0.2},
- {1, 5, 3, 1.6, 0.2},
- {1, 5, 3.4, 1.6, 0.4},
- {1, 5.2, 3.5, 1.5, 0.2},
- {1, 5.2, 3.4, 1.4, 0.2},
- {1, 4.7, 3.2, 1.6, 0.2},
- {1, 4.8, 3.1, 1.6, 0.2},
- {1, 5.4, 3.4, 1.5, 0.4},
- {1, 5.2, 4.1, 1.5, 0.1},
- {1, 5.5, 4.2, 1.4, 0.2},
- {1, 4.9, 3.1, 1.5, 0.1},
- {1, 5, 3.2, 1.2, 0.2},
- {1, 5.5, 3.5, 1.3, 0.2},
- {1, 4.9, 3.1, 1.5, 0.1},
- {1, 4.4, 3, 1.3, 0.2},
- {1, 5.1, 3.4, 1.5, 0.2},
- {1, 5, 3.5, 1.3, 0.3},
- {1, 4.5, 2.3, 1.3, 0.3},
- {1, 4.4, 3.2, 1.3, 0.2},
- {1, 5, 3.5, 1.6, 0.6},
- {1, 5.1, 3.8, 1.9, 0.4},
- {1, 4.8, 3, 1.4, 0.3},
- {1, 5.1, 3.8, 1.6, 0.2},
- {1, 4.6, 3.2, 1.4, 0.2},
- {1, 5.3, 3.7, 1.5, 0.2},
- {1, 5, 3.3, 1.4, 0.2},
- {2, 7, 3.2, 4.7, 1.4},
- {2, 6.4, 3.2, 4.5, 1.5},
- {2, 6.9, 3.1, 4.9, 1.5},
- {2, 5.5, 2.3, 4, 1.3},
- {2, 6.5, 2.8, 4.6, 1.5},
- {2, 5.7, 2.8, 4.5, 1.3},
- {2, 6.3, 3.3, 4.7, 1.6},
- {2, 4.9, 2.4, 3.3, 1},
- {2, 6.6, 2.9, 4.6, 1.3},
- {2, 5.2, 2.7, 3.9, 1.4},
- {2, 5, 2, 3.5, 1},
- {2, 5.9, 3, 4.2, 1.5},
- {2, 6, 2.2, 4, 1},
- {2, 6.1, 2.9, 4.7, 1.4},
- {2, 5.6, 2.9, 3.6, 1.3},
- {2, 6.7, 3.1, 4.4, 1.4},
- {2, 5.6, 3, 4.5, 1.5},
- {2, 5.8, 2.7, 4.1, 1},
- {2, 6.2, 2.2, 4.5, 1.5},
- {2, 5.6, 2.5, 3.9, 1.1},
- {2, 5.9, 3.2, 4.8, 1.8},
- {2, 6.1, 2.8, 4, 1.3},
- {2, 6.3, 2.5, 4.9, 1.5},
- {2, 6.1, 2.8, 4.7, 1.2},
- {2, 6.4, 2.9, 4.3, 1.3},
- {2, 6.6, 3, 4.4, 1.4},
- {2, 6.8, 2.8, 4.8, 1.4},
- {2, 6.7, 3, 5, 1.7},
- {2, 6, 2.9, 4.5, 1.5},
- {2, 5.7, 2.6, 3.5, 1},
- {2, 5.5, 2.4, 3.8, 1.1},
- {2, 5.5, 2.4, 3.7, 1},
- {2, 5.8, 2.7, 3.9, 1.2},
- {2, 6, 2.7, 5.1, 1.6},
- {2, 5.4, 3, 4.5, 1.5},
- {2, 6, 3.4, 4.5, 1.6},
- {2, 6.7, 3.1, 4.7, 1.5},
- {2, 6.3, 2.3, 4.4, 1.3},
- {2, 5.6, 3, 4.1, 1.3},
- {2, 5.5, 2.5, 4, 1.3},
- {2, 5.5, 2.6, 4.4, 1.2},
- {2, 6.1, 3, 4.6, 1.4},
- {2, 5.8, 2.6, 4, 1.2},
- {2, 5, 2.3, 3.3, 1},
- {2, 5.6, 2.7, 4.2, 1.3},
- {2, 5.7, 3, 4.2, 1.2},
- {2, 5.7, 2.9, 4.2, 1.3},
- {2, 6.2, 2.9, 4.3, 1.3},
- {2, 5.1, 2.5, 3, 1.1},
- {2, 5.7, 2.8, 4.1, 1.3},
- {3, 6.3, 3.3, 6, 2.5},
- {3, 5.8, 2.7, 5.1, 1.9},
- {3, 7.1, 3, 5.9, 2.1},
- {3, 6.3, 2.9, 5.6, 1.8},
- {3, 6.5, 3, 5.8, 2.2},
- {3, 7.6, 3, 6.6, 2.1},
- {3, 4.9, 2.5, 4.5, 1.7},
- {3, 7.3, 2.9, 6.3, 1.8},
- {3, 6.7, 2.5, 5.8, 1.8},
- {3, 7.2, 3.6, 6.1, 2.5},
- {3, 6.5, 3.2, 5.1, 2},
- {3, 6.4, 2.7, 5.3, 1.9},
- {3, 6.8, 3, 5.5, 2.1},
- {3, 5.7, 2.5, 5, 2},
- {3, 5.8, 2.8, 5.1, 2.4},
- {3, 6.4, 3.2, 5.3, 2.3},
- {3, 6.5, 3, 5.5, 1.8},
- {3, 7.7, 3.8, 6.7, 2.2},
- {3, 7.7, 2.6, 6.9, 2.3},
- {3, 6, 2.2, 5, 1.5},
- {3, 6.9, 3.2, 5.7, 2.3},
- {3, 5.6, 2.8, 4.9, 2},
- {3, 7.7, 2.8, 6.7, 2},
- {3, 6.3, 2.7, 4.9, 1.8},
- {3, 6.7, 3.3, 5.7, 2.1},
- {3, 7.2, 3.2, 6, 1.8},
- {3, 6.2, 2.8, 4.8, 1.8},
- {3, 6.1, 3, 4.9, 1.8},
- {3, 6.4, 2.8, 5.6, 2.1},
- {3, 7.2, 3, 5.8, 1.6},
- {3, 7.4, 2.8, 6.1, 1.9},
- {3, 7.9, 3.8, 6.4, 2},
- {3, 6.4, 2.8, 5.6, 2.2},
- {3, 6.3, 2.8, 5.1, 1.5},
- {3, 6.1, 2.6, 5.6, 1.4},
- {3, 7.7, 3, 6.1, 2.3},
- {3, 6.3, 3.4, 5.6, 2.4},
- {3, 6.4, 3.1, 5.5, 1.8},
- {3, 6, 3, 4.8, 1.8},
- {3, 6.9, 3.1, 5.4, 2.1},
- {3, 6.7, 3.1, 5.6, 2.4},
- {3, 6.9, 3.1, 5.1, 2.3},
- {3, 5.8, 2.7, 5.1, 1.9},
- {3, 6.8, 3.2, 5.9, 2.3},
- {3, 6.7, 3.3, 5.7, 2.5},
- {3, 6.7, 3, 5.2, 2.3},
- {3, 6.3, 2.5, 5, 1.9},
- {3, 6.5, 3, 5.2, 2},
- {3, 6.2, 3.4, 5.4, 2.3},
- {3, 5.9, 3, 5.1, 1.8}
- };
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/CompoundNaiveBayesExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/CompoundNaiveBayesExportImportExample.java
deleted file mode 100644
index 7d05f5e8212..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/CompoundNaiveBayesExportImportExample.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.naivebayes.compound.CompoundNaiveBayesModel;
-import org.apache.ignite.ml.naivebayes.compound.CompoundNaiveBayesTrainer;
-import org.apache.ignite.ml.naivebayes.discrete.DiscreteNaiveBayesTrainer;
-import org.apache.ignite.ml.naivebayes.gaussian.GaussianNaiveBayesTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-import static java.util.Arrays.asList;
-
-/**
- * Run naive Compound Bayes classification model based on <a href="https://en.wikipedia.org/wiki/Naive_Bayes_classifier">
- * Nnaive Bayes classifier</a> algorithm ({@link GaussianNaiveBayesTrainer})and <a
- * href=https://en.wikipedia.org/wiki/Naive_Bayes_classifier#Multinomial_naive_Bayes"> Discrete naive Bayes
- * classifier</a> algorithm ({@link DiscreteNaiveBayesTrainer}) over distributed cache.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points.
- * <p>
- * After that it trains the naive Bayes classification model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value,
- * compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class CompoundNaiveBayesExportImportExample {
- /** Run example. */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Compound Naive Bayes classification model over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite)
- .fillCacheWith(MLSandboxDatasets.MIXED_DATASET);
-
- double[] priorProbabilities = new double[]{.5, .5};
- double[][] thresholds = new double[][]{{.5}, {.5}, {.5}, {.5}, {.5}};
-
- System.out.println("\n>>> Create new naive Bayes classification trainer object.");
- CompoundNaiveBayesTrainer trainer = new CompoundNaiveBayesTrainer()
- .withPriorProbabilities(priorProbabilities)
- .withGaussianNaiveBayesTrainer(new GaussianNaiveBayesTrainer())
- .withGaussianFeatureIdsToSkip(asList(3, 4, 5, 6, 7))
- .withDiscreteNaiveBayesTrainer(new DiscreteNaiveBayesTrainer()
- .setBucketThresholds(thresholds))
- .withDiscreteFeatureIdsToSkip(asList(0, 1, 2));
- System.out.println("\n>>> Perform the training to get the model.");
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- CompoundNaiveBayesModel mdl = trainer.fit(ignite, dataCache, vectorizer);
-
- System.out.println("\n>>> Exported Compound Naive Bayes model: " + mdl.toString(true));
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for exported Compound Naive Bayes model:" + accuracy);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- CompoundNaiveBayesModel modelImportedFromJSON = CompoundNaiveBayesModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported Compound Naive Bayes model: " + modelImportedFromJSON.toString(true));
-
- accuracy = Evaluator.evaluate(
- dataCache,
- modelImportedFromJSON,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for imported Compound Naive Bayes model:" + accuracy);
-
- System.out.println("\n>>> Compound Naive Bayes model over partitioned dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DecisionTreeClassificationExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DecisionTreeClassificationExportImportExample.java
deleted file mode 100644
index a0ed9bfa4f6..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DecisionTreeClassificationExportImportExample.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Random;
-import org.apache.commons.math3.util.Precision;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.LabeledDummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-import org.apache.ignite.ml.structures.LabeledVector;
-import org.apache.ignite.ml.tree.DecisionTreeClassificationTrainer;
-import org.apache.ignite.ml.tree.DecisionTreeModel;
-
-/**
- * Example of using distributed {@link DecisionTreeClassificationTrainer}.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with pseudo random training data points.</p>
- * <p>
- * After that it creates classification trainer and uses it to train the model on the training set.</p>
- * <p>
- * Finally, this example loops over the pseudo randomly generated test set of data points, applies the trained model,
- * and compares prediction to expected outcome.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class DecisionTreeClassificationExportImportExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws IOException {
- System.out.println(">>> Decision tree classification trainer example started.");
-
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println("\n>>> Ignite grid started.");
-
- // Create cache with training data.
- CacheConfiguration<Integer, LabeledVector<Double>> trainingSetCfg = new CacheConfiguration<>();
- trainingSetCfg.setName("TRAINING_SET");
- trainingSetCfg.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- IgniteCache<Integer, LabeledVector<Double>> trainingSet = null;
- Path jsonMdlPath = null;
- try {
- trainingSet = ignite.createCache(trainingSetCfg);
-
- Random rnd = new Random(0);
-
- // Fill training data.
- for (int i = 0; i < 1000; i++)
- trainingSet.put(i, generatePoint(rnd));
-
- // Create classification trainer.
- DecisionTreeClassificationTrainer trainer = new DecisionTreeClassificationTrainer(4, 0);
-
- // Train decision tree model.
- LabeledDummyVectorizer<Integer, Double> vectorizer = new LabeledDummyVectorizer<>();
- DecisionTreeModel mdl = trainer.fit(
- ignite,
- trainingSet,
- vectorizer
- );
-
- System.out.println("\n>>> Exported Decision tree classification model: " + mdl);
-
- int correctPredictions = evaluateModel(rnd, mdl);
-
- System.out.println("\n>>> Accuracy for exported Decision tree classification model: " + correctPredictions / 10.0 + "%");
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- DecisionTreeModel modelImportedFromJSON = DecisionTreeModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported Decision tree classification model: " + modelImportedFromJSON);
-
- correctPredictions = evaluateModel(rnd, modelImportedFromJSON);
-
- System.out.println("\n>>> Accuracy for imported Decision tree classification model: " + correctPredictions / 10.0 + "%");
-
- System.out.println("\n>>> Decision tree classification trainer example completed.");
- }
- finally {
- if (trainingSet != null)
- trainingSet.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /** */
- private static int evaluateModel(Random rnd, DecisionTreeModel mdl) {
- // Calculate score.
- int correctPredictions = 0;
- for (int i = 0; i < 1000; i++) {
- LabeledVector<Double> pnt = generatePoint(rnd);
-
- double prediction = mdl.predict(pnt.features());
- double lbl = pnt.label();
-
- if (i % 50 == 1)
- System.out.printf(">>> test #: %d\t\t predicted: %.4f\t\tlabel: %.4f\n", i, prediction, lbl);
-
- if (Precision.equals(prediction, lbl, Precision.EPSILON))
- correctPredictions++;
- }
- return correctPredictions;
- }
-
- /**
- * Generate point with {@code x} in (-0.5, 0.5) and {@code y} in the same interval. If {@code x * y > 0} then label
- * is 1, otherwise 0.
- *
- * @param rnd Random.
- * @return Point with label.
- */
- private static LabeledVector<Double> generatePoint(Random rnd) {
-
- double x = rnd.nextDouble() - 0.5;
- double y = rnd.nextDouble() - 0.5;
-
- return new LabeledVector<>(VectorUtils.of(x, y), x * y > 0 ? 1. : 0.);
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DecisionTreeRegressionExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DecisionTreeRegressionExportImportExample.java
deleted file mode 100644
index 9857ba9edab..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DecisionTreeRegressionExportImportExample.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.LabeledDummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-import org.apache.ignite.ml.structures.LabeledVector;
-import org.apache.ignite.ml.tree.DecisionTreeModel;
-import org.apache.ignite.ml.tree.DecisionTreeRegressionTrainer;
-
-/**
- * Example of using distributed {@link DecisionTreeRegressionTrainer}.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with generated test data points ({@code sin(x)} on
- * interval {@code [0, 10)}).</p>
- * <p>
- * After that it creates classification trainer and uses it to train the model on the training set.</p>
- * <p>
- * Finally, this example loops over the test data points, applies the trained model, and compares prediction to expected
- * outcome (ground truth).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class DecisionTreeRegressionExportImportExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String... args) throws IOException {
- System.out.println(">>> Decision tree regression trainer example started.");
-
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println("\n>>> Ignite grid started.");
-
- // Create cache with training data.
- CacheConfiguration<Integer, LabeledVector<Double>> trainingSetCfg = new CacheConfiguration<>();
- trainingSetCfg.setName("TRAINING_SET");
- trainingSetCfg.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- IgniteCache<Integer, LabeledVector<Double>> trainingSet = null;
- Path jsonMdlPath = null;
- try {
- trainingSet = ignite.createCache(trainingSetCfg);
-
- // Fill training data.
- generatePoints(trainingSet);
-
- // Create regression trainer.
- DecisionTreeRegressionTrainer trainer = new DecisionTreeRegressionTrainer(10, 0);
-
- // Train decision tree model.
- DecisionTreeModel mdl = trainer.fit(ignite, trainingSet, new LabeledDummyVectorizer<>());
-
- System.out.println("\n>>> Exported Decision tree regression model: " + mdl);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- DecisionTreeModel modelImportedFromJSON = DecisionTreeModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported Decision tree regression model: " + modelImportedFromJSON);
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
-
- // Calculate score.
- for (int x = 0; x < 10; x++) {
- double predicted = mdl.predict(VectorUtils.of(x));
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", predicted, Math.sin(x));
- }
-
- System.out.println(">>> ---------------------------------");
-
- System.out.println("\n>>> Decision tree regression trainer example completed.");
- }
- finally {
- if (trainingSet != null)
- trainingSet.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Generates {@code sin(x)} on interval {@code [0, 10)} and loads into the specified cache.
- */
- private static void generatePoints(IgniteCache<Integer, LabeledVector<Double>> trainingSet) {
- for (int i = 0; i < 1000; i++) {
- double x = i / 100.0;
- double y = Math.sin(x);
-
- trainingSet.put(i, new LabeledVector<>(VectorUtils.of(x), y));
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DiscreteNaiveBayesExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DiscreteNaiveBayesExportImportExample.java
deleted file mode 100644
index c4d44c45684..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/DiscreteNaiveBayesExportImportExample.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.naivebayes.discrete.DiscreteNaiveBayesModel;
-import org.apache.ignite.ml.naivebayes.discrete.DiscreteNaiveBayesTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-/**
- * Run naive Bayes classification model based on <a href=https://en.wikipedia.org/wiki/Naive_Bayes_classifier#Multinomial_naive_Bayes">
- * naive Bayes classifier</a> algorithm ({@link DiscreteNaiveBayesTrainer}) over distributed cache.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points.
- * </p>
- * <p>
- * After that it trains the Discrete naive Bayes classification model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value,
- * compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class DiscreteNaiveBayesExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println(">>> Discrete naive Bayes classification model over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.ENGLISH_VS_SCOTTISH);
-
- double[][] thresholds = new double[][] {{.5}, {.5}, {.5}, {.5}, {.5}};
- System.out.println(">>> Create new Discrete naive Bayes classification trainer object.");
- DiscreteNaiveBayesTrainer trainer = new DiscreteNaiveBayesTrainer()
- .setBucketThresholds(thresholds);
-
- System.out.println("\n>>> Perform the training to get the model.");
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- DiscreteNaiveBayesModel mdl = trainer.fit(ignite, dataCache, vectorizer);
- System.out.println("\n>>> Exported Discrete Naive Bayes model: " + mdl.toString(true));
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for exported Discrete Naive Bayes model:" + accuracy);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- DiscreteNaiveBayesModel modelImportedFromJSON = DiscreteNaiveBayesModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported Discrete Naive Bayes model: " + modelImportedFromJSON.toString(true));
-
- accuracy = Evaluator.evaluate(
- dataCache,
- modelImportedFromJSON,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for imported Discrete Naive Bayes model:" + accuracy);
-
- System.out.println("\n>>> Discrete Naive bayes model over partitioned dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GDBOnTreesClassificationExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GDBOnTreesClassificationExportImportExample.java
deleted file mode 100644
index eedefbac4e6..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GDBOnTreesClassificationExportImportExample.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.composition.boosting.GDBModel;
-import org.apache.ignite.ml.composition.boosting.GDBTrainer;
-import org.apache.ignite.ml.composition.boosting.convergence.mean.MeanAbsValueConvergenceCheckerFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DoubleArrayVectorizer;
-import org.apache.ignite.ml.math.functions.IgniteFunction;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-import org.apache.ignite.ml.tree.boosting.GDBBinaryClassifierOnTreesTrainer;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Example represents a solution for the task of classification learning based on Gradient Boosting on trees
- * implementation. It shows an initialization of {@link GDBBinaryClassifierOnTreesTrainer}, initialization of Ignite
- * Cache, learning step and comparing of predicted and real values.
- * <p>
- * In this example dataset is created automatically by meander function {@code f(x) = [sin(x) > 0]}.</p>
- */
-public class GDBOnTreesClassificationExportImportExample {
- /**
- * Run example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> GDB classification trainer example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println("\n>>> Ignite grid started.");
-
- // Create cache with training data.
- CacheConfiguration<Integer, double[]> trainingSetCfg = createCacheConfiguration();
- IgniteCache<Integer, double[]> trainingSet = null;
- Path jsonMdlPath = null;
- try {
- trainingSet = fillTrainingData(ignite, trainingSetCfg);
-
- // Create classification trainer.
- GDBTrainer trainer = new GDBBinaryClassifierOnTreesTrainer(1.0, 300, 2, 0.)
- .withCheckConvergenceStgyFactory(new MeanAbsValueConvergenceCheckerFactory(0.1));
-
- // Train decision tree model.
- GDBModel mdl = trainer.fit(
- ignite,
- trainingSet,
- new DoubleArrayVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.LAST)
- );
-
- System.out.println("\n>>> Exported GDB classification model: " + mdl.toString(true));
-
- predictOnGeneratedData(mdl);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- IgniteFunction<Double, Double> lbMapper = lb -> lb > 0.5 ? 1.0 : 0.0;
- GDBModel modelImportedFromJSON = GDBModel.fromJSON(jsonMdlPath).withLblMapping(lbMapper);
-
- System.out.println("\n>>> Imported GDB classification model: " + modelImportedFromJSON.toString(true));
-
- predictOnGeneratedData(modelImportedFromJSON);
-
- System.out.println(">>> GDB classification trainer example completed.");
- }
- finally {
- if (trainingSet != null)
- trainingSet.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /** */
- private static void predictOnGeneratedData(GDBModel mdl) {
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Valid answer\t|");
- System.out.println(">>> ---------------------------------");
-
- // Calculate score.
- for (int x = -5; x < 5; x++) {
- double predicted = mdl.predict(VectorUtils.of(x));
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", predicted, Math.sin(x) < 0 ? 0.0 : 1.0);
- }
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> Count of trees = " + mdl.getModels().size());
- System.out.println(">>> ---------------------------------");
- }
-
- /**
- * Create cache configuration.
- */
- @NotNull private static CacheConfiguration<Integer, double[]> createCacheConfiguration() {
- CacheConfiguration<Integer, double[]> trainingSetCfg = new CacheConfiguration<>();
- trainingSetCfg.setName("TRAINING_SET");
- trainingSetCfg.setAffinity(new RendezvousAffinityFunction(false, 10));
- return trainingSetCfg;
- }
-
- /**
- * Fill meander-like training data.
- *
- * @param ignite Ignite instance.
- * @param trainingSetCfg Training set config.
- */
- @NotNull private static IgniteCache<Integer, double[]> fillTrainingData(Ignite ignite,
- CacheConfiguration<Integer, double[]> trainingSetCfg) {
- IgniteCache<Integer, double[]> trainingSet = ignite.getOrCreateCache(trainingSetCfg);
- for (int i = -50; i <= 50; i++) {
- double x = ((double)i) / 10.0;
- double y = Math.sin(x) < 0 ? 0.0 : 1.0;
- trainingSet.put(i, new double[] {x, y});
- }
- return trainingSet;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GDBOnTreesRegressionExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GDBOnTreesRegressionExportImportExample.java
deleted file mode 100644
index bddd4251229..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GDBOnTreesRegressionExportImportExample.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.composition.boosting.GDBModel;
-import org.apache.ignite.ml.composition.boosting.GDBTrainer;
-import org.apache.ignite.ml.composition.boosting.convergence.mean.MeanAbsValueConvergenceCheckerFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DoubleArrayVectorizer;
-import org.apache.ignite.ml.math.functions.IgniteFunction;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-import org.apache.ignite.ml.tree.boosting.GDBRegressionOnTreesTrainer;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Example represents a solution for the task of regression learning based on Gradient Boosting on trees implementation.
- * It shows an initialization of {@link GDBRegressionOnTreesTrainer}, initialization of Ignite Cache, learning step and
- * comparing of predicted and real values.
- * <p>
- * In this example dataset is created automatically by parabolic function {@code f(x) = x^2}.</p>
- */
-public class GDBOnTreesRegressionExportImportExample {
- /**
- * Run example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> GDB regression trainer example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- // Create cache with training data.
- CacheConfiguration<Integer, double[]> trainingSetCfg = createCacheConfiguration();
- IgniteCache<Integer, double[]> trainingSet = null;
- Path jsonMdlPath = null;
- try {
- trainingSet = fillTrainingData(ignite, trainingSetCfg);
-
- // Create regression trainer.
- GDBTrainer trainer = new GDBRegressionOnTreesTrainer(1.0, 2000, 1, 0.)
- .withCheckConvergenceStgyFactory(new MeanAbsValueConvergenceCheckerFactory(0.001));
-
- // Train decision tree model.
- GDBModel mdl = trainer.fit(
- ignite,
- trainingSet,
- new DoubleArrayVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.LAST)
- );
-
- System.out.println("\n>>> Exported GDB regression model: " + mdl.toString(true));
-
- predictOnGeneratedData(mdl);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- IgniteFunction<Double, Double> lbMapper = lb -> lb;
- GDBModel modelImportedFromJSON = GDBModel.fromJSON(jsonMdlPath).withLblMapping(lbMapper);
-
- System.out.println("\n>>> Imported GDB regression model: " + modelImportedFromJSON.toString(true));
-
- predictOnGeneratedData(modelImportedFromJSON);
-
- System.out.println(">>> GDB regression trainer example completed.");
- }
- finally {
- if (trainingSet != null)
- trainingSet.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /** */
- private static void predictOnGeneratedData(GDBModel mdl) {
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Valid answer \t|");
- System.out.println(">>> ---------------------------------");
-
- // Calculate score.
- for (int x = -5; x < 5; x++) {
- double predicted = mdl.predict(VectorUtils.of(x));
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", predicted, Math.pow(x, 2));
- }
-
- System.out.println(">>> ---------------------------------");
- }
-
- /**
- * Create cache configuration.
- */
- @NotNull private static CacheConfiguration<Integer, double[]> createCacheConfiguration() {
- CacheConfiguration<Integer, double[]> trainingSetCfg = new CacheConfiguration<>();
- trainingSetCfg.setName("TRAINING_SET");
- trainingSetCfg.setAffinity(new RendezvousAffinityFunction(false, 10));
- return trainingSetCfg;
- }
-
- /**
- * Fill parabolic training data.
- *
- * @param ignite Ignite instance.
- * @param trainingSetCfg Training set config.
- */
- @NotNull private static IgniteCache<Integer, double[]> fillTrainingData(Ignite ignite,
- CacheConfiguration<Integer, double[]> trainingSetCfg) {
- IgniteCache<Integer, double[]> trainingSet = ignite.getOrCreateCache(trainingSetCfg);
- for (int i = -50; i <= 50; i++) {
- double x = ((double)i) / 10.0;
- double y = Math.pow(x, 2);
- trainingSet.put(i, new double[] {x, y});
- }
- return trainingSet;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GaussianNaiveBayesExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GaussianNaiveBayesExportImportExample.java
deleted file mode 100644
index b6fb9c9fd20..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/GaussianNaiveBayesExportImportExample.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.naivebayes.gaussian.GaussianNaiveBayesModel;
-import org.apache.ignite.ml.naivebayes.gaussian.GaussianNaiveBayesTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-/**
- * Run naive Bayes classification model based on <a href="https://en.wikipedia.org/wiki/Naive_Bayes_classifier"> naive
- * Bayes classifier</a> algorithm ({@link GaussianNaiveBayesTrainer}) over distributed cache.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the naive Bayes classification model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value,
- * compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class GaussianNaiveBayesExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Naive Bayes classification model over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.TWO_CLASSED_IRIS);
-
- System.out.println(">>> Create new Gaussian Naive Bayes classification trainer object.");
- GaussianNaiveBayesTrainer trainer = new GaussianNaiveBayesTrainer();
-
- System.out.println("\n>>> Perform the training to get the model.");
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- GaussianNaiveBayesModel mdl = trainer.fit(ignite, dataCache, vectorizer);
- System.out.println("\n>>> Exported Gaussian Naive Bayes model: " + mdl.toString(true));
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for exported Gaussian Naive Bayes model:" + accuracy);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- GaussianNaiveBayesModel modelImportedFromJSON = GaussianNaiveBayesModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported Gaussian Naive Bayes model: " + modelImportedFromJSON.toString(true));
-
- accuracy = Evaluator.evaluate(
- dataCache,
- modelImportedFromJSON,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for imported Gaussian Naive Bayes model:" + accuracy);
-
- System.out.println("\n>>> Gaussian Naive bayes model over partitioned dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/KMeansClusterizationExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/KMeansClusterizationExportImportExample.java
deleted file mode 100644
index f841a06e593..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/KMeansClusterizationExportImportExample.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.clustering.kmeans.KMeansModel;
-import org.apache.ignite.ml.clustering.kmeans.KMeansTrainer;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.distances.WeightedMinkowskiDistance;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-
-/**
- * Run KMeans clustering algorithm ({@link KMeansTrainer}) over distributed dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the model based on the specified data using
- * <a href="https://en.wikipedia.org/wiki/K-means_clustering">KMeans</a> algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict what cluster does
- * this point belong to, and compares prediction to expected outcome (ground truth).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class KMeansClusterizationExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> KMeans clustering algorithm over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.TWO_CLASSED_IRIS);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer =
- new DummyVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST);
-
- KMeansTrainer trainer = new KMeansTrainer()
- .withDistance(new WeightedMinkowskiDistance(2, new double[] {5.9360, 2.7700, 4.2600, 1.3260}));
- //.withDistance(new MinkowskiDistance(2));
-
- KMeansModel mdl = trainer.fit(
- ignite,
- dataCache,
- vectorizer
- );
-
- System.out.println("\n>>> Exported KMeans model: " + mdl);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- KMeansModel modelImportedFromJSON = KMeansModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported KMeans model: " + modelImportedFromJSON);
-
- System.out.println("\n>>> KMeans clustering algorithm over cached dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/LinearRegressionExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/LinearRegressionExportImportExample.java
deleted file mode 100644
index 723784bb999..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/LinearRegressionExportImportExample.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionLSQRTrainer;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-/**
- * Run linear regression model based on <a href="http://web.stanford.edu/group/SOL/software/lsqr/">LSQR algorithm</a>
- * ({@link LinearRegressionLSQRTrainer}) over cached dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it trains the linear regression model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value
- * and compares prediction to expected outcome (ground truth).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class LinearRegressionExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Linear regression model over cache based dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.MORTALITY_DATA);
-
- System.out.println("\n>>> Create new linear regression trainer object.");
- LinearRegressionLSQRTrainer trainer = new LinearRegressionLSQRTrainer();
-
- System.out.println("\n>>> Perform the training to get the model.");
-
- LinearRegressionModel mdl = trainer.fit(
- ignite,
- dataCache,
- new DummyVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST)
- );
-
- System.out.println("\n>>> Exported LinearRegression model: " + mdl);
-
- double rmse = Evaluator.evaluate(
- dataCache,
- mdl,
- new DummyVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST),
- MetricName.RMSE
- );
-
- System.out.println("\n>>> RMSE for exported LinearRegression model: " + rmse);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- LinearRegressionModel modelImportedFromJSON = LinearRegressionModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported LinearRegression model: " + modelImportedFromJSON);
-
- rmse = Evaluator.evaluate(
- dataCache,
- mdl,
- new DummyVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST),
- MetricName.RMSE
- );
-
- System.out.println("\n>>> RMSE for imported LinearRegression model: " + rmse);
-
- System.out.println("\n>>> Linear regression model over cache based dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/LogisticRegressionExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/LogisticRegressionExportImportExample.java
deleted file mode 100644
index 6491f7edd5a..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/LogisticRegressionExportImportExample.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.nn.UpdatesStrategy;
-import org.apache.ignite.ml.optimization.updatecalculators.SimpleGDParameterUpdate;
-import org.apache.ignite.ml.optimization.updatecalculators.SimpleGDUpdateCalculator;
-import org.apache.ignite.ml.regressions.logistic.LogisticRegressionModel;
-import org.apache.ignite.ml.regressions.logistic.LogisticRegressionSGDTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-/**
- * Run logistic regression model based on <a href="https://en.wikipedia.org/wiki/Stochastic_gradient_descent">
- * stochastic gradient descent</a> algorithm ({@link LogisticRegressionSGDTrainer}) over distributed cache.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the logistic regression model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value,
- * compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class LogisticRegressionExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Logistic regression model over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println("\n>>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.TWO_CLASSED_IRIS);
-
- System.out.println("\n>>> Create new logistic regression trainer object.");
- LogisticRegressionSGDTrainer trainer = new LogisticRegressionSGDTrainer()
- .withUpdatesStgy(new UpdatesStrategy<>(
- new SimpleGDUpdateCalculator(0.2),
- SimpleGDParameterUpdate.SUM_LOCAL,
- SimpleGDParameterUpdate.AVG
- ))
- .withMaxIterations(100000)
- .withLocIterations(100)
- .withBatchSize(10)
- .withSeed(123L);
-
- System.out.println("\n>>> Perform the training to get the model.");
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- LogisticRegressionModel mdl = trainer.fit(ignite, dataCache, vectorizer);
-
- System.out.println("\n>>> Exported logistic regression model: " + mdl);
-
- double accuracy = Evaluator.evaluate(dataCache,
- mdl, vectorizer, MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for exported logistic regression model " + accuracy);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- LogisticRegressionModel modelImportedFromJSON = LogisticRegressionModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported logistic regression model: " + modelImportedFromJSON);
-
- accuracy = Evaluator.evaluate(dataCache,
- modelImportedFromJSON, vectorizer, MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for imported logistic regression model " + accuracy);
-
- System.out.println("\n>>> Logistic regression model over partitioned dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/RandomForestClassificationExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/RandomForestClassificationExportImportExample.java
deleted file mode 100644
index 2b8bf95e359..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/RandomForestClassificationExportImportExample.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import javax.cache.Cache;
-import org.apache.commons.math3.util.Precision;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.FeatureMeta;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.tree.randomforest.RandomForestClassifierTrainer;
-import org.apache.ignite.ml.tree.randomforest.RandomForestModel;
-import org.apache.ignite.ml.tree.randomforest.data.FeaturesCountSelectionStrategies;
-
-/**
- * Example represents a solution for the task of wine classification based on a
- * <a href ="https://en.wikipedia.org/wiki/Random_forest">Random Forest</a> implementation for
- * multi-classification.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://archive.ics.uci.edu/ml/machine-learning-databases/wine/">Wine recognition dataset</a>).</p>
- * <p>
- * After that it initializes the {@link RandomForestClassifierTrainer} with thread pool for multi-thread learning and
- * trains the model based on the specified data using random forest regression algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, compares prediction of the trained model to the
- * expected outcome (ground truth), and evaluates accuracy of the model.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class RandomForestClassificationExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Random Forest multi-class classification algorithm over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println("\n>>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.WINE_RECOGNITION);
-
- AtomicInteger idx = new AtomicInteger(0);
- RandomForestClassifierTrainer classifier = new RandomForestClassifierTrainer(
- IntStream.range(0, dataCache.get(1).size() - 1).mapToObj(
- x -> new FeatureMeta("", idx.getAndIncrement(), false)).collect(Collectors.toList())
- ).withAmountOfTrees(101)
- .withFeaturesCountSelectionStrgy(FeaturesCountSelectionStrategies.ONE_THIRD)
- .withMaxDepth(4)
- .withMinImpurityDelta(0.)
- .withSubSampleSize(0.3)
- .withSeed(0);
-
- System.out.println(">>> Configured trainer: " + classifier.getClass().getSimpleName());
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
- RandomForestModel mdl = classifier.fit(ignite, dataCache, vectorizer);
-
- System.out.println(">>> Exported Random Forest classification model: " + mdl.toString(true));
-
- double accuracy = evaluateModel(dataCache, mdl);
-
- System.out.println("\n>>> Accuracy for exported Random Forest classification model " + accuracy);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- RandomForestModel modelImportedFromJSON = RandomForestModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported Random Forest classification model: " + modelImportedFromJSON);
-
- accuracy = evaluateModel(dataCache, mdl);
-
- System.out.println("\n>>> Accuracy for imported Random Forest classification model " + accuracy);
-
- System.out.println("\n>>> Random Forest multi-class classification algorithm over cached dataset usage example completed.");
-
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /** */
- private static double evaluateModel(IgniteCache<Integer, Vector> dataCache, RandomForestModel randomForestMdl) {
- int amountOfErrors = 0;
- int totalAmount = 0;
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- Vector val = observation.getValue();
- Vector inputs = val.copyOfRange(1, val.size());
- double groundTruth = val.get(0);
-
- double prediction = randomForestMdl.predict(inputs);
-
- totalAmount++;
- if (!Precision.equals(groundTruth, prediction, Precision.EPSILON))
- amountOfErrors++;
- }
- }
-
- return 1 - amountOfErrors / (double)totalAmount;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/RandomForestRegressionExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/RandomForestRegressionExportImportExample.java
deleted file mode 100644
index 372ee67baba..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/RandomForestRegressionExportImportExample.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.FeatureMeta;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.tree.randomforest.RandomForestModel;
-import org.apache.ignite.ml.tree.randomforest.RandomForestRegressionTrainer;
-import org.apache.ignite.ml.tree.randomforest.data.FeaturesCountSelectionStrategies;
-
-/**
- * Example represents a solution for the task of price predictions for houses in Boston based on a
- * <a href ="https://en.wikipedia.org/wiki/Random_forest">Random Forest</a> implementation for regression.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://archive.ics.uci.edu/ml/machine-learning-databases/housing/">Boston Housing dataset</a>).</p>
- * <p>
- * After that it initializes the {@link RandomForestRegressionTrainer} and trains the model based on the specified data
- * using random forest regression algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, compares prediction of the trained model to the
- * expected outcome (ground truth), and evaluates model quality in terms of Mean Squared Error (MSE) and Mean Absolute
- * Error (MAE).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class RandomForestRegressionExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Random Forest regression algorithm over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println("\n>>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.BOSTON_HOUSE_PRICES);
-
- AtomicInteger idx = new AtomicInteger(0);
- RandomForestRegressionTrainer trainer = new RandomForestRegressionTrainer(
- IntStream.range(0, dataCache.get(1).size() - 1).mapToObj(
- x -> new FeatureMeta("", idx.getAndIncrement(), false)).collect(Collectors.toList())
- ).withAmountOfTrees(101)
- .withFeaturesCountSelectionStrgy(FeaturesCountSelectionStrategies.ONE_THIRD)
- .withMaxDepth(4)
- .withMinImpurityDelta(0.)
- .withSubSampleSize(0.3)
- .withSeed(0);
-
- trainer.withEnvironmentBuilder(LearningEnvironmentBuilder.defaultBuilder()
- .withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.LOW)
- );
-
- System.out.println("\n>>> Configured trainer: " + trainer.getClass().getSimpleName());
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
- RandomForestModel mdl = trainer.fit(ignite, dataCache, vectorizer);
-
- System.out.println("\n>>> Exported Random Forest regression model: " + mdl.toString(true));
-
- double mae = evaluateModel(dataCache, mdl);
-
- System.out.println("\n>>> Mean absolute error (MAE) for exported Random Forest regression model " + mae);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- RandomForestModel modelImportedFromJSON = RandomForestModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Exported Random Forest regression model: " + modelImportedFromJSON.toString(true));
-
- mae = evaluateModel(dataCache, modelImportedFromJSON);
-
- System.out.println("\n>>> Mean absolute error (MAE) for exported Random Forest regression model " + mae);
-
- System.out.println("\n>>> Random Forest regression algorithm over cached dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /** */
- private static double evaluateModel(IgniteCache<Integer, Vector> dataCache, RandomForestModel randomForestMdl) {
- double mae = 0.0;
- int totalAmount = 0;
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- Vector val = observation.getValue();
- Vector inputs = val.copyOfRange(1, val.size());
- double groundTruth = val.get(0);
-
- double prediction = randomForestMdl.predict(inputs);
-
- mae += Math.abs(prediction - groundTruth);
-
- totalAmount++;
- }
-
- mae /= totalAmount;
- }
- return mae;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/SVMExportImportExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/SVMExportImportExample.java
deleted file mode 100644
index 24262901b88..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/exchange/SVMExportImportExample.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.exchange;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-import org.apache.ignite.ml.svm.SVMLinearClassificationModel;
-import org.apache.ignite.ml.svm.SVMLinearClassificationTrainer;
-
-/**
- * Run SVM binary-class classification model ({@link SVMLinearClassificationModel}) over distributed dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the model based on the specified data using KMeans algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict what cluster does
- * this point belong to, compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class SVMExportImportExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> SVM Binary classification model over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println("\n>>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- Path jsonMdlPath = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.TWO_CLASSED_IRIS);
-
- SVMLinearClassificationTrainer trainer = new SVMLinearClassificationTrainer();
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- SVMLinearClassificationModel mdl = trainer.fit(ignite, dataCache, vectorizer);
-
- System.out.println("\n>>> Exported SVM model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for exported SVM model: " + accuracy);
-
- jsonMdlPath = Files.createTempFile(null, null);
- mdl.toJSON(jsonMdlPath);
-
- SVMLinearClassificationModel modelImportedFromJSON = SVMLinearClassificationModel.fromJSON(jsonMdlPath);
-
- System.out.println("\n>>> Imported SVM model: " + modelImportedFromJSON);
-
- accuracy = Evaluator.evaluate(
- dataCache,
- modelImportedFromJSON,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy for imported SVM model: " + accuracy);
-
- System.out.println("\n>>> SVM Binary classification model over cache based dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- if (jsonMdlPath != null)
- Files.deleteIfExists(jsonMdlPath);
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/h2o/H2OMojoModelParserExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/h2o/H2OMojoModelParserExample.java
deleted file mode 100644
index 2a046fdc381..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/h2o/H2OMojoModelParserExample.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.h2o;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Scanner;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.ml.h2o.H2OMojoModelParser;
-import org.apache.ignite.ml.inference.Model;
-import org.apache.ignite.ml.inference.builder.AsyncModelBuilder;
-import org.apache.ignite.ml.inference.builder.IgniteDistributedModelBuilder;
-import org.apache.ignite.ml.inference.reader.FileSystemModelReader;
-import org.apache.ignite.ml.inference.reader.ModelReader;
-import org.apache.ignite.ml.math.primitives.vector.NamedVector;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-
-/**
- * This example demonstrates how to import H2O MOJO model and use imported model for distributed inference in Apache
- * Ignite.
- */
-public class H2OMojoModelParserExample {
- /**
- * Test model resource name.
- */
- private static final String MODEL_RES = "examples/src/main/resources/models/h2o/agaricus-gbm-mojo.zip";
-
- /**
- * Test data.
- */
- private static final String DATA_RES = "examples/src/main/resources/datasets/agaricus-test-data.txt";
-
- /**
- * Parser.
- */
- private static final H2OMojoModelParser parser = new H2OMojoModelParser();
-
- /**
- * Run example.
- */
- public static void main(String... args) throws ExecutionException, InterruptedException, FileNotFoundException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- File mdlRsrc = IgniteUtils.resolveIgnitePath(MODEL_RES);
- if (mdlRsrc == null)
- throw new IllegalArgumentException("File not found [resource_path=" + MODEL_RES + "]");
-
- ModelReader reader = new FileSystemModelReader(mdlRsrc.getPath());
-
- AsyncModelBuilder mdlBuilder = new IgniteDistributedModelBuilder(ignite, 4, 4);
-
- File testData = IgniteUtils.resolveIgnitePath(DATA_RES);
- if (testData == null)
- throw new IllegalArgumentException("File not found [resource_path=" + DATA_RES + "]");
-
- try (Model<NamedVector, Future<Double>> mdl = mdlBuilder.build(reader, parser);
- Scanner testDataScanner = new Scanner(testData)) {
-
- while (testDataScanner.hasNextLine()) {
- String testDataStr = testDataScanner.nextLine();
- String actual = null;
-
- HashMap<String, Double> testObj = new HashMap<>();
-
- for (String keyValueString : testDataStr.split(" ")) {
- String[] keyVal = keyValueString.split(":");
-
- if (keyVal.length == 2)
- testObj.put("C" + (1 + Integer.parseInt(keyVal[0])), Double.parseDouble(keyVal[1]));
- else
- actual = keyValueString;
- }
-
- double prediction = mdl.predict(VectorUtils.of(testObj)).get();
-
- System.out.println("Actual: " + actual + ", prediction: " + prediction);
- }
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/h2o/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/h2o/package-info.java
deleted file mode 100644
index ce63b5db84a..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/h2o/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * H2O MOJO model inference examples.
- */
-
-package org.apache.ignite.examples.ml.inference.h2o;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/package-info.java
deleted file mode 100644
index 26274369e39..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Model inference examples.
- */
-package org.apache.ignite.examples.ml.inference;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/LogRegFromSparkThroughPMMLExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/LogRegFromSparkThroughPMMLExample.java
deleted file mode 100644
index 7ab3e4bc54a..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/LogRegFromSparkThroughPMMLExample.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import javax.xml.bind.JAXBException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.regressions.logistic.LogisticRegressionModel;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.dmg.pmml.PMML;
-import org.dmg.pmml.regression.RegressionModel;
-import org.dmg.pmml.regression.RegressionTable;
-import org.jpmml.model.PMMLUtil;
-import org.xml.sax.SAXException;
-
-/**
- * Run logistic regression model loaded from PMML file. The PMML file was generated by Spark MLLib toPMML operator.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class LogRegFromSparkThroughPMMLExample {
- /** Run example. */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Logistic regression model loaded from PMML over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.TWO_CLASSED_IRIS);
-
- String path = IgniteUtils.resolveIgnitePath("examples/src/main/resources/models/spark/iris.pmml")
- .toPath().toAbsolutePath().toString();
- LogisticRegressionModel mdl = PMMLParser.load(path);
-
- System.out.println(">>> Logistic regression model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- new Accuracy<>()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- }
-
- /** Util class to build the LogReg model. */
- private static class PMMLParser {
- /**
- * @param path Path.
- */
- public static LogisticRegressionModel load(String path) {
- try (InputStream is = new FileInputStream(new File(path))) {
- PMML pmml = PMMLUtil.unmarshal(is);
-
- RegressionModel logRegMdl = (RegressionModel)pmml.getModels().get(0);
-
- RegressionTable regTbl = logRegMdl.getRegressionTables().get(0);
-
- Vector coefficients = new DenseVector(regTbl.getNumericPredictors().size());
-
- for (int i = 0; i < regTbl.getNumericPredictors().size(); i++)
- coefficients.set(i, regTbl.getNumericPredictors().get(i).getCoefficient());
-
- double interceptor = regTbl.getIntercept();
-
- return new LogisticRegressionModel(coefficients, interceptor);
- }
- catch (IOException | JAXBException | SAXException e) {
- e.printStackTrace();
- }
-
- return null;
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/DecisionTreeFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/DecisionTreeFromSparkExample.java
deleted file mode 100644
index 41717ba9bcb..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/DecisionTreeFromSparkExample.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-import org.apache.ignite.ml.tree.DecisionTreeModel;
-
-/**
- * Run Decision Tree model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark MLLib
- * model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class DecisionTreeFromSparkExample {
- /**
- * Path to Spark DT model.
- */
- public static final String SPARK_MDL_PATH = IgniteUtils.resolveIgnitePath("examples/src/main/resources/models/spark/serialized/dt")
- .toPath().toAbsolutePath().toString();
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(
- ">>> Decision Tree model loaded from Spark through serialization over partitioned dataset usage example started."
- );
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengersWithoutNulls(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 5, 6, 4).labeled(1);
-
- DecisionTreeModel mdl = (DecisionTreeModel)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.DECISION_TREE,
- env
- );
-
- System.out.println(">>> DT: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- new Accuracy<>()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/DecisionTreeRegressionFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/DecisionTreeRegressionFromSparkExample.java
deleted file mode 100644
index f0e95fdb92e..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/DecisionTreeRegressionFromSparkExample.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-import org.apache.ignite.ml.structures.LabeledVector;
-import org.apache.ignite.ml.tree.DecisionTreeModel;
-
-/**
- * Run Decision tree regression model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark
- * MLLib model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class DecisionTreeRegressionFromSparkExample {
- /**
- * Path to Spark Decision tree regression model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/dtreg";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(
- ">>> Decision tree regression model loaded from Spark through serialization over partitioned dataset usage example started."
- );
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengersWithoutNulls(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 1, 5, 6).labeled(4);
-
- DecisionTreeModel mdl = (DecisionTreeModel)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.DECISION_TREE_REGRESSION,
- env
- );
-
- System.out.println(">>> Decision tree regression model: " + mdl);
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- LabeledVector<Double> lv = vectorizer.apply(observation.getKey(), observation.getValue());
- Vector inputs = lv.features();
- double groundTruth = lv.label();
- double prediction = mdl.predict(inputs);
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
- }
-
- System.out.println(">>> ---------------------------------");
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/GBTFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/GBTFromSparkExample.java
deleted file mode 100644
index 4154f24695d..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/GBTFromSparkExample.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.composition.ModelsComposition;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-
-/**
- * Run Gradient Boosted trees model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark
- * MLLib model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class GBTFromSparkExample {
- /**
- * Path to Spark LogReg model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/gbt";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(
- ">>> Gradient Boosted trees model loaded from Spark through serialization over partitioned dataset usage example started."
- );
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengersWithoutNulls(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 5, 6).labeled(1);
-
- ModelsComposition mdl = (ModelsComposition)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.GRADIENT_BOOSTED_TREES,
- env
- );
-
- System.out.println(">>> GBT: " + mdl.toString(true));
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- new Accuracy<>()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/GBTRegressionFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/GBTRegressionFromSparkExample.java
deleted file mode 100644
index 561ab9c7bfa..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/GBTRegressionFromSparkExample.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.composition.ModelsComposition;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-import org.apache.ignite.ml.structures.LabeledVector;
-
-/**
- * Run GBT Regression model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark MLLib
- * model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class GBTRegressionFromSparkExample {
- /**
- * Path to Spark GBT Regression model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/gbtreg";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(
- ">>> GBT Regression model loaded from Spark through serialization over partitioned dataset usage example started."
- );
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengersWithoutNulls(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 1, 5, 6).labeled(4);
-
- ModelsComposition mdl = (ModelsComposition)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.GRADIENT_BOOSTED_TREES_REGRESSION,
- env
- );
-
- System.out.println(">>> GBT Regression model: " + mdl);
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- LabeledVector<Double> lv = vectorizer.apply(observation.getKey(), observation.getValue());
- Vector inputs = lv.features();
- double groundTruth = lv.label();
- double prediction = mdl.predict(inputs);
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
- }
-
- System.out.println(">>> ---------------------------------");
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/KMeansFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/KMeansFromSparkExample.java
deleted file mode 100644
index 5aa65273296..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/KMeansFromSparkExample.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.clustering.kmeans.KMeansModel;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-import org.apache.ignite.ml.structures.LabeledVector;
-
-/**
- * Run KMeans model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark MLLib
- * model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class KMeansFromSparkExample {
- /**
- * Path to Spark KMeans model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/kmeans";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(">>> K-means model loaded from Spark through serialization over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengers(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 5, 6, 4).labeled(1);
-
- KMeansModel mdl = (KMeansModel)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.KMEANS,
- env
- );
-
- System.out.println(">>> K-Means model: " + mdl);
- System.out.println(">>> ------------------------------------");
- System.out.println(">>> | Predicted cluster\t| Is survived\t|");
- System.out.println(">>> ------------------------------------");
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- LabeledVector<Double> lv = vectorizer.apply(observation.getKey(), observation.getValue());
- Vector inputs = lv.features();
- double isSurvived = lv.label();
- double clusterId = mdl.predict(inputs);
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", clusterId, isSurvived);
- }
- }
-
- System.out.println(">>> ---------------------------------");
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/LinearRegressionFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/LinearRegressionFromSparkExample.java
deleted file mode 100644
index 52842aac1c2..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/LinearRegressionFromSparkExample.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-import org.apache.ignite.ml.structures.LabeledVector;
-
-/**
- * Run linear regression model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark MLLib
- * model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class LinearRegressionFromSparkExample {
- /**
- * Path to Spark linear regression model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/linreg";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(
- ">>> Linear regression model loaded from Spark through serialization over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengers(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 1, 5, 6).labeled(4);
-
- LinearRegressionModel mdl = (LinearRegressionModel)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.LINEAR_REGRESSION,
- env
- );
-
- System.out.println(">>> Linear regression model: " + mdl);
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- LabeledVector<Double> lv = vectorizer.apply(observation.getKey(), observation.getValue());
- Vector inputs = lv.features();
- double groundTruth = lv.label();
- double prediction = mdl.predict(inputs);
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
- }
-
- System.out.println(">>> ---------------------------------");
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/LogRegFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/LogRegFromSparkExample.java
deleted file mode 100644
index 725ac3873ee..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/LogRegFromSparkExample.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.regressions.logistic.LogisticRegressionModel;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-
-/**
- * Run logistic regression model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark MLLib
- * model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class LogRegFromSparkExample {
- /**
- * Path to Spark LogReg model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/logreg";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(
- ">>> Logistic regression model loaded from Spark through serialization over partitioned dataset usage example started."
- );
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengers(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 5, 6).labeled(1);
-
- LogisticRegressionModel mdl = (LogisticRegressionModel)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.LOG_REGRESSION,
- env
- );
-
- System.out.println(">>> Logistic regression model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- new Accuracy<>()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/RandomForestFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/RandomForestFromSparkExample.java
deleted file mode 100644
index 641285dded4..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/RandomForestFromSparkExample.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.composition.ModelsComposition;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-
-/**
- * Run Random Forest model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark MLLib
- * model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class RandomForestFromSparkExample {
- /**
- * Path to Spark Random Forest model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/rf";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(
- ">>> Random Forest model loaded from Spark through serialization over partitioned dataset usage example started."
- );
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengersWithoutNulls(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 5, 6).labeled(1);
-
- ModelsComposition mdl = (ModelsComposition)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.RANDOM_FOREST,
- env
- );
-
- System.out.println(">>> Random Forest model: " + mdl.toString(true));
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- new Accuracy<>()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/RandomForestRegressionFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/RandomForestRegressionFromSparkExample.java
deleted file mode 100644
index c1b8babd7a1..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/RandomForestRegressionFromSparkExample.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.composition.ModelsComposition;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-import org.apache.ignite.ml.structures.LabeledVector;
-
-/**
- * Run Random Forest regression model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark
- * MLLib model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class RandomForestRegressionFromSparkExample {
- /**
- * Path to Spark Random Forest regression model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/rfreg";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(
- ">>> Random Forest regression model loaded from Spark through serialization over partitioned dataset usage example started."
- );
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengersWithoutNulls(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 1, 5, 6).labeled(4);
-
- ModelsComposition mdl = (ModelsComposition)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.RANDOM_FOREST_REGRESSION,
- env
- );
-
- System.out.println(">>> Random Forest regression model: " + mdl);
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- LabeledVector<Double> lv = vectorizer.apply(observation.getKey(), observation.getValue());
- Vector inputs = lv.features();
- double groundTruth = lv.label();
- double prediction = mdl.predict(inputs);
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
- }
-
- System.out.println(">>> ---------------------------------");
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/SVMFromSparkExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/SVMFromSparkExample.java
deleted file mode 100644
index adcab7a0207..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/SVMFromSparkExample.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
-
-import java.io.FileNotFoundException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.tutorial.TitanicUtils;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironment;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.environment.logging.ConsoleLogger;
-import org.apache.ignite.ml.environment.parallelism.ParallelismStrategy;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.sparkmodelparser.SparkModelParser;
-import org.apache.ignite.ml.sparkmodelparser.SupportedSparkModels;
-import org.apache.ignite.ml.svm.SVMLinearClassificationModel;
-
-/**
- * Run SVM model loaded from snappy.parquet file. The snappy.parquet file was generated by Spark MLLib
- * model.write.overwrite().save(..) operator.
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class SVMFromSparkExample {
- /**
- * Path to Spark SVM model.
- */
- public static final String SPARK_MDL_PATH = "examples/src/main/resources/models/spark/serialized/svm";
-
- /** Learning environment. */
- public static final LearningEnvironment env =
- LearningEnvironmentBuilder.defaultBuilder().withParallelismStrategyTypeDependency(ParallelismStrategy.ON_DEFAULT_POOL)
- .withLoggingFactoryDependency(ConsoleLogger.Factory.HIGH).buildForTrainer();
-
- /**
- * Run example.
- */
- public static void main(String[] args) throws FileNotFoundException {
- System.out.println();
- System.out.println(">>> SVM model loaded from Spark through serialization over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = TitanicUtils.readPassengers(ignite);
-
- final Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>(0, 5, 6).labeled(1);
-
- SVMLinearClassificationModel mdl = (SVMLinearClassificationModel)SparkModelParser.parse(
- SPARK_MDL_PATH,
- SupportedSparkModels.LINEAR_SVM,
- env
- );
-
- System.out.println(">>> SVM: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- new Accuracy<>()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
- }
- finally {
- dataCache.destroy();
- }
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/package-info.java
deleted file mode 100644
index 4b994d5fdcb..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/modelparser/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Model inference examples for Spark ML via Spark Model Parser.
- */
-package org.apache.ignite.examples.ml.inference.spark.modelparser;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/package-info.java
deleted file mode 100644
index 699fe5dc3c0..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/spark/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Model inference examples for Spark ML models.
- */
-package org.apache.ignite.examples.ml.inference.spark;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/xgboost/XGBoostModelParserExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/xgboost/XGBoostModelParserExample.java
deleted file mode 100644
index 997ece8d66d..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/xgboost/XGBoostModelParserExample.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.inference.xgboost;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Scanner;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.ml.inference.Model;
-import org.apache.ignite.ml.inference.builder.AsyncModelBuilder;
-import org.apache.ignite.ml.inference.builder.IgniteDistributedModelBuilder;
-import org.apache.ignite.ml.inference.reader.FileSystemModelReader;
-import org.apache.ignite.ml.inference.reader.ModelReader;
-import org.apache.ignite.ml.math.primitives.vector.NamedVector;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-import org.apache.ignite.ml.xgboost.parser.XGModelParser;
-
-/**
- * This example demonstrates how to import XGBoost model and use imported model for distributed inference in Apache
- * Ignite.
- */
-public class XGBoostModelParserExample {
- /**
- * Test model resource name.
- */
- private static final String TEST_MODEL_RES = "examples/src/main/resources/models/xgboost/agaricus-model.txt";
-
- /**
- * Test data.
- */
- private static final String TEST_DATA_RES = "examples/src/main/resources/datasets/agaricus-test-data.txt";
-
- /**
- * Test expected results.
- */
- private static final String TEST_ER_RES = "examples/src/main/resources/datasets/agaricus-test-expected-results.txt";
-
- /**
- * Parser.
- */
- private static final XGModelParser parser = new XGModelParser();
-
- /**
- * Run example.
- */
- public static void main(String... args) throws ExecutionException, InterruptedException, FileNotFoundException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- File mdlRsrc = IgniteUtils.resolveIgnitePath(TEST_MODEL_RES);
- if (mdlRsrc == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_MODEL_RES + "]");
-
- ModelReader reader = new FileSystemModelReader(mdlRsrc.getPath());
-
- AsyncModelBuilder mdlBuilder = new IgniteDistributedModelBuilder(ignite, 4, 4);
-
- File testData = IgniteUtils.resolveIgnitePath(TEST_DATA_RES);
- if (testData == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_DATA_RES + "]");
-
- File testExpRes = IgniteUtils.resolveIgnitePath(TEST_ER_RES);
- if (testExpRes == null)
- throw new IllegalArgumentException("File not found [resource_path=" + TEST_ER_RES + "]");
-
- try (Model<NamedVector, Future<Double>> mdl = mdlBuilder.build(reader, parser);
- Scanner testDataScanner = new Scanner(testData);
- Scanner testExpResultsScanner = new Scanner(testExpRes)) {
-
- while (testDataScanner.hasNextLine()) {
- String testDataStr = testDataScanner.nextLine();
- String testExpResultsStr = testExpResultsScanner.nextLine();
-
- HashMap<String, Double> testObj = new HashMap<>();
-
- for (String keyValueString : testDataStr.split(" ")) {
- String[] keyVal = keyValueString.split(":");
-
- if (keyVal.length == 2)
- testObj.put("f" + keyVal[0], Double.parseDouble(keyVal[1]));
- }
-
- double prediction = mdl.predict(VectorUtils.of(testObj)).get();
-
- double expPrediction = Double.parseDouble(testExpResultsStr);
-
- System.out.println("Expected: " + expPrediction + ", prediction: " + prediction);
- }
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/inference/xgboost/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/inference/xgboost/package-info.java
deleted file mode 100644
index 3f834d28f47..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/inference/xgboost/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> XGBoost model inference examples.
- */
-
-package org.apache.ignite.examples.ml.inference.xgboost;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/ANNClassificationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/ANNClassificationExample.java
deleted file mode 100644
index 8a23a8f1506..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/knn/ANNClassificationExample.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.knn;
-
-import java.util.Arrays;
-import java.util.UUID;
-import javax.cache.Cache;
-import org.apache.commons.math3.util.Precision;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DoubleArrayVectorizer;
-import org.apache.ignite.ml.knn.NNClassificationModel;
-import org.apache.ignite.ml.knn.ann.ANNClassificationTrainer;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.distances.ManhattanDistance;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-
-/**
- * Run ANN multi-class classification trainer ({@link ANNClassificationTrainer}) over distributed dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the model based on the specified data using
- * <a href="https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm">kNN</a> algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict what cluster does
- * this point belong to, and compares prediction to expected outcome (ground truth).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class ANNClassificationExample {
- /**
- * Run example.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> ANN multi-class classification algorithm over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, double[]> dataCache = null;
- try {
- dataCache = getTestCache(ignite);
-
- ANNClassificationTrainer trainer = new ANNClassificationTrainer()
- .withDistance(new ManhattanDistance())
- .withK(50)
- .withMaxIterations(1000)
- .withEpsilon(1e-2);
-
- long startTrainingTime = System.currentTimeMillis();
-
- NNClassificationModel knnMdl = trainer.fit(
- ignite,
- dataCache,
- new DoubleArrayVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST)
- ).withK(5)
- .withDistanceMeasure(new EuclideanDistance())
- .withWeighted(true);
-
- long endTrainingTime = System.currentTimeMillis();
-
- System.out.println(">>> ---------------------------------");
- System.out.println(">>> | Prediction\t| Ground Truth\t|");
- System.out.println(">>> ---------------------------------");
-
- int amountOfErrors = 0;
- int totalAmount = 0;
-
- long totalPredictionTime = 0L;
-
- try (QueryCursor<Cache.Entry<Integer, double[]>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, double[]> observation : observations) {
- double[] val = observation.getValue();
- double[] inputs = Arrays.copyOfRange(val, 1, val.length);
- double groundTruth = val[0];
-
- long startPredictionTime = System.currentTimeMillis();
- double prediction = knnMdl.predict(new DenseVector(inputs));
- long endPredictionTime = System.currentTimeMillis();
-
- totalPredictionTime += (endPredictionTime - startPredictionTime);
-
- totalAmount++;
- if (!Precision.equals(groundTruth, prediction, Precision.EPSILON))
- amountOfErrors++;
-
- System.out.printf(">>> | %.4f\t\t| %.4f\t\t|\n", prediction, groundTruth);
- }
-
- System.out.println(">>> ---------------------------------");
-
- System.out.println("Training costs = " + (endTrainingTime - startTrainingTime));
- System.out.println("Prediction costs = " + totalPredictionTime);
-
- System.out.println("\n>>> Absolute amount of errors " + amountOfErrors);
- System.out.println("\n>>> Accuracy " + (1 - amountOfErrors / (double)totalAmount));
- System.out.println(totalAmount);
-
- System.out.println(">>> ANN multi-class classification algorithm over cached dataset usage example completed.");
- }
- }
- finally {
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Fills cache with data and returns it.
- *
- * @param ignite Ignite instance.
- * @return Filled Ignite Cache.
- */
- private static IgniteCache<Integer, double[]> getTestCache(Ignite ignite) {
- CacheConfiguration<Integer, double[]> cacheConfiguration = new CacheConfiguration<>();
- cacheConfiguration.setName("TEST_" + UUID.randomUUID());
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- IgniteCache<Integer, double[]> cache = ignite.createCache(cacheConfiguration);
-
- for (int k = 0; k < 10; k++) { // multiplies the Iris dataset k times.
- for (int i = 0; i < data.length; i++)
- cache.put(k * 10000 + i, mutate(data[i], k));
- }
-
- return cache;
- }
-
- /**
- * Tiny changing of data depending on k parameter.
- *
- * @param datum The vector data.
- * @param k The passed parameter.
- * @return The changed vector data.
- */
- private static double[] mutate(double[] datum, int k) {
- for (int i = 0; i < datum.length; i++)
- datum[i] += k / 100000;
- return datum;
- }
-
- /**
- * The Iris dataset.
- */
- private static final double[][] data = {
- {1, 5.1, 3.5, 1.4, 0.2},
- {1, 4.9, 3, 1.4, 0.2},
- {1, 4.7, 3.2, 1.3, 0.2},
- {1, 4.6, 3.1, 1.5, 0.2},
- {1, 5, 3.6, 1.4, 0.2},
- {1, 5.4, 3.9, 1.7, 0.4},
- {1, 4.6, 3.4, 1.4, 0.3},
- {1, 5, 3.4, 1.5, 0.2},
- {1, 4.4, 2.9, 1.4, 0.2},
- {1, 4.9, 3.1, 1.5, 0.1},
- {1, 5.4, 3.7, 1.5, 0.2},
- {1, 4.8, 3.4, 1.6, 0.2},
- {1, 4.8, 3, 1.4, 0.1},
- {1, 4.3, 3, 1.1, 0.1},
- {1, 5.8, 4, 1.2, 0.2},
- {1, 5.7, 4.4, 1.5, 0.4},
- {1, 5.4, 3.9, 1.3, 0.4},
- {1, 5.1, 3.5, 1.4, 0.3},
- {1, 5.7, 3.8, 1.7, 0.3},
- {1, 5.1, 3.8, 1.5, 0.3},
- {1, 5.4, 3.4, 1.7, 0.2},
- {1, 5.1, 3.7, 1.5, 0.4},
- {1, 4.6, 3.6, 1, 0.2},
- {1, 5.1, 3.3, 1.7, 0.5},
- {1, 4.8, 3.4, 1.9, 0.2},
- {1, 5, 3, 1.6, 0.2},
- {1, 5, 3.4, 1.6, 0.4},
- {1, 5.2, 3.5, 1.5, 0.2},
- {1, 5.2, 3.4, 1.4, 0.2},
- {1, 4.7, 3.2, 1.6, 0.2},
- {1, 4.8, 3.1, 1.6, 0.2},
- {1, 5.4, 3.4, 1.5, 0.4},
- {1, 5.2, 4.1, 1.5, 0.1},
- {1, 5.5, 4.2, 1.4, 0.2},
- {1, 4.9, 3.1, 1.5, 0.1},
- {1, 5, 3.2, 1.2, 0.2},
- {1, 5.5, 3.5, 1.3, 0.2},
- {1, 4.9, 3.1, 1.5, 0.1},
- {1, 4.4, 3, 1.3, 0.2},
- {1, 5.1, 3.4, 1.5, 0.2},
- {1, 5, 3.5, 1.3, 0.3},
- {1, 4.5, 2.3, 1.3, 0.3},
- {1, 4.4, 3.2, 1.3, 0.2},
- {1, 5, 3.5, 1.6, 0.6},
- {1, 5.1, 3.8, 1.9, 0.4},
- {1, 4.8, 3, 1.4, 0.3},
- {1, 5.1, 3.8, 1.6, 0.2},
- {1, 4.6, 3.2, 1.4, 0.2},
- {1, 5.3, 3.7, 1.5, 0.2},
- {1, 5, 3.3, 1.4, 0.2},
- {2, 7, 3.2, 4.7, 1.4},
- {2, 6.4, 3.2, 4.5, 1.5},
- {2, 6.9, 3.1, 4.9, 1.5},
- {2, 5.5, 2.3, 4, 1.3},
- {2, 6.5, 2.8, 4.6, 1.5},
- {2, 5.7, 2.8, 4.5, 1.3},
- {2, 6.3, 3.3, 4.7, 1.6},
- {2, 4.9, 2.4, 3.3, 1},
- {2, 6.6, 2.9, 4.6, 1.3},
- {2, 5.2, 2.7, 3.9, 1.4},
- {2, 5, 2, 3.5, 1},
- {2, 5.9, 3, 4.2, 1.5},
- {2, 6, 2.2, 4, 1},
- {2, 6.1, 2.9, 4.7, 1.4},
- {2, 5.6, 2.9, 3.6, 1.3},
- {2, 6.7, 3.1, 4.4, 1.4},
- {2, 5.6, 3, 4.5, 1.5},
- {2, 5.8, 2.7, 4.1, 1},
- {2, 6.2, 2.2, 4.5, 1.5},
- {2, 5.6, 2.5, 3.9, 1.1},
- {2, 5.9, 3.2, 4.8, 1.8},
- {2, 6.1, 2.8, 4, 1.3},
- {2, 6.3, 2.5, 4.9, 1.5},
- {2, 6.1, 2.8, 4.7, 1.2},
- {2, 6.4, 2.9, 4.3, 1.3},
- {2, 6.6, 3, 4.4, 1.4},
- {2, 6.8, 2.8, 4.8, 1.4},
- {2, 6.7, 3, 5, 1.7},
- {2, 6, 2.9, 4.5, 1.5},
- {2, 5.7, 2.6, 3.5, 1},
- {2, 5.5, 2.4, 3.8, 1.1},
- {2, 5.5, 2.4, 3.7, 1},
- {2, 5.8, 2.7, 3.9, 1.2},
- {2, 6, 2.7, 5.1, 1.6},
- {2, 5.4, 3, 4.5, 1.5},
- {2, 6, 3.4, 4.5, 1.6},
- {2, 6.7, 3.1, 4.7, 1.5},
- {2, 6.3, 2.3, 4.4, 1.3},
- {2, 5.6, 3, 4.1, 1.3},
- {2, 5.5, 2.5, 4, 1.3},
- {2, 5.5, 2.6, 4.4, 1.2},
- {2, 6.1, 3, 4.6, 1.4},
- {2, 5.8, 2.6, 4, 1.2},
- {2, 5, 2.3, 3.3, 1},
- {2, 5.6, 2.7, 4.2, 1.3},
- {2, 5.7, 3, 4.2, 1.2},
- {2, 5.7, 2.9, 4.2, 1.3},
- {2, 6.2, 2.9, 4.3, 1.3},
- {2, 5.1, 2.5, 3, 1.1},
- {2, 5.7, 2.8, 4.1, 1.3},
- {3, 6.3, 3.3, 6, 2.5},
- {3, 5.8, 2.7, 5.1, 1.9},
- {3, 7.1, 3, 5.9, 2.1},
- {3, 6.3, 2.9, 5.6, 1.8},
- {3, 6.5, 3, 5.8, 2.2},
- {3, 7.6, 3, 6.6, 2.1},
- {3, 4.9, 2.5, 4.5, 1.7},
- {3, 7.3, 2.9, 6.3, 1.8},
- {3, 6.7, 2.5, 5.8, 1.8},
- {3, 7.2, 3.6, 6.1, 2.5},
- {3, 6.5, 3.2, 5.1, 2},
- {3, 6.4, 2.7, 5.3, 1.9},
- {3, 6.8, 3, 5.5, 2.1},
- {3, 5.7, 2.5, 5, 2},
- {3, 5.8, 2.8, 5.1, 2.4},
- {3, 6.4, 3.2, 5.3, 2.3},
- {3, 6.5, 3, 5.5, 1.8},
- {3, 7.7, 3.8, 6.7, 2.2},
- {3, 7.7, 2.6, 6.9, 2.3},
- {3, 6, 2.2, 5, 1.5},
- {3, 6.9, 3.2, 5.7, 2.3},
- {3, 5.6, 2.8, 4.9, 2},
- {3, 7.7, 2.8, 6.7, 2},
- {3, 6.3, 2.7, 4.9, 1.8},
- {3, 6.7, 3.3, 5.7, 2.1},
- {3, 7.2, 3.2, 6, 1.8},
- {3, 6.2, 2.8, 4.8, 1.8},
- {3, 6.1, 3, 4.9, 1.8},
- {3, 6.4, 2.8, 5.6, 2.1},
- {3, 7.2, 3, 5.8, 1.6},
- {3, 7.4, 2.8, 6.1, 1.9},
- {3, 7.9, 3.8, 6.4, 2},
- {3, 6.4, 2.8, 5.6, 2.2},
- {3, 6.3, 2.8, 5.1, 1.5},
- {3, 6.1, 2.6, 5.6, 1.4},
- {3, 7.7, 3, 6.1, 2.3},
- {3, 6.3, 3.4, 5.6, 2.4},
- {3, 6.4, 3.1, 5.5, 1.8},
- {3, 6, 3, 4.8, 1.8},
- {3, 6.9, 3.1, 5.4, 2.1},
- {3, 6.7, 3.1, 5.6, 2.4},
- {3, 6.9, 3.1, 5.1, 2.3},
- {3, 5.8, 2.7, 5.1, 1.9},
- {3, 6.8, 3.2, 5.9, 2.3},
- {3, 6.7, 3.3, 5.7, 2.5},
- {3, 6.7, 3, 5.2, 2.3},
- {3, 6.3, 2.5, 5, 1.9},
- {3, 6.5, 3, 5.2, 2},
- {3, 6.2, 3.4, 5.4, 2.3},
- {3, 5.9, 3, 5.1, 1.8}
- };
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/IrisClassificationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/IrisClassificationExample.java
deleted file mode 100644
index e8ef55e5fb8..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/knn/IrisClassificationExample.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.knn;
-
-import java.io.IOException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.knn.classification.KNNClassificationModel;
-import org.apache.ignite.ml.knn.classification.KNNClassificationTrainer;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.selection.split.TrainTestDatasetSplitter;
-import org.apache.ignite.ml.selection.split.TrainTestSplit;
-
-/**
- * Example of using Knn model in Apache Ignite for iris class predicion.
- * <p>
- * Description of model can be found in: https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm . Original dataset
- * can be downloaded from: https://archive.ics.uci.edu/ml/datasets/Wholesale+customers . Copy of dataset are stored in:
- * https://archive.ics.uci.edu/ml/datasets/iris . Score for classifier estimation: accuracy . Description of score can
- * be found in: https://stattrek.com/statistics/dictionary.aspx?definition=accuracy .
- */
-public class IrisClassificationExample {
- /**
- * Runs example.
- */
- public static void main(String[] args) throws IOException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- System.out.println(">>> Fill dataset cache.");
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.IRIS);
- KNNClassificationTrainer trainer = ((KNNClassificationTrainer)new KNNClassificationTrainer()
- .withEnvironmentBuilder(LearningEnvironmentBuilder.defaultBuilder().withRNGSeed(0)))
- .withK(3)
- .withDistanceMeasure(new EuclideanDistance())
- .withWeighted(true);
-
- // This vectorizer works with values in cache of Vector class.
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST); // FIRST means "label are stored at first coordinate of vector"
-
- // Splits dataset to train and test samples with 60/40 proportion.
- TrainTestSplit<Integer, Vector> split = new TrainTestDatasetSplitter<Integer, Vector>().split(0.6);
-
- System.out.println(">>> Start traininig.");
- KNNClassificationModel mdl = trainer.fit(
- ignite, dataCache,
- split.getTrainFilter(),
- vectorizer
- );
-
- System.out.println(">>> Perform scoring.");
- double accuracy = Evaluator.evaluate(
- dataCache,
- split.getTestFilter(),
- mdl,
- vectorizer,
- new Accuracy<>()
- );
-
- System.out.println(">> Model accuracy: " + accuracy);
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNClassificationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNClassificationExample.java
deleted file mode 100644
index 1917d22821f..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNClassificationExample.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.knn;
-
-import java.io.IOException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.knn.classification.KNNClassificationModel;
-import org.apache.ignite.ml.knn.classification.KNNClassificationTrainer;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-/**
- * Run kNN multi-class classification trainer ({@link KNNClassificationTrainer}) over distributed dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the model based on the specified data using
- * <a href="https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm">kNN</a> algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict what cluster does
- * this point belong to, and compares prediction to expected outcome (ground truth).</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class KNNClassificationExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> kNN multi-class classification algorithm over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.TWO_CLASSED_IRIS);
-
- KNNClassificationTrainer trainer = new KNNClassificationTrainer()
- .withK(3)
- .withDistanceMeasure(new EuclideanDistance())
- .withWeighted(true)
- .withDataTtl(60);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- KNNClassificationModel mdl = trainer.fit(ignite, dataCache, vectorizer);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNRegressionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNRegressionExample.java
deleted file mode 100644
index a2c1cbe1c5a..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/knn/KNNRegressionExample.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.knn;
-
-import java.io.IOException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.knn.regression.KNNRegressionModel;
-import org.apache.ignite.ml.knn.regression.KNNRegressionTrainer;
-import org.apache.ignite.ml.knn.utils.indices.SpatialIndexType;
-import org.apache.ignite.ml.math.distances.ManhattanDistance;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.regression.Rmse;
-
-/**
- * Run kNN regression trainer ({@link KNNRegressionTrainer}) over distributed dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the model based on the specified data using
- * <a href="https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm">kNN</a> regression algorithm.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict what cluster does
- * this point belong to, and compares prediction to expected outcome (ground truth).</p>
- * <p>
- * You can change the test data used in this example or trainer object settings and re-run it to explore this algorithm
- * further.</p>
- */
-public class KNNRegressionExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> kNN regression over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.CLEARED_MACHINES);
-
- KNNRegressionTrainer trainer = new KNNRegressionTrainer()
- .withK(5)
- .withDistanceMeasure(new ManhattanDistance())
- .withIdxType(SpatialIndexType.BALL_TREE)
- .withWeighted(true);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- KNNRegressionModel knnMdl = trainer.fit(ignite, dataCache, vectorizer);
-
- double rmse = Evaluator.evaluate(
- dataCache,
- knnMdl,
- vectorizer,
- new Rmse()
- );
-
- System.out.println("\n>>> Rmse = " + rmse);
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/knn/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/knn/package-info.java
deleted file mode 100644
index b8c8b216aae..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/knn/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> kNN examples.
- */
-package org.apache.ignite.examples.ml.knn;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/multiclass/OneVsRestClassificationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/multiclass/OneVsRestClassificationExample.java
deleted file mode 100644
index 14b05c4890f..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/multiclass/OneVsRestClassificationExample.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.multiclass;
-
-import java.io.IOException;
-import java.util.Arrays;
-import javax.cache.Cache;
-import org.apache.commons.math3.util.Precision;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.multiclass.MultiClassModel;
-import org.apache.ignite.ml.multiclass.OneVsRestTrainer;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.minmaxscaling.MinMaxScalerTrainer;
-import org.apache.ignite.ml.svm.SVMLinearClassificationModel;
-import org.apache.ignite.ml.svm.SVMLinearClassificationTrainer;
-
-/**
- * Run One-vs-Rest multi-class classification trainer ({@link OneVsRestTrainer}) parametrized by binary SVM classifier
- * ({@link SVMLinearClassificationTrainer}) over distributed dataset to build two models: one with min-max scaling and
- * one without min-max scaling.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (preprocessed
- * <a href="https://archive.ics.uci.edu/ml/datasets/Glass+Identification">Glass dataset</a>).</p>
- * <p>
- * After that it trains two One-vs-Rest multi-class models based on the specified data - one model is with min-max
- * scaling and one without min-max scaling.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained models to predict what cluster does
- * this point belong to, compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p> NOTE: the
- * smallest 3rd class could not be classified via linear SVM here.
- */
-public class OneVsRestClassificationExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> One-vs-Rest SVM Multi-class classification model over cached dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.GLASS_IDENTIFICATION);
-
- OneVsRestTrainer<SVMLinearClassificationModel> trainer
- = new OneVsRestTrainer<>(new SVMLinearClassificationTrainer()
- .withAmountOfIterations(20)
- .withAmountOfLocIterations(50)
- .withLambda(0.2)
- .withSeed(1234L)
- );
-
- MultiClassModel<SVMLinearClassificationModel> mdl = trainer.fit(
- ignite,
- dataCache,
- new DummyVectorizer<Integer>().labeled(0)
- );
-
- System.out.println(">>> One-vs-Rest SVM Multi-class model");
- System.out.println(mdl.toString());
-
- MinMaxScalerTrainer<Integer, Vector> minMaxScalerTrainer = new MinMaxScalerTrainer<>();
-
- Preprocessor<Integer, Vector> preprocessor = minMaxScalerTrainer.fit(
- ignite,
- dataCache,
- new DummyVectorizer<Integer>().labeled(0)
- );
-
- MultiClassModel<SVMLinearClassificationModel> mdlWithScaling = trainer.fit(
- ignite,
- dataCache,
- preprocessor
- );
-
- System.out.println(">>> One-vs-Rest SVM Multi-class model with MinMaxScaling");
- System.out.println(mdlWithScaling.toString());
-
- System.out.println(">>> ----------------------------------------------------------------");
- System.out.println(">>> | Prediction\t| Prediction with MinMaxScaling\t| Ground Truth\t|");
- System.out.println(">>> ----------------------------------------------------------------");
-
- int amountOfErrors = 0;
- int amountOfErrorsWithMinMaxScaling = 0;
- int totalAmount = 0;
-
- // Build confusion matrix. See https://en.wikipedia.org/wiki/Confusion_matrix
- int[][] confusionMtx = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
- int[][] confusionMtxWithMinMaxScaling = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
-
- try (QueryCursor<Cache.Entry<Integer, Vector>> observations = dataCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, Vector> observation : observations) {
- Vector val = observation.getValue();
- Vector inputs = val.copyOfRange(1, val.size());
- double groundTruth = val.get(0);
-
- double prediction = mdl.predict(inputs);
- double predictionWithMinMaxScaling = mdlWithScaling.predict(inputs);
-
- totalAmount++;
-
- // Collect data for model
- if (!Precision.equals(groundTruth, prediction, Precision.EPSILON))
- amountOfErrors++;
-
- int idx1 = (int)prediction == 1 ? 0 : ((int)prediction == 3 ? 1 : 2);
- int idx2 = (int)groundTruth == 1 ? 0 : ((int)groundTruth == 3 ? 1 : 2);
-
- confusionMtx[idx1][idx2]++;
-
- // Collect data for model with min-max scaling
- if (!Precision.equals(groundTruth, predictionWithMinMaxScaling, Precision.EPSILON))
- amountOfErrorsWithMinMaxScaling++;
-
- idx1 = (int)predictionWithMinMaxScaling == 1 ? 0 : ((int)predictionWithMinMaxScaling == 3 ? 1 : 2);
- idx2 = (int)groundTruth == 1 ? 0 : ((int)groundTruth == 3 ? 1 : 2);
-
- confusionMtxWithMinMaxScaling[idx1][idx2]++;
-
- System.out.printf(
- ">>> | %.4f\t\t| %.4f\t\t\t\t\t\t| %.4f\t\t|\n",
- prediction,
- predictionWithMinMaxScaling,
- groundTruth
- );
- }
- System.out.println(">>> ----------------------------------------------------------------");
- System.out.println("\n>>> -----------------One-vs-Rest SVM model-------------");
- System.out.println("\n>>> Absolute amount of errors " + amountOfErrors);
- System.out.println("\n>>> Accuracy " + (1 - amountOfErrors / (double)totalAmount));
- System.out.println("\n>>> Confusion matrix is " + Arrays.deepToString(confusionMtx));
-
- System.out.println("\n>>> -----------------One-vs-Rest SVM model with MinMaxScaling-------------");
- System.out.println("\n>>> Absolute amount of errors " + amountOfErrorsWithMinMaxScaling);
- System.out.println("\n>>> Accuracy " + (1 - amountOfErrorsWithMinMaxScaling / (double)totalAmount));
- System.out.println("\n>>> Confusion matrix is " + Arrays.deepToString(confusionMtxWithMinMaxScaling));
-
- System.out.println(">>> One-vs-Rest SVM model over cache based dataset usage example completed.");
- }
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/multiclass/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/multiclass/package-info.java
deleted file mode 100644
index 0cb8ebed550..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/multiclass/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Multi-class classification examples.
- */
-package org.apache.ignite.examples.ml.multiclass;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/CompoundNaiveBayesExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/CompoundNaiveBayesExample.java
deleted file mode 100644
index 24bbcb8f10d..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/CompoundNaiveBayesExample.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.naivebayes;
-
-import java.io.IOException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.naivebayes.compound.CompoundNaiveBayesModel;
-import org.apache.ignite.ml.naivebayes.compound.CompoundNaiveBayesTrainer;
-import org.apache.ignite.ml.naivebayes.discrete.DiscreteNaiveBayesTrainer;
-import org.apache.ignite.ml.naivebayes.gaussian.GaussianNaiveBayesTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-import static java.util.Arrays.asList;
-
-/**
- * Run naive Compound Bayes classification model based on <a href="https://en.wikipedia.org/wiki/Naive_Bayes_classifier">
- * Nnaive Bayes classifier</a> algorithm ({@link GaussianNaiveBayesTrainer})and <a
- * href=https://en.wikipedia.org/wiki/Naive_Bayes_classifier#Multinomial_naive_Bayes"> Discrete naive Bayes
- * classifier</a> algorithm ({@link DiscreteNaiveBayesTrainer}) over distributed cache.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points.
- * <p>
- * After that it trains the naive Bayes classification model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value,
- * compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class CompoundNaiveBayesExample {
- /** Run example. */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Compound Naive Bayes classification model over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = new SandboxMLCache(ignite)
- .fillCacheWith(MLSandboxDatasets.MIXED_DATASET);
-
- double[] priorProbabilities = new double[] {.5, .5};
- double[][] thresholds = new double[][] {{.5}, {.5}, {.5}, {.5}, {.5}};
-
- System.out.println(">>> Create new naive Bayes classification trainer object.");
- CompoundNaiveBayesTrainer trainer = new CompoundNaiveBayesTrainer()
- .withPriorProbabilities(priorProbabilities)
- .withGaussianNaiveBayesTrainer(new GaussianNaiveBayesTrainer())
- .withGaussianFeatureIdsToSkip(asList(3, 4, 5, 6, 7))
- .withDiscreteNaiveBayesTrainer(new DiscreteNaiveBayesTrainer()
- .setBucketThresholds(thresholds))
- .withDiscreteFeatureIdsToSkip(asList(0, 1, 2));
- System.out.println(">>> Perform the training to get the model.");
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- CompoundNaiveBayesModel mdl = trainer.fit(ignite, dataCache, vectorizer);
-
- System.out.println(">>> Compound Naive Bayes model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
-
- System.out.println(">>> Compound Naive bayes model over partitioned dataset usage example completed.");
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/DiscreteNaiveBayesTrainerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/DiscreteNaiveBayesTrainerExample.java
deleted file mode 100644
index 2aee5fe45af..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/DiscreteNaiveBayesTrainerExample.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.naivebayes;
-
-import java.io.IOException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.naivebayes.discrete.DiscreteNaiveBayesModel;
-import org.apache.ignite.ml.naivebayes.discrete.DiscreteNaiveBayesTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-/**
- * Run naive Bayes classification model based on <a href=https://en.wikipedia.org/wiki/Naive_Bayes_classifier#Multinomial_naive_Bayes">
- * naive Bayes classifier</a> algorithm ({@link DiscreteNaiveBayesTrainer}) over distributed cache.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points.
- * </p>
- * <p>
- * After that it trains the Discrete naive Bayes classification model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value,
- * compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class DiscreteNaiveBayesTrainerExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println(">>> Discrete naive Bayes classification model over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.ENGLISH_VS_SCOTTISH);
-
- double[][] thresholds = new double[][] {{.5}, {.5}, {.5}, {.5}, {.5}};
- System.out.println(">>> Create new Discrete naive Bayes classification trainer object.");
- DiscreteNaiveBayesTrainer trainer = new DiscreteNaiveBayesTrainer()
- .setBucketThresholds(thresholds);
-
- System.out.println(">>> Perform the training to get the model.");
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- DiscreteNaiveBayesModel mdl = trainer.fit(ignite, dataCache, vectorizer);
- System.out.println(">>> Discrete Naive Bayes model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
-
- System.out.println(">>> Discrete Naive bayes model over partitioned dataset usage example completed.");
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/GaussianNaiveBayesTrainerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/GaussianNaiveBayesTrainerExample.java
deleted file mode 100644
index 6571d3e1ef1..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/GaussianNaiveBayesTrainerExample.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.naivebayes;
-
-import java.io.IOException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.naivebayes.gaussian.GaussianNaiveBayesModel;
-import org.apache.ignite.ml.naivebayes.gaussian.GaussianNaiveBayesTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-/**
- * Run naive Bayes classification model based on <a href="https://en.wikipedia.org/wiki/Naive_Bayes_classifier"> naive
- * Bayes classifier</a> algorithm ({@link GaussianNaiveBayesTrainer}) over distributed cache.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data points (based on the
- * <a href="https://en.wikipedia.org/wiki/Iris_flower_data_set"></a>Iris dataset</a>).</p>
- * <p>
- * After that it trains the naive Bayes classification model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value,
- * compares prediction to expected outcome (ground truth), and builds
- * <a href="https://en.wikipedia.org/wiki/Confusion_matrix">confusion matrix</a>.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this algorithm further.</p>
- */
-public class GaussianNaiveBayesTrainerExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Naive Bayes classification model over partitioned dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.TWO_CLASSED_IRIS);
-
- System.out.println(">>> Create new naive Bayes classification trainer object.");
- GaussianNaiveBayesTrainer trainer = new GaussianNaiveBayesTrainer();
-
- System.out.println(">>> Perform the training to get the model.");
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST);
-
- GaussianNaiveBayesModel mdl = trainer.fit(ignite, dataCache, vectorizer);
- System.out.println(">>> Naive Bayes model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- vectorizer,
- MetricName.ACCURACY
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
-
- System.out.println(">>> Naive bayes model over partitioned dataset usage example completed.");
- }
- finally {
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/package-info.java
deleted file mode 100644
index 6672ada1632..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/naivebayes/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> ML naive Bayes classifier examples.
- */
-
-package org.apache.ignite.examples.ml.naivebayes;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPTrainerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPTrainerExample.java
deleted file mode 100644
index ccdcd0bd7c2..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/nn/MLPTrainerExample.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.nn;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.LabeledDummyVectorizer;
-import org.apache.ignite.ml.math.primitives.matrix.Matrix;
-import org.apache.ignite.ml.math.primitives.matrix.impl.DenseMatrix;
-import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
-import org.apache.ignite.ml.nn.Activators;
-import org.apache.ignite.ml.nn.MLPTrainer;
-import org.apache.ignite.ml.nn.MultilayerPerceptron;
-import org.apache.ignite.ml.nn.UpdatesStrategy;
-import org.apache.ignite.ml.nn.architecture.MLPArchitecture;
-import org.apache.ignite.ml.optimization.LossFunctions;
-import org.apache.ignite.ml.optimization.updatecalculators.SimpleGDParameterUpdate;
-import org.apache.ignite.ml.optimization.updatecalculators.SimpleGDUpdateCalculator;
-import org.apache.ignite.ml.structures.LabeledVector;
-
-/**
- * Example of using distributed {@link MultilayerPerceptron}.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it defines a layered architecture and a
- * <a href="https://en.wikipedia.org/wiki/Neural_network">neural network</a> trainer, trains neural network
- * and obtains multilayer perceptron model.</p>
- * <p>
- * Finally, this example loops over the test set, applies the trained model to predict the value and compares prediction
- * to expected outcome.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this functionality further.</p>
- * <p>
- * Remote nodes should always be started with special configuration file which enables P2P class loading: {@code
- * 'ignite.{sh|bat} examples/config/example-ignite.xml'}.</p>
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will start node with {@code
- * examples/config/example-ignite.xml} configuration.</p>
- */
-public class MLPTrainerExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- // IMPL NOTE based on MLPGroupTrainerTest#testXOR
- System.out.println(">>> Distributed multilayer perceptron example started.");
-
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- // Create cache with training data.
- CacheConfiguration<Integer, LabeledVector<double[]>> trainingSetCfg = new CacheConfiguration<>();
- trainingSetCfg.setName("TRAINING_SET");
- trainingSetCfg.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- IgniteCache<Integer, LabeledVector<double[]>> trainingSet = null;
- try {
- trainingSet = ignite.createCache(trainingSetCfg);
-
- // Fill cache with training data.
- trainingSet.put(0, new LabeledVector<>(VectorUtils.of(0, 0), new double[] {0}));
- trainingSet.put(1, new LabeledVector<>(VectorUtils.of(0, 1), new double[] {1}));
- trainingSet.put(2, new LabeledVector<>(VectorUtils.of(1, 0), new double[] {1}));
- trainingSet.put(3, new LabeledVector<>(VectorUtils.of(1, 1), new double[] {0}));
-
- // Define a layered architecture.
- MLPArchitecture arch = new MLPArchitecture(2).
- withAddedLayer(10, true, Activators.RELU).
- withAddedLayer(1, false, Activators.SIGMOID);
-
- // Define a neural network trainer.
- MLPTrainer<SimpleGDParameterUpdate> trainer = new MLPTrainer<>(
- arch,
- LossFunctions.MSE,
- new UpdatesStrategy<>(
- new SimpleGDUpdateCalculator(0.1),
- SimpleGDParameterUpdate.SUM_LOCAL,
- SimpleGDParameterUpdate.AVG
- ),
- 3000,
- 4,
- 50,
- 123L
- );
-
- // Train neural network and get multilayer perceptron model.
- MultilayerPerceptron mlp = trainer.fit(ignite, trainingSet, new LabeledDummyVectorizer<>());
-
- int totalCnt = 4;
- int failCnt = 0;
-
- // Calculate score.
- for (int i = 0; i < 4; i++) {
- LabeledVector<double[]> pnt = trainingSet.get(i);
- Matrix predicted = mlp.predict(new DenseMatrix(new double[][] {{pnt.features().get(0), pnt.features().get(1)}}));
-
- double predictedVal = predicted.get(0, 0);
- double lbl = pnt.label()[0];
- System.out.printf(">>> key: %d\t\t predicted: %.4f\t\tlabel: %.4f\n", i, predictedVal, lbl);
- failCnt += Math.abs(predictedVal - lbl) < 0.5 ? 0 : 1;
- }
-
- double failRatio = (double)failCnt / totalCnt;
-
- System.out.println("\n>>> Fail percentage: " + (failRatio * 100) + "%.");
- System.out.println("\n>>> Distributed multilayer perceptron example completed.");
- }
- finally {
- trainingSet.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/nn/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/nn/package-info.java
deleted file mode 100644
index d2c9f56ceae..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/nn/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> ML neural network examples.
- */
-package org.apache.ignite.examples.ml.nn;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/package-info.java
deleted file mode 100644
index d0f08bcdf57..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Machine learning examples.
- */
-
-package org.apache.ignite.examples.ml;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/BinarizationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/BinarizationExample.java
deleted file mode 100644
index 1ff29ff729c..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/BinarizationExample.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing;
-
-import java.io.Serializable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.DatasetHelper;
-import org.apache.ignite.ml.dataset.DatasetFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.dataset.primitive.SimpleDataset;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.binarization.BinarizationTrainer;
-
-/**
- * Example that shows how to use binarization preprocessor to binarize data.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it defines preprocessors that extract features from an upstream data and normalize features.</p>
- * <p>
- * Finally, it creates the dataset based on the processed data and uses Dataset API to find and output various
- * statistical metrics of the data.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this functionality further.</p>
- */
-public class BinarizationExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Binarization example started.");
-
- IgniteCache<Integer, Vector> data = null;
- try {
- data = createCache(ignite);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<>(1);
-
- // Defines second preprocessor that binarizes features.
- Preprocessor<Integer, Vector> preprocessor = new BinarizationTrainer<Integer, Vector>()
- .withThreshold(40)
- .fit(ignite, data, vectorizer);
-
- // Creates a cache based simple dataset containing features and providing standard dataset API.
- try (SimpleDataset<?> dataset = DatasetFactory.createSimpleDataset(ignite, data, preprocessor)) {
- new DatasetHelper(dataset).describe();
- }
-
- System.out.println(">>> Binarization example completed.");
- }
- finally {
- data.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- *
- */
- private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
- CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
-
- persons.put(1, new DenseVector(new Serializable[] {"Mike", 42, 10000}));
- persons.put(2, new DenseVector(new Serializable[] {"John", 32, 64000}));
- persons.put(3, new DenseVector(new Serializable[] {"George", 53, 120000}));
- persons.put(4, new DenseVector(new Serializable[] {"Karl", 24, 70000}));
-
- return persons;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/ImputingExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/ImputingExample.java
deleted file mode 100644
index eb29c847804..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/ImputingExample.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing;
-
-import java.io.Serializable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.DatasetHelper;
-import org.apache.ignite.ml.dataset.DatasetFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.dataset.primitive.SimpleDataset;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.imputing.ImputerTrainer;
-
-/**
- * Example that shows how to use <a href="https://en.wikipedia.org/wiki/Imputation_(statistics)">Imputing</a>
- * preprocessor to impute the missing value in the given data.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it defines preprocessors that extract features from an upstream data and impute missing values.</p>
- * <p>
- * Finally, it creates the dataset based on the processed data and uses Dataset API to find and output various
- * statistical metrics of the data.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this functionality further.</p>
- */
-public class ImputingExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Imputing example started.");
-
- IgniteCache<Integer, Vector> data = null;
- try {
- data = createCache(ignite);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<>(1, 2);
-
- // Defines second preprocessor that imputing features.
- Preprocessor<Integer, Vector> preprocessor = new ImputerTrainer<Integer, Vector>()
- .fit(ignite, data, vectorizer);
-
- // Creates a cache based simple dataset containing features and providing standard dataset API.
- try (SimpleDataset<?> dataset = DatasetFactory.createSimpleDataset(ignite, data, preprocessor)) {
- new DatasetHelper(dataset).describe();
- }
-
- System.out.println(">>> Imputing example completed.");
- }
- finally {
- data.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- *
- */
- private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
- CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
-
- persons.put(1, new DenseVector(new Serializable[] {"Mike", 10, 1}));
- persons.put(1, new DenseVector(new Serializable[] {"John", 20, 2}));
- persons.put(1, new DenseVector(new Serializable[] {"George", 15, 1}));
- persons.put(1, new DenseVector(new Serializable[] {"Piter", 25, Double.NaN}));
- persons.put(1, new DenseVector(new Serializable[] {"Karl", Double.NaN, 1}));
- persons.put(1, new DenseVector(new Serializable[] {"Gustaw", 20, 2}));
- persons.put(1, new DenseVector(new Serializable[] {"Alex", 20, 2}));
-
- return persons;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/MaxAbsScalerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/MaxAbsScalerExample.java
deleted file mode 100644
index b563a48100a..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/MaxAbsScalerExample.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing;
-
-import java.io.Serializable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.DatasetHelper;
-import org.apache.ignite.ml.dataset.DatasetFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.dataset.primitive.SimpleDataset;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.maxabsscaling.MaxAbsScalerTrainer;
-
-/**
- * Example that shows how to use MaxAbsScaler preprocessor to scale the given data.
- * <p>
- * Machine learning preprocessors are built as a chain. Most often a first preprocessor is a feature extractor as shown
- * in this example. The second preprocessor here is a MinMaxScaler preprocessor which is built on top of the feature
- * extractor and represents a chain of itself and the underlying feature extractor.
- */
-public class MaxAbsScalerExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Max abs example started.");
-
- IgniteCache<Integer, Vector> data = null;
- try {
- data = createCache(ignite);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer
- = new DummyVectorizer<>(1, 2);
-
- // Defines second preprocessor that imputing features.
- Preprocessor<Integer, Vector> preprocessor = new MaxAbsScalerTrainer<Integer, Vector>()
- .fit(ignite, data, vectorizer);
-
- // Creates a cache based simple dataset containing features and providing standard dataset API.
- try (SimpleDataset<?> dataset = DatasetFactory.createSimpleDataset(ignite, data, preprocessor)) {
- new DatasetHelper(dataset).describe();
- }
-
- System.out.println(">>> Max abs example completed.");
- }
- finally {
- data.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- *
- */
- private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
- CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
-
- persons.put(1, new DenseVector(new Serializable[] {"Mike", 42, 10000}));
- persons.put(2, new DenseVector(new Serializable[] {"John", 32, 64000}));
- persons.put(3, new DenseVector(new Serializable[] {"George", 53, 120000}));
- persons.put(4, new DenseVector(new Serializable[] {"Karl", 24, 70000}));
-
- return persons;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/MinMaxScalerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/MinMaxScalerExample.java
deleted file mode 100644
index 89cf8dad55a..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/MinMaxScalerExample.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing;
-
-import java.io.Serializable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.DatasetHelper;
-import org.apache.ignite.ml.dataset.DatasetFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.dataset.primitive.SimpleDataset;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.minmaxscaling.MinMaxScalerTrainer;
-
-/**
- * Example that shows how to use MinMaxScaler preprocessor to scale the given data.
- * <p>
- * Machine learning preprocessors are built as a chain. Most often a first preprocessor is a feature extractor as shown
- * in this example. The second preprocessor here is a MinMaxScaler preprocessor which is built on top of the feature
- * extractor and represents a chain of itself and the underlying feature extractor.</p>
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it defines preprocessors that extract features from an upstream data and normalize their values.</p>
- * <p>
- * Finally, it creates the dataset based on the processed data and uses Dataset API to find and output various
- * statistical metrics of the data.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this functionality further.</p>
- */
-public class MinMaxScalerExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> MinMax preprocessing example started.");
-
- IgniteCache<Integer, Vector> data = null;
- try {
- data = createCache(ignite);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer
- = new DummyVectorizer<>(1, 2);
-
- // Defines second preprocessor that imputing features.
- Preprocessor<Integer, Vector> preprocessor = new MinMaxScalerTrainer<Integer, Vector>()
- .fit(ignite, data, vectorizer);
-
- // Creates a cache based simple dataset containing features and providing standard dataset API.
- try (SimpleDataset<?> dataset = DatasetFactory.createSimpleDataset(ignite, data, preprocessor)) {
- new DatasetHelper(dataset).describe();
- }
-
- System.out.println(">>> MinMax preprocessing example completed.");
- }
- finally {
- data.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- *
- */
- private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
- CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
-
- persons.put(1, new DenseVector(new Serializable[] {"Mike", 42, 10000}));
- persons.put(2, new DenseVector(new Serializable[] {"John", 32, 64000}));
- persons.put(3, new DenseVector(new Serializable[] {"George", 53, 120000}));
- persons.put(4, new DenseVector(new Serializable[] {"Karl", 24, 70000}));
-
- return persons;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/NormalizationExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/NormalizationExample.java
deleted file mode 100644
index d2eb5463a1c..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/NormalizationExample.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing;
-
-import java.io.Serializable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.DatasetHelper;
-import org.apache.ignite.ml.dataset.DatasetFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.dataset.primitive.SimpleDataset;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.normalization.NormalizationTrainer;
-
-/**
- * Example that shows how to use normalization preprocessor to normalize each vector in the given data.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it defines preprocessors that extract features from an upstream data and normalize their values.</p>
- * <p>
- * Finally, it creates the dataset based on the processed data and uses Dataset API to find and output various
- * statistical metrics of the data.</p>
- * <p>
- * You can change the test data used in this example and re-run it to explore this functionality further.</p>
- */
-public class NormalizationExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Normalization example started.");
-
- IgniteCache<Integer, Vector> data = null;
- try {
- data = createCache(ignite);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer
- = new DummyVectorizer<>(1, 2);
-
- // Defines second preprocessor that normalizes features.
- Preprocessor<Integer, Vector> preprocessor = new NormalizationTrainer<Integer, Vector>()
- .withP(1)
- .fit(ignite, data, vectorizer);
-
- // Creates a cache based simple dataset containing features and providing standard dataset API.
- try (SimpleDataset<?> dataset = DatasetFactory.createSimpleDataset(ignite, data, preprocessor)) {
- new DatasetHelper(dataset).describe();
- }
-
- System.out.println(">>> Normalization example completed.");
- }
- finally {
- data.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- *
- */
- private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
- CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
-
- persons.put(1, new DenseVector(new Serializable[] {"Mike", 10, 20}));
- persons.put(2, new DenseVector(new Serializable[] {"John", 20, 10}));
- persons.put(3, new DenseVector(new Serializable[] {"George", 30, 0}));
- persons.put(4, new DenseVector(new Serializable[] {"Karl", 25, 15}));
-
- return persons;
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/StandardScalerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/StandardScalerExample.java
deleted file mode 100644
index 3ae0b9f7e85..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/StandardScalerExample.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing;
-
-import java.io.Serializable;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.DatasetHelper;
-import org.apache.ignite.ml.dataset.DatasetFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.dataset.primitive.SimpleDataset;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.math.primitives.vector.impl.DenseVector;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.standardscaling.StandardScalerTrainer;
-
-/**
- * Example that shows how to use StandardScaler preprocessor to scale the given data.
- * <p>
- * Machine learning preprocessors are built as a chain. Most often the first preprocessor is a feature extractor as
- * shown in this example. The second preprocessor here is a {@code StandardScaler} preprocessor which is built on top of
- * the feature extractor and represents a chain of itself and the underlying feature extractor.
- */
-public class StandardScalerExample {
- /**
- * Run example.
- */
- public static void main(String[] args) throws Exception {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Standard scaler example started.");
-
- IgniteCache<Integer, Vector> data = null;
- try {
- data = createCache(ignite);
-
- Vectorizer<Integer, Vector, Integer, Double> vectorizer
- = new DummyVectorizer<>(1, 2);
-
- // Defines second preprocessor that scales features.
- Preprocessor<Integer, Vector> preprocessor = new StandardScalerTrainer<Integer, Vector>()
- .fit(ignite, data, vectorizer);
-
- // Creates a cache based simple dataset containing features and providing standard dataset API.
- try (SimpleDataset<?> dataset = DatasetFactory.createSimpleDataset(ignite, data, preprocessor)) {
- new DatasetHelper(dataset).describe();
- }
-
- System.out.println(">>> Standard scaler example completed.");
- }
- finally {
- data.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- *
- */
- private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
- CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
-
- cacheConfiguration.setName("PERSONS");
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
-
- IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
-
- persons.put(1, new DenseVector(new Serializable[] {"Mike", 42, 10000}));
- persons.put(2, new DenseVector(new Serializable[] {"John", 32, 64000}));
- persons.put(3, new DenseVector(new Serializable[] {"George", 53, 120000}));
- persons.put(4, new DenseVector(new Serializable[] {"Karl", 24, 70000}));
-
- return persons;
- }
-}
-
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/EncoderExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/EncoderExample.java
deleted file mode 100644
index 233cb13b913..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/EncoderExample.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing.encoding;
-
-import java.io.FileNotFoundException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.ObjectArrayVectorizer;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.encoding.EncoderTrainer;
-import org.apache.ignite.ml.preprocessing.encoding.EncoderType;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.tree.DecisionTreeClassificationTrainer;
-import org.apache.ignite.ml.tree.DecisionTreeModel;
-
-/**
- * Example that shows how to use String Encoder preprocessor to encode features presented as a strings.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data (based on mushrooms dataset).</p>
- * <p>
- * After that it defines preprocessors that extract features from an upstream data and encode string values (categories)
- * to double values in specified range.</p>
- * <p>
- * Then, it trains the model based on the processed data using decision tree classification.</p>
- * <p>
- * Finally, this example uses {@link Evaluator} functionality to compute metrics from predictions.</p>
- */
-public class EncoderExample {
- /**
- * Run example.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Train Decision Tree model on mushrooms.csv dataset.");
-
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- try {
- IgniteCache<Integer, Object[]> dataCache = new SandboxMLCache(ignite)
- .fillObjectCacheWithDoubleLabels(MLSandboxDatasets.MUSHROOMS);
-
- final Vectorizer<Integer, Object[], Integer, Object> vectorizer = new ObjectArrayVectorizer<Integer>(1, 2, 3).labeled(0);
-
- Preprocessor<Integer, Object[]> encoderPreprocessor = new EncoderTrainer<Integer, Object[]>()
- .withEncoderType(EncoderType.STRING_ENCODER)
- .withEncodedFeature(0)
- .withEncodedFeature(1)
- .withEncodedFeature(2)
- .fit(ignite,
- dataCache,
- vectorizer
- );
-
- DecisionTreeClassificationTrainer trainer = new DecisionTreeClassificationTrainer(5, 0);
-
- // Train decision tree model.
- DecisionTreeModel mdl = trainer.fit(
- ignite,
- dataCache,
- encoderPreprocessor
- );
-
- System.out.println("\n>>> Trained model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- encoderPreprocessor,
- new Accuracy<>()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
-
- System.out.println(">>> Train Decision Tree model on mushrooms.csv dataset.");
-
- }
- catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/EncoderExampleWithNormalization.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/EncoderExampleWithNormalization.java
deleted file mode 100644
index 7270b03e401..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/EncoderExampleWithNormalization.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing.encoding;
-
-import java.io.FileNotFoundException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.ObjectArrayVectorizer;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.encoding.EncoderTrainer;
-import org.apache.ignite.ml.preprocessing.encoding.EncoderType;
-import org.apache.ignite.ml.preprocessing.normalization.NormalizationTrainer;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.tree.DecisionTreeClassificationTrainer;
-import org.apache.ignite.ml.tree.DecisionTreeModel;
-
-/**
- * Example that shows how to combine together two preprocessors: String Encoder preprocessor to encode features presented as a strings
- * and Normalizer to normalize data presented as doubles.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data (based on mushrooms dataset).</p>
- * <p>
- * After that it defines preprocessors that extract features from an upstream data and encode string values (categories)
- * to double values in specified range.</p>
- * <p>
- * Then, it trains the model based on the processed data using decision tree classification.</p>
- * <p>
- * Finally, this example uses {@link Evaluator} functionality to compute metrics from predictions.</p>
- */
-public class EncoderExampleWithNormalization {
- /**
- * Run example.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Train Decision Tree model on mushrooms.csv dataset.");
-
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- try {
- IgniteCache<Integer, Object[]> dataCache = new SandboxMLCache(ignite)
- .fillObjectCacheWithDoubleLabels(MLSandboxDatasets.MUSHROOMS);
-
- final Vectorizer<Integer, Object[], Integer, Object> vectorizer = new ObjectArrayVectorizer<Integer>(1, 2, 3).labeled(0);
-
- Preprocessor<Integer, Object[]> encoderPreprocessor = new EncoderTrainer<Integer, Object[]>()
- .withEncoderType(EncoderType.STRING_ENCODER)
- .withEncodedFeature(0)
- .withEncodedFeature(1)
- .withEncodedFeature(2)
- .fit(ignite,
- dataCache,
- vectorizer
- );
-
- // Defines second preprocessor that normalizes features.
- Preprocessor<Integer, Object[]> normalizer = new NormalizationTrainer<Integer, Object[]>()
- .withP(1)
- .fit(ignite, dataCache, encoderPreprocessor);
-
- DecisionTreeClassificationTrainer trainer = new DecisionTreeClassificationTrainer(5, 0);
-
- // Train decision tree model.
- DecisionTreeModel mdl = trainer.fit(
- ignite,
- dataCache,
- normalizer
- );
-
- System.out.println("\n>>> Trained model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- normalizer,
- new Accuracy<>()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
-
- System.out.println(">>> Tutorial step 3 (categorial with One-hot encoder) example started.");
-
- }
- catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/LabelEncoderExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/LabelEncoderExample.java
deleted file mode 100644
index 3547d7e2010..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/LabelEncoderExample.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing.encoding;
-
-import java.io.FileNotFoundException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.ObjectArrayVectorizer;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.encoding.EncoderTrainer;
-import org.apache.ignite.ml.preprocessing.encoding.EncoderType;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.tree.DecisionTreeClassificationTrainer;
-import org.apache.ignite.ml.tree.DecisionTreeModel;
-
-/**
- * Example that shows how to use Label Encoder preprocessor to encode labels presented as a strings.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data (based on mushrooms dataset).</p>
- * <p>
- * After that it defines preprocessors that extract features from an upstream data and encode string values (categories)
- * to double values in specified range.</p>
- * <p>
- * Then, it trains the model based on the processed data using decision tree classification.</p>
- * <p>
- * Finally, this example uses {@link Evaluator} functionality to compute metrics from predictions.</p>
- */
-public class LabelEncoderExample {
- /**
- * Run example.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Train Decision Tree model on mushrooms.csv dataset.");
-
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- try {
- IgniteCache<Integer, Object[]> dataCache = new SandboxMLCache(ignite)
- .fillObjectCacheWithCategoricalData(MLSandboxDatasets.MUSHROOMS);
-
- final Vectorizer<Integer, Object[], Integer, Object> vectorizer = new ObjectArrayVectorizer<Integer>(1, 2).labeled(0);
-
- Preprocessor<Integer, Object[]> strEncoderPreprocessor = new EncoderTrainer<Integer, Object[]>()
- .withEncoderType(EncoderType.STRING_ENCODER)
- .withEncodedFeature(0)
- .withEncodedFeature(1)
- .fit(ignite,
- dataCache,
- vectorizer
- );
-
- Preprocessor<Integer, Object[]> lbEncoderPreprocessor = new EncoderTrainer<Integer, Object[]>()
- .withEncoderType(EncoderType.LABEL_ENCODER)
- .fit(ignite,
- dataCache,
- strEncoderPreprocessor
- );
-
- DecisionTreeClassificationTrainer trainer = new DecisionTreeClassificationTrainer(5, 0);
-
- // Train decision tree model.
- DecisionTreeModel mdl = trainer.fit(
- ignite,
- dataCache,
- lbEncoderPreprocessor
- );
-
- System.out.println("\n>>> Trained model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- lbEncoderPreprocessor,
- new Accuracy()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
-
- System.out.println(">>> Train Decision Tree model on mushrooms.csv dataset.");
-
- }
- catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/TargetEncoderExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/TargetEncoderExample.java
deleted file mode 100644
index 82089acd8a0..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/TargetEncoderExample.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.preprocessing.encoding;
-
-import java.io.FileNotFoundException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.composition.ModelsComposition;
-import org.apache.ignite.ml.composition.boosting.GDBTrainer;
-import org.apache.ignite.ml.composition.boosting.convergence.median.MedianOfMedianConvergenceCheckerFactory;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.ObjectArrayVectorizer;
-import org.apache.ignite.ml.preprocessing.Preprocessor;
-import org.apache.ignite.ml.preprocessing.encoding.EncoderTrainer;
-import org.apache.ignite.ml.preprocessing.encoding.EncoderType;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.classification.Accuracy;
-import org.apache.ignite.ml.tree.boosting.GDBBinaryClassifierOnTreesTrainer;
-
-/**
- * Example that shows how to use Target Encoder preprocessor to encode labels presented as a mean target value.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with test data (based on mushrooms dataset).</p>
- * <p>
- * After that it defines preprocessors that extract features from an upstream data and encode category with avarage
- * target value (categories). </p>
- * <p>
- * Then, it trains the model based on the processed data using gradient boosing decision tree classification.</p>
- * <p>
- * Finally, this example uses {@link Evaluator} functionality to compute metrics from predictions.</p>
- *
- * <p>Daniele Miccii-Barreca (2001). A Preprocessing Scheme for High-Cardinality Categorical
- * Attributes in Classification and Prediction Problems. SIGKDD Explor. Newsl. 3, 1.
- * From http://dx.doi.org/10.1145/507533.507538</p>
- */
-public class TargetEncoderExample {
- /**
- * Run example.
- */
- public static void main(String[] args) {
- System.out.println();
- System.out.println(">>> Train Gradient Boosing Decision Tree model on amazon-employee-access-challenge_train.csv dataset.");
-
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- try {
- IgniteCache<Integer, Object[]> dataCache = new SandboxMLCache(ignite)
- .fillObjectCacheWithCategoricalData(MLSandboxDatasets.AMAZON_EMPLOYEE_ACCESS);
-
- Set<Integer> featuresIndexies = new HashSet<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9));
- Set<Integer> targetEncodedfeaturesIndexies = new HashSet<>(Arrays.asList(1, 5, 6));
- Integer targetIndex = 0;
-
- final Vectorizer<Integer, Object[], Integer, Object> vectorizer =
- new ObjectArrayVectorizer<Integer>(featuresIndexies.toArray(new Integer[0])).labeled(targetIndex);
-
- Preprocessor<Integer, Object[]> strEncoderPreprocessor = new EncoderTrainer<Integer, Object[]>()
- .withEncoderType(EncoderType.STRING_ENCODER)
- .withEncodedFeature(0)
- .withEncodedFeatures(featuresIndexies)
- .fit(ignite,
- dataCache,
- vectorizer
- );
-
- Preprocessor<Integer, Object[]> targetEncoderProcessor = new EncoderTrainer<Integer, Object[]>()
- .withEncoderType(EncoderType.TARGET_ENCODER)
- .labeled(0)
- .withEncodedFeatures(targetEncodedfeaturesIndexies)
- .minSamplesLeaf(1)
- .minCategorySize(1L)
- .smoothing(1d)
- .fit(ignite,
- dataCache,
- strEncoderPreprocessor
- );
-
- Preprocessor<Integer, Object[]> lbEncoderPreprocessor = new EncoderTrainer<Integer, Object[]>()
- .withEncoderType(EncoderType.LABEL_ENCODER)
- .fit(ignite,
- dataCache,
- targetEncoderProcessor
- );
-
- GDBTrainer trainer = new GDBBinaryClassifierOnTreesTrainer(0.5, 500, 4, 0.)
- .withCheckConvergenceStgyFactory(new MedianOfMedianConvergenceCheckerFactory(0.1));
-
- // Train model.
- ModelsComposition mdl = trainer.fit(
- ignite,
- dataCache,
- lbEncoderPreprocessor
- );
-
- System.out.println("\n>>> Trained model: " + mdl);
-
- double accuracy = Evaluator.evaluate(
- dataCache,
- mdl,
- lbEncoderPreprocessor,
- new Accuracy()
- );
-
- System.out.println("\n>>> Accuracy " + accuracy);
- System.out.println("\n>>> Test Error " + (1 - accuracy));
-
- System.out.println(">>> Train Gradient Boosing Decision Tree model on amazon-employee-access-challenge_train.csv dataset.");
-
- }
- catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- finally {
- System.out.flush();
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/package-info.java
deleted file mode 100644
index 529efeb289b..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/encoding/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Machine learning encoding examples.
- */
-
-package org.apache.ignite.examples.ml.preprocessing.encoding;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/package-info.java b/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/package-info.java
deleted file mode 100644
index ad80177d52b..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/preprocessing/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-/**
- * <!-- Package description. --> Machine learning pre-processing examples.
- */
-
-package org.apache.ignite.examples.ml.preprocessing;
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/recommendation/MovieLensExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/recommendation/MovieLensExample.java
deleted file mode 100644
index b5c798403c0..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/recommendation/MovieLensExample.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.recommendation;
-
-import java.io.IOException;
-import javax.cache.Cache;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.ScanQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.impl.cache.CacheBasedDatasetBuilder;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.recommendation.ObjectSubjectRatingTriplet;
-import org.apache.ignite.ml.recommendation.RecommendationModel;
-import org.apache.ignite.ml.recommendation.RecommendationTrainer;
-
-/**
- * Example of recommendation system based on MovieLens dataset (see https://grouplens.org/datasets/movielens/).
- * In this example we create a cache with MovieLens rating data. Each entry in this cache represents a rating point
- * (rating set by a single user to a single movie). Then we pass this cache to {@link RecommendationTrainer} and so
- * that train {@link RecommendationModel}. This model predicts rating with assumed to be set by any user to any movie.
- * When model is ready we calculate R2 score.
- */
-public class MovieLensExample {
- /** Run example. */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Recommendation system over cache based dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, RatingPoint> movielensCache = loadMovieLensDataset(ignite, 10_000);
- try {
- LearningEnvironmentBuilder envBuilder = LearningEnvironmentBuilder.defaultBuilder().withRNGSeed(1);
- RecommendationTrainer trainer = new RecommendationTrainer()
- .withMaxIterations(-1)
- .withMinMdlImprovement(10)
- .withBatchSize(10)
- .withLearningRate(10)
- .withLearningEnvironmentBuilder(envBuilder)
- .withTrainerEnvironment(envBuilder.buildForTrainer());
-
- RecommendationModel<Integer, Integer> mdl = trainer.fit(
- new CacheBasedDatasetBuilder<>(ignite, movielensCache)
- );
-
- double mean = 0;
- try (QueryCursor<Cache.Entry<Integer, RatingPoint>> cursor = movielensCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, RatingPoint> e : cursor) {
- ObjectSubjectRatingTriplet<Integer, Integer> triplet = e.getValue();
- mean += triplet.getRating();
- }
- mean /= movielensCache.size();
- }
-
- double tss = 0, rss = 0;
- try (QueryCursor<Cache.Entry<Integer, RatingPoint>> cursor = movielensCache.query(new ScanQuery<>())) {
- for (Cache.Entry<Integer, RatingPoint> e : cursor) {
- ObjectSubjectRatingTriplet<Integer, Integer> triplet = e.getValue();
- tss += Math.pow(triplet.getRating() - mean, 2);
- rss += Math.pow(triplet.getRating() - mdl.predict(triplet), 2);
- }
- }
-
- double r2 = 1.0 - rss / tss;
-
- System.out.println("R2 score: " + r2);
-
- }
- finally {
- movielensCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Loads MovieLens dataset into cache.
- *
- * @param ignite Ignite instance.
- * @param cnt Number of rating point to be loaded.
- * @return Ignite cache with loaded MovieLens dataset.
- * @throws IOException If dataset not found.
- */
- private static IgniteCache<Integer, RatingPoint> loadMovieLensDataset(Ignite ignite, int cnt) throws IOException {
- CacheConfiguration<Integer, RatingPoint> cacheConfiguration = new CacheConfiguration<>();
- cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 100));
- cacheConfiguration.setName("MOVIELENS");
-
- IgniteCache<Integer, RatingPoint> dataCache = ignite.createCache(cacheConfiguration);
-
- int seq = 0;
- for (String s : new SandboxMLCache(ignite).loadDataset(MLSandboxDatasets.MOVIELENS)) {
- String[] line = s.split(",");
- int userId = Integer.valueOf(line[0]);
- int movieId = Integer.valueOf(line[1]);
- double rating = Double.valueOf(line[2]);
-
- dataCache.put(seq++, new RatingPoint(movieId, userId, rating));
-
- if (seq == cnt)
- break;
- }
-
- return dataCache;
- }
-
- /**
- * Rating point that represents a result of assesment of a single movie by a single user.
- */
- private static class RatingPoint extends ObjectSubjectRatingTriplet<Integer, Integer> {
- /** */
- private static final long serialVersionUID = -7301471870043910312L;
-
- /**
- * Constructs a new instance of rating point.
- *
- * @param movieId Movie identifier.
- * @param userId User identifier..
- * @param rating Rating.
- */
- public RatingPoint(Integer movieId, Integer userId, Double rating) {
- super(movieId, userId, rating);
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/recommendation/MovieLensSQLExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/recommendation/MovieLensSQLExample.java
deleted file mode 100644
index dbfb55394f3..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/recommendation/MovieLensSQLExample.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.recommendation;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.List;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.inference.IgniteModelStorageUtil;
-import org.apache.ignite.ml.recommendation.RecommendationModel;
-import org.apache.ignite.ml.recommendation.RecommendationTrainer;
-import org.apache.ignite.ml.sql.SQLFunctions;
-import org.apache.ignite.ml.sql.SqlDatasetBuilder;
-
-/**
- * Example of recommendation system based on MovieLens dataset (see https://grouplens.org/datasets/movielens/) and SQL.
- * In this example we create a cache with MovieLens rating data. Each entry in this cache represents a rating point
- * (rating set by a single user to a single movie). Then we pass this cache to {@link RecommendationTrainer} and so
- * that train {@link RecommendationModel}. This model predicts rating with assumed to be set by any user to any movie.
- * When model is ready we calculate R2 score.
- */
-public class MovieLensSQLExample {
- /** Dummy cache name. */
- private static final String DUMMY_CACHE_NAME = "dummy_cache";
-
- /** Run example. */
- public static void main(String[] args) throws IOException {
- System.out.println();
- System.out.println(">>> Recommendation system over cache based dataset usage example started.");
- // Start ignite grid.
- try (Ignite ignite = Ignition.start("examples/config/example-ignite-ml.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- // Dummy cache is required to perform SQL queries.
- CacheConfiguration<?, ?> cacheCfg = new CacheConfiguration<>(DUMMY_CACHE_NAME)
- .setSqlSchema("PUBLIC")
- .setSqlFunctionClasses(SQLFunctions.class);
-
- IgniteCache<?, ?> cache = null;
- try {
- cache = ignite.getOrCreateCache(cacheCfg);
-
- System.out.println(">>> Creating table with training data...");
- cache.query(new SqlFieldsQuery("create table ratings (\n" +
- " rating_id int primary key,\n" +
- " movie_id int,\n" +
- " user_id int,\n" +
- " rating float\n" +
- ") with \"template=partitioned\";")).getAll();
-
- System.out.println(">>> Loading data...");
- loadMovieLensDataset(ignite, cache, 10_000);
-
- LearningEnvironmentBuilder envBuilder = LearningEnvironmentBuilder.defaultBuilder().withRNGSeed(1);
- RecommendationTrainer trainer = new RecommendationTrainer()
- .withMaxIterations(100)
- .withBatchSize(10)
- .withLearningRate(10)
- .withLearningEnvironmentBuilder(envBuilder)
- .withTrainerEnvironment(envBuilder.buildForTrainer());
-
- System.out.println(">>> Training model...");
- RecommendationModel<Serializable, Serializable> mdl = trainer.fit(
- new SqlDatasetBuilder(ignite, "SQL_PUBLIC_RATINGS"),
- "movie_id",
- "user_id",
- "rating"
- );
-
- System.out.println("Saving model into model storage...");
- IgniteModelStorageUtil.saveModel(ignite, mdl, "movielens_model");
-
- System.out.println("Inference...");
- try (QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select " +
- "rating, " +
- "predictRecommendation('movielens_model', movie_id, user_id) as prediction " +
- "from ratings"))) {
- for (List<?> row : cursor) {
- double rating = (Double)row.get(0);
- double prediction = (Double)row.get(1);
- System.out.println("Rating: " + rating + ", prediction: " + prediction);
- }
- }
- }
- finally {
- cache.query(new SqlFieldsQuery("DROP TABLE ratings"));
- cache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Loads MovieLens dataset into cache.
- *
- * @param ignite Ignite instance.
- * @param cnt Number of rating point to be loaded.
- * @throws IOException If dataset not found.
- */
- private static void loadMovieLensDataset(Ignite ignite, IgniteCache<?, ?> cache, int cnt) throws IOException {
- SqlFieldsQuery qry = new SqlFieldsQuery("insert into ratings (rating_id, movie_id, user_id, rating) values (?, ?, ?, ?)");
- int seq = 0;
- for (String s : new SandboxMLCache(ignite).loadDataset(MLSandboxDatasets.MOVIELENS)) {
- String[] line = s.split(",");
-
- int userId = Integer.valueOf(line[0]);
- int movieId = Integer.valueOf(line[1]);
- double rating = Double.valueOf(line[2]);
-
- qry.setArgs(seq++, movieId, userId, rating);
- cache.query(qry);
-
- if (seq == cnt)
- break;
- }
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/BostonHousePricesPredictionExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/BostonHousePricesPredictionExample.java
deleted file mode 100644
index 9d2b31683c8..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/BostonHousePricesPredictionExample.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.regression.linear;
-
-import java.io.IOException;
-import java.util.function.BiFunction;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.environment.LearningEnvironmentBuilder;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionLSQRTrainer;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-import org.apache.ignite.ml.selection.split.TrainTestDatasetSplitter;
-import org.apache.ignite.ml.selection.split.TrainTestSplit;
-import org.apache.ignite.ml.trainers.DatasetTrainer;
-
-/**
- * Example of using Linear Regression model in Apache Ignite for house prices prediction.
- * <p>
- * Description of model can be found in: https://en.wikipedia.org/wiki/Linear_regression . Original dataset can be
- * downloaded from: https://archive.ics.uci.edu/ml/machine-learning-databases/housing/ . Copy of dataset are stored in:
- * modules/ml/src/main/resources/datasets/boston_housing_dataset.txt . Score for regression estimation: R^2 (coefficient
- * of determination). Description of score evaluation can be found in:
- * https://stattrek.com/statistics/dictionary.aspx?definition=coefficient_of_determination
- * .
- */
-public class BostonHousePricesPredictionExample {
- /**
- * Runs example.
- */
- public static void main(String[] args) throws IOException {
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- System.out.println(">>> Ignite grid started.");
-
- IgniteCache<Integer, Vector> dataCache = null;
- try {
- System.out.println(">>> Fill dataset cache.");
- dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.BOSTON_HOUSE_PRICES);
- DatasetTrainer<LinearRegressionModel, Double> trainer = new LinearRegressionLSQRTrainer()
- .withEnvironmentBuilder(LearningEnvironmentBuilder.defaultBuilder().withRNGSeed(0));
-
- // This vectorizer works with values in cache of Vector class.
- Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>()
- .labeled(Vectorizer.LabelCoordinate.FIRST); // FIRST means "label are stored at first coordinate of vector"
-
- // Splits dataset to train and test samples with 80/20 proportion.
- TrainTestSplit<Integer, Vector> split = new TrainTestDatasetSplitter<Integer, Vector>().split(0.8);
-
- System.out.println(">>> Start training.");
- LinearRegressionModel mdl = trainer.fit(
- ignite, dataCache,
- split.getTrainFilter(),
- vectorizer
- );
-
- System.out.println(">>> Perform scoring.");
- double score = Evaluator.evaluate(
- dataCache,
- split.getTestFilter(),
- mdl,
- vectorizer,
- MetricName.R2
- );
-
- System.out.println(">>> Model: " + toString(mdl));
- System.out.println(">>> R^2 score: " + score);
- }
- finally {
- if (dataCache != null)
- dataCache.destroy();
- }
- }
- finally {
- System.out.flush();
- }
- }
-
- /**
- * Prepare pretty string for model.
- *
- * @param mdl Model.
- * @return String representation of model.
- */
- private static String toString(LinearRegressionModel mdl) {
- BiFunction<Integer, Double, String> formatter = (idx, val) -> String.format("%.2f*f%d", val, idx);
-
- Vector weights = mdl.weights();
- StringBuilder sb = new StringBuilder(formatter.apply(0, weights.get(0)));
-
- for (int fid = 1; fid < weights.size(); fid++) {
- double w = weights.get(fid);
- sb.append(" ").append(w > 0 ? "+" : "-").append(" ")
- .append(formatter.apply(fid, Math.abs(w)));
- }
-
- double intercept = mdl.intercept();
- sb.append(" ").append(intercept > 0 ? "+" : "-").append(" ")
- .append(String.format("%.2f", Math.abs(intercept)));
- return sb.toString();
- }
-}
diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/LinearRegressionLSQRTrainerExample.java b/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/LinearRegressionLSQRTrainerExample.java
deleted file mode 100644
index e6ab6f6e43a..00000000000
--- a/examples/src/main/java/org/apache/ignite/examples/ml/regression/linear/LinearRegressionLSQRTrainerExample.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */
-
-package org.apache.ignite.examples.ml.regression.linear;
-
-import java.io.IOException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.ml.util.MLSandboxDatasets;
-import org.apache.ignite.examples.ml.util.SandboxMLCache;
-import org.apache.ignite.ml.dataset.feature.extractor.Vectorizer;
-import org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer;
-import org.apache.ignite.ml.math.primitives.vector.Vector;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionLSQRTrainer;
-import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
-import org.apache.ignite.ml.selection.scoring.evaluator.Evaluator;
-import org.apache.ignite.ml.selection.scoring.metric.MetricName;
-
-/**
- * Run linear regression model based on <a href="http://web.stanford.edu/group/SOL/software/lsqr/">LSQR algorithm</a>
- * ({@link LinearRegressionLSQRTrainer}) over cached dataset.
- * <p>
- * Code in this example launches Ignite grid and fills the cache with simple test data.</p>
- * <p>
- * After that it trains the linear regression model based on the specified data.</p>
- * <p>
- * Finally, this example loops over the test set of data points, applies the trained model to predict the target value
- * and compares prediction to expected outcome (ground truth).</p>
- * <p>
... 238541 lines suppressed ...