diff --git a/sdks/python/apache_beam/examples/inference/xgboost_iris_classification.py b/sdks/python/apache_beam/examples/inference/xgboost_iris_classification.py index fa0582905e94..6fedd6ee5183 100644 --- a/sdks/python/apache_beam/examples/inference/xgboost_iris_classification.py +++ b/sdks/python/apache_beam/examples/inference/xgboost_iris_classification.py @@ -24,16 +24,14 @@ import numpy import pandas import scipy +import xgboost from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split import apache_beam as beam -import datatable -import xgboost from apache_beam.ml.inference.base import KeyedModelHandler from apache_beam.ml.inference.base import PredictionResult from apache_beam.ml.inference.base import RunInference -from apache_beam.ml.inference.xgboost_inference import XGBoostModelHandlerDatatable from apache_beam.ml.inference.xgboost_inference import XGBoostModelHandlerNumpy from apache_beam.ml.inference.xgboost_inference import XGBoostModelHandlerPandas from apache_beam.ml.inference.xgboost_inference import XGBoostModelHandlerSciPy @@ -59,7 +57,7 @@ def parse_known_args(argv): '--input_type', dest='input_type', required=True, - choices=['numpy', 'pandas', 'scipy', 'datatable'], + choices=['numpy', 'pandas', 'scipy'], help='Datatype of the input data.') parser.add_argument( '--output', @@ -122,7 +120,6 @@ def run( 'numpy': (numpy.array, XGBoostModelHandlerNumpy), 'pandas': (pandas.DataFrame, XGBoostModelHandlerPandas), 'scipy': (scipy.sparse.csr_matrix, XGBoostModelHandlerSciPy), - 'datatable': (datatable.Frame, XGBoostModelHandlerDatatable), } input_data_type, model_handler = data_types[known_args.input_type] diff --git a/sdks/python/apache_beam/ml/inference/xgboost_inference_it_test.py b/sdks/python/apache_beam/ml/inference/xgboost_inference_it_test.py index 73becf4ff104..12e8e503c628 100644 --- a/sdks/python/apache_beam/ml/inference/xgboost_inference_it_test.py +++ b/sdks/python/apache_beam/ml/inference/xgboost_inference_it_test.py @@ -77,7 +77,7 @@ def process_outputs(filepath): @unittest.skipIf( os.getenv('FORCE_XGBOOST_IT') is None and xgboost is None, 'Missing dependencies. ' - 'Test depends on xgboost and datatable') + 'Test depends on xgboost') @pytest.mark.uses_xgboost @pytest.mark.it_postcommit class XGBoostInference(unittest.TestCase): @@ -214,39 +214,6 @@ def test_iris_classification_scipy_single_batch(self): true_label, expected_prediction = expected_output.split(',') self.assertEqual(predictions_dict[true_label], expected_prediction) - def test_iris_classification_datatable_single_batch(self): - test_pipeline = TestPipeline(is_integration_test=True) - input_type = 'datatable' - output_file_dir = '/tmp' - output_file = '/'.join( - [output_file_dir, str(uuid.uuid4()), 'datatable_single_batch.txt']) - model_state_path = 'gs://apache-beam-ml/models/xgboost.iris_classifier.json' - extra_opts = { - 'input_type': input_type, - 'output': output_file, - 'model_state': model_state_path, - 'no_split': True - } - - xgboost_iris_classification.run( - test_pipeline.get_full_options_as_args(**extra_opts), - save_main_session=False) - self.assertEqual(FileSystems().exists(output_file), True) - - expected_outputs = EXPECTED_OUTPUT_SINGLE_BATCHES - - predicted_outputs = process_outputs(output_file) - self.assertEqual(len(expected_outputs), len(predicted_outputs)) - - predictions_dict = {} - for predicted_output in predicted_outputs: - true_label, prediction = predicted_output.split(',') - predictions_dict[true_label] = prediction - - for expected_output in expected_outputs: - true_label, expected_prediction = expected_output.split(',') - self.assertEqual(predictions_dict[true_label], expected_prediction) - def test_iris_classification_numpy_multi_batch(self): test_pipeline = TestPipeline(is_integration_test=True) input_type = 'numpy' @@ -346,39 +313,6 @@ def test_iris_classification_scipy_multi_batch(self): true_label, expected_prediction = expected_output.split(',') self.assertEqual(predictions_dict[true_label], expected_prediction) - def test_iris_classification_datatable_multi_batch(self): - test_pipeline = TestPipeline(is_integration_test=True) - input_type = 'datatable' - output_file_dir = '/tmp' - output_file = '/'.join( - [output_file_dir, str(uuid.uuid4()), 'datatable_multi_batch.txt']) - model_state_path = 'gs://apache-beam-ml/models/xgboost.iris_classifier.json' - extra_opts = { - 'input_type': input_type, - 'output': output_file, - 'model_state': model_state_path, - 'split': True - } - - xgboost_iris_classification.run( - test_pipeline.get_full_options_as_args(**extra_opts), - save_main_session=False) - self.assertEqual(FileSystems().exists(output_file), True) - - expected_outputs = EXPECTED_OUTPUT_MULTIPLE_BATCHES - - predicted_outputs = process_outputs(output_file) - self.assertEqual(len(expected_outputs), len(predicted_outputs)) - - predictions_dict = {} - for predicted_output in predicted_outputs: - true_label, prediction = predicted_output.split(',') - predictions_dict[true_label] = prediction - - for expected_output in expected_outputs: - true_label, expected_prediction = expected_output.split(',') - self.assertEqual(predictions_dict[true_label], expected_prediction) - if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) diff --git a/sdks/python/apache_beam/ml/inference/xgboost_inference_test.py b/sdks/python/apache_beam/ml/inference/xgboost_inference_test.py index 33b70c737d07..15ff7e436428 100644 --- a/sdks/python/apache_beam/ml/inference/xgboost_inference_test.py +++ b/sdks/python/apache_beam/ml/inference/xgboost_inference_test.py @@ -34,7 +34,6 @@ from apache_beam.ml.inference import RunInference from apache_beam.ml.inference.base import KeyedModelHandler from apache_beam.ml.inference.base import PredictionResult - from apache_beam.ml.inference.xgboost_inference import XGBoostModelHandlerDatatable from apache_beam.ml.inference.xgboost_inference import XGBoostModelHandlerNumpy from apache_beam.ml.inference.xgboost_inference import XGBoostModelHandlerPandas from apache_beam.ml.inference.xgboost_inference import XGBoostModelHandlerSciPy diff --git a/sdks/python/apache_beam/ml/inference/xgboost_tests_requirements.txt b/sdks/python/apache_beam/ml/inference/xgboost_tests_requirements.txt index b1936b4149e4..d90af4070d75 100644 --- a/sdks/python/apache_beam/ml/inference/xgboost_tests_requirements.txt +++ b/sdks/python/apache_beam/ml/inference/xgboost_tests_requirements.txt @@ -15,5 +15,4 @@ # limitations under the License. # -datatable>=1.1.0,<2 xgboost>=2.0.0,<4