snowflake-ml-python 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snowflake/ml/_internal/env_utils.py +2 -1
- snowflake/ml/_internal/file_utils.py +35 -40
- snowflake/ml/_internal/telemetry.py +5 -8
- snowflake/ml/_internal/utils/identifier.py +74 -7
- snowflake/ml/_internal/utils/uri.py +7 -2
- snowflake/ml/model/_core_requirements.py +1 -1
- snowflake/ml/model/_deploy_client/image_builds/base_image_builder.py +15 -0
- snowflake/ml/model/_deploy_client/image_builds/client_image_builder.py +259 -0
- snowflake/ml/model/_deploy_client/image_builds/docker_context.py +89 -0
- snowflake/ml/model/_deploy_client/image_builds/gunicorn_run.sh +24 -0
- snowflake/ml/model/_deploy_client/image_builds/inference_server/main.py +118 -0
- snowflake/ml/model/_deploy_client/image_builds/templates/dockerfile_template +40 -0
- snowflake/ml/model/_deploy_client/snowservice/deploy.py +199 -0
- snowflake/ml/model/_deploy_client/snowservice/deploy_options.py +88 -0
- snowflake/ml/model/_deploy_client/snowservice/templates/service_spec_template +24 -0
- snowflake/ml/model/_deploy_client/utils/constants.py +47 -0
- snowflake/ml/model/_deploy_client/utils/snowservice_client.py +178 -0
- snowflake/ml/model/_deploy_client/warehouse/deploy.py +25 -28
- snowflake/ml/model/_deploy_client/warehouse/infer_template.py +7 -4
- snowflake/ml/model/_deployer.py +14 -27
- snowflake/ml/model/_env.py +4 -4
- snowflake/ml/model/_handlers/_base.py +3 -1
- snowflake/ml/model/_handlers/custom.py +14 -2
- snowflake/ml/model/_handlers/pytorch.py +186 -0
- snowflake/ml/model/_handlers/sklearn.py +14 -8
- snowflake/ml/model/_handlers/snowmlmodel.py +14 -9
- snowflake/ml/model/_handlers/torchscript.py +180 -0
- snowflake/ml/model/_handlers/xgboost.py +19 -9
- snowflake/ml/model/_model.py +27 -21
- snowflake/ml/model/_model_meta.py +33 -19
- snowflake/ml/model/model_signature.py +446 -66
- snowflake/ml/model/type_hints.py +28 -15
- snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +79 -43
- snowflake/ml/modeling/cluster/affinity_propagation.py +79 -43
- snowflake/ml/modeling/cluster/agglomerative_clustering.py +79 -43
- snowflake/ml/modeling/cluster/birch.py +79 -43
- snowflake/ml/modeling/cluster/bisecting_k_means.py +79 -43
- snowflake/ml/modeling/cluster/dbscan.py +79 -43
- snowflake/ml/modeling/cluster/feature_agglomeration.py +79 -43
- snowflake/ml/modeling/cluster/k_means.py +79 -43
- snowflake/ml/modeling/cluster/mean_shift.py +79 -43
- snowflake/ml/modeling/cluster/mini_batch_k_means.py +79 -43
- snowflake/ml/modeling/cluster/optics.py +79 -43
- snowflake/ml/modeling/cluster/spectral_biclustering.py +79 -43
- snowflake/ml/modeling/cluster/spectral_clustering.py +79 -43
- snowflake/ml/modeling/cluster/spectral_coclustering.py +79 -43
- snowflake/ml/modeling/compose/column_transformer.py +79 -43
- snowflake/ml/modeling/compose/transformed_target_regressor.py +79 -43
- snowflake/ml/modeling/covariance/elliptic_envelope.py +79 -43
- snowflake/ml/modeling/covariance/empirical_covariance.py +79 -43
- snowflake/ml/modeling/covariance/graphical_lasso.py +79 -43
- snowflake/ml/modeling/covariance/graphical_lasso_cv.py +79 -43
- snowflake/ml/modeling/covariance/ledoit_wolf.py +79 -43
- snowflake/ml/modeling/covariance/min_cov_det.py +79 -43
- snowflake/ml/modeling/covariance/oas.py +79 -43
- snowflake/ml/modeling/covariance/shrunk_covariance.py +79 -43
- snowflake/ml/modeling/decomposition/dictionary_learning.py +79 -43
- snowflake/ml/modeling/decomposition/factor_analysis.py +79 -43
- snowflake/ml/modeling/decomposition/fast_ica.py +79 -43
- snowflake/ml/modeling/decomposition/incremental_pca.py +79 -43
- snowflake/ml/modeling/decomposition/kernel_pca.py +79 -43
- snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +79 -43
- snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +79 -43
- snowflake/ml/modeling/decomposition/pca.py +79 -43
- snowflake/ml/modeling/decomposition/sparse_pca.py +79 -43
- snowflake/ml/modeling/decomposition/truncated_svd.py +79 -43
- snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +79 -43
- snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +79 -43
- snowflake/ml/modeling/ensemble/ada_boost_classifier.py +79 -43
- snowflake/ml/modeling/ensemble/ada_boost_regressor.py +79 -43
- snowflake/ml/modeling/ensemble/bagging_classifier.py +79 -43
- snowflake/ml/modeling/ensemble/bagging_regressor.py +79 -43
- snowflake/ml/modeling/ensemble/extra_trees_classifier.py +79 -43
- snowflake/ml/modeling/ensemble/extra_trees_regressor.py +79 -43
- snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +79 -43
- snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +79 -43
- snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +79 -43
- snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +79 -43
- snowflake/ml/modeling/ensemble/isolation_forest.py +79 -43
- snowflake/ml/modeling/ensemble/random_forest_classifier.py +79 -43
- snowflake/ml/modeling/ensemble/random_forest_regressor.py +79 -43
- snowflake/ml/modeling/ensemble/stacking_regressor.py +79 -43
- snowflake/ml/modeling/ensemble/voting_classifier.py +79 -43
- snowflake/ml/modeling/ensemble/voting_regressor.py +79 -43
- snowflake/ml/modeling/feature_selection/generic_univariate_select.py +79 -43
- snowflake/ml/modeling/feature_selection/select_fdr.py +79 -43
- snowflake/ml/modeling/feature_selection/select_fpr.py +79 -43
- snowflake/ml/modeling/feature_selection/select_fwe.py +79 -43
- snowflake/ml/modeling/feature_selection/select_k_best.py +79 -43
- snowflake/ml/modeling/feature_selection/select_percentile.py +79 -43
- snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +79 -43
- snowflake/ml/modeling/feature_selection/variance_threshold.py +79 -43
- snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +79 -43
- snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +79 -43
- snowflake/ml/modeling/impute/iterative_imputer.py +79 -43
- snowflake/ml/modeling/impute/knn_imputer.py +79 -43
- snowflake/ml/modeling/impute/missing_indicator.py +79 -43
- snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +79 -43
- snowflake/ml/modeling/kernel_approximation/nystroem.py +79 -43
- snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +79 -43
- snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +79 -43
- snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +79 -43
- snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +79 -43
- snowflake/ml/modeling/lightgbm/lgbm_classifier.py +79 -43
- snowflake/ml/modeling/lightgbm/lgbm_regressor.py +79 -43
- snowflake/ml/modeling/linear_model/ard_regression.py +79 -43
- snowflake/ml/modeling/linear_model/bayesian_ridge.py +79 -43
- snowflake/ml/modeling/linear_model/elastic_net.py +79 -43
- snowflake/ml/modeling/linear_model/elastic_net_cv.py +79 -43
- snowflake/ml/modeling/linear_model/gamma_regressor.py +79 -43
- snowflake/ml/modeling/linear_model/huber_regressor.py +79 -43
- snowflake/ml/modeling/linear_model/lars.py +79 -43
- snowflake/ml/modeling/linear_model/lars_cv.py +79 -43
- snowflake/ml/modeling/linear_model/lasso.py +79 -43
- snowflake/ml/modeling/linear_model/lasso_cv.py +79 -43
- snowflake/ml/modeling/linear_model/lasso_lars.py +79 -43
- snowflake/ml/modeling/linear_model/lasso_lars_cv.py +79 -43
- snowflake/ml/modeling/linear_model/lasso_lars_ic.py +79 -43
- snowflake/ml/modeling/linear_model/linear_regression.py +79 -43
- snowflake/ml/modeling/linear_model/logistic_regression.py +79 -43
- snowflake/ml/modeling/linear_model/logistic_regression_cv.py +79 -43
- snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +79 -43
- snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +79 -43
- snowflake/ml/modeling/linear_model/multi_task_lasso.py +79 -43
- snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +79 -43
- snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +79 -43
- snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +79 -43
- snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +79 -43
- snowflake/ml/modeling/linear_model/perceptron.py +79 -43
- snowflake/ml/modeling/linear_model/poisson_regressor.py +79 -43
- snowflake/ml/modeling/linear_model/ransac_regressor.py +79 -43
- snowflake/ml/modeling/linear_model/ridge.py +79 -43
- snowflake/ml/modeling/linear_model/ridge_classifier.py +79 -43
- snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +79 -43
- snowflake/ml/modeling/linear_model/ridge_cv.py +79 -43
- snowflake/ml/modeling/linear_model/sgd_classifier.py +79 -43
- snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +79 -43
- snowflake/ml/modeling/linear_model/sgd_regressor.py +79 -43
- snowflake/ml/modeling/linear_model/theil_sen_regressor.py +79 -43
- snowflake/ml/modeling/linear_model/tweedie_regressor.py +79 -43
- snowflake/ml/modeling/manifold/isomap.py +79 -43
- snowflake/ml/modeling/manifold/mds.py +79 -43
- snowflake/ml/modeling/manifold/spectral_embedding.py +79 -43
- snowflake/ml/modeling/manifold/tsne.py +79 -43
- snowflake/ml/modeling/metrics/classification.py +6 -1
- snowflake/ml/modeling/metrics/regression.py +517 -9
- snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +79 -43
- snowflake/ml/modeling/mixture/gaussian_mixture.py +79 -43
- snowflake/ml/modeling/model_selection/grid_search_cv.py +79 -43
- snowflake/ml/modeling/model_selection/randomized_search_cv.py +79 -43
- snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +79 -43
- snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +79 -43
- snowflake/ml/modeling/multiclass/output_code_classifier.py +79 -43
- snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +79 -43
- snowflake/ml/modeling/naive_bayes/categorical_nb.py +79 -43
- snowflake/ml/modeling/naive_bayes/complement_nb.py +79 -43
- snowflake/ml/modeling/naive_bayes/gaussian_nb.py +79 -43
- snowflake/ml/modeling/naive_bayes/multinomial_nb.py +79 -43
- snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +79 -43
- snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +79 -43
- snowflake/ml/modeling/neighbors/kernel_density.py +79 -43
- snowflake/ml/modeling/neighbors/local_outlier_factor.py +79 -43
- snowflake/ml/modeling/neighbors/nearest_centroid.py +79 -43
- snowflake/ml/modeling/neighbors/nearest_neighbors.py +79 -43
- snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +79 -43
- snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +79 -43
- snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +79 -43
- snowflake/ml/modeling/neural_network/bernoulli_rbm.py +79 -43
- snowflake/ml/modeling/neural_network/mlp_classifier.py +79 -43
- snowflake/ml/modeling/neural_network/mlp_regressor.py +79 -43
- snowflake/ml/modeling/pipeline/pipeline.py +24 -0
- snowflake/ml/modeling/preprocessing/one_hot_encoder.py +18 -19
- snowflake/ml/modeling/preprocessing/ordinal_encoder.py +2 -0
- snowflake/ml/modeling/preprocessing/polynomial_features.py +79 -43
- snowflake/ml/modeling/semi_supervised/label_propagation.py +79 -43
- snowflake/ml/modeling/semi_supervised/label_spreading.py +79 -43
- snowflake/ml/modeling/svm/linear_svc.py +79 -43
- snowflake/ml/modeling/svm/linear_svr.py +79 -43
- snowflake/ml/modeling/svm/nu_svc.py +79 -43
- snowflake/ml/modeling/svm/nu_svr.py +79 -43
- snowflake/ml/modeling/svm/svc.py +79 -43
- snowflake/ml/modeling/svm/svr.py +79 -43
- snowflake/ml/modeling/tree/decision_tree_classifier.py +79 -43
- snowflake/ml/modeling/tree/decision_tree_regressor.py +79 -43
- snowflake/ml/modeling/tree/extra_tree_classifier.py +79 -43
- snowflake/ml/modeling/tree/extra_tree_regressor.py +79 -43
- snowflake/ml/modeling/xgboost/xgb_classifier.py +79 -43
- snowflake/ml/modeling/xgboost/xgb_regressor.py +79 -43
- snowflake/ml/modeling/xgboost/xgbrf_classifier.py +79 -43
- snowflake/ml/modeling/xgboost/xgbrf_regressor.py +79 -43
- snowflake/ml/registry/model_registry.py +123 -121
- snowflake/ml/version.py +1 -1
- {snowflake_ml_python-1.0.1.dist-info → snowflake_ml_python-1.0.3.dist-info}/METADATA +50 -8
- snowflake_ml_python-1.0.3.dist-info/RECORD +259 -0
- snowflake_ml_python-1.0.1.dist-info/RECORD +0 -246
- {snowflake_ml_python-1.0.1.dist-info → snowflake_ml_python-1.0.3.dist-info}/WHEEL +0 -0
@@ -7,6 +7,7 @@
|
|
7
7
|
#
|
8
8
|
import inspect
|
9
9
|
import os
|
10
|
+
import posixpath
|
10
11
|
from typing import Iterable, Optional, Union, List, Any, Dict, Callable, Set
|
11
12
|
from uuid import uuid4
|
12
13
|
|
@@ -27,6 +28,7 @@ from snowflake.ml._internal.utils.temp_file_utils import cleanup_temp_files, get
|
|
27
28
|
from snowflake.snowpark import DataFrame, Session
|
28
29
|
from snowflake.snowpark.functions import pandas_udf, sproc
|
29
30
|
from snowflake.snowpark.types import PandasSeries
|
31
|
+
from snowflake.snowpark._internal.type_utils import convert_sp_to_sf_type
|
30
32
|
|
31
33
|
from snowflake.ml.model.model_signature import (
|
32
34
|
DataType,
|
@@ -224,7 +226,6 @@ class MultiTaskLasso(BaseTransformer):
|
|
224
226
|
sample_weight_col: Optional[str] = None,
|
225
227
|
) -> None:
|
226
228
|
super().__init__()
|
227
|
-
self.id = str(uuid4()).replace("-", "_").upper()
|
228
229
|
deps: Set[str] = set([f'numpy=={np.__version__}', f'scikit-learn=={sklearn.__version__}', f'cloudpickle=={cp.__version__}'])
|
229
230
|
|
230
231
|
self._deps = list(deps)
|
@@ -251,6 +252,15 @@ class MultiTaskLasso(BaseTransformer):
|
|
251
252
|
self.set_drop_input_cols(drop_input_cols)
|
252
253
|
self.set_sample_weight_col(sample_weight_col)
|
253
254
|
|
255
|
+
def _get_rand_id(self) -> str:
|
256
|
+
"""
|
257
|
+
Generate random id to be used in sproc and stage names.
|
258
|
+
|
259
|
+
Returns:
|
260
|
+
Random id string usable in sproc, table, and stage names.
|
261
|
+
"""
|
262
|
+
return str(uuid4()).replace("-", "_").upper()
|
263
|
+
|
254
264
|
def _infer_input_output_cols(self, dataset: Union[DataFrame, pd.DataFrame]) -> None:
|
255
265
|
"""
|
256
266
|
Infer `self.input_cols` and `self.output_cols` if they are not explicitly set.
|
@@ -329,7 +339,7 @@ class MultiTaskLasso(BaseTransformer):
|
|
329
339
|
cp.dump(self._sklearn_object, local_transform_file)
|
330
340
|
|
331
341
|
# Create temp stage to run fit.
|
332
|
-
transform_stage_name = "SNOWML_TRANSFORM_{safe_id}".format(safe_id=self.
|
342
|
+
transform_stage_name = "SNOWML_TRANSFORM_{safe_id}".format(safe_id=self._get_rand_id())
|
333
343
|
stage_creation_query = f"CREATE OR REPLACE TEMPORARY STAGE {transform_stage_name};"
|
334
344
|
SqlResultValidator(
|
335
345
|
session=session,
|
@@ -342,11 +352,12 @@ class MultiTaskLasso(BaseTransformer):
|
|
342
352
|
expected_value=f"Stage area {transform_stage_name} successfully created."
|
343
353
|
).validate()
|
344
354
|
|
345
|
-
|
355
|
+
# Use posixpath to construct stage paths
|
356
|
+
stage_transform_file_name = posixpath.join(transform_stage_name, os.path.basename(local_transform_file_name))
|
357
|
+
stage_result_file_name = posixpath.join(transform_stage_name, os.path.basename(local_transform_file_name))
|
346
358
|
local_result_file_name = get_temp_file_path()
|
347
|
-
stage_result_file_name = os.path.join(transform_stage_name, os.path.basename(local_transform_file_name))
|
348
359
|
|
349
|
-
fit_sproc_name = "SNOWML_FIT_{safe_id}".format(safe_id=self.
|
360
|
+
fit_sproc_name = "SNOWML_FIT_{safe_id}".format(safe_id=self._get_rand_id())
|
350
361
|
statement_params = telemetry.get_function_usage_statement_params(
|
351
362
|
project=_PROJECT,
|
352
363
|
subproject=_SUBPROJECT,
|
@@ -372,6 +383,7 @@ class MultiTaskLasso(BaseTransformer):
|
|
372
383
|
replace=True,
|
373
384
|
session=session,
|
374
385
|
statement_params=statement_params,
|
386
|
+
anonymous=True
|
375
387
|
)
|
376
388
|
def fit_wrapper_sproc(
|
377
389
|
session: Session,
|
@@ -380,7 +392,8 @@ class MultiTaskLasso(BaseTransformer):
|
|
380
392
|
stage_result_file_name: str,
|
381
393
|
input_cols: List[str],
|
382
394
|
label_cols: List[str],
|
383
|
-
sample_weight_col: Optional[str]
|
395
|
+
sample_weight_col: Optional[str],
|
396
|
+
statement_params: Dict[str, str]
|
384
397
|
) -> str:
|
385
398
|
import cloudpickle as cp
|
386
399
|
import numpy as np
|
@@ -447,15 +460,15 @@ class MultiTaskLasso(BaseTransformer):
|
|
447
460
|
api_calls=[Session.call],
|
448
461
|
custom_tags=dict([("autogen", True)]),
|
449
462
|
)
|
450
|
-
sproc_export_file_name =
|
451
|
-
|
463
|
+
sproc_export_file_name = fit_wrapper_sproc(
|
464
|
+
session,
|
452
465
|
query,
|
453
466
|
stage_transform_file_name,
|
454
467
|
stage_result_file_name,
|
455
468
|
identifier.get_unescaped_names(self.input_cols),
|
456
469
|
identifier.get_unescaped_names(self.label_cols),
|
457
470
|
identifier.get_unescaped_names(self.sample_weight_col),
|
458
|
-
statement_params
|
471
|
+
statement_params,
|
459
472
|
)
|
460
473
|
|
461
474
|
if "|" in sproc_export_file_name:
|
@@ -465,7 +478,7 @@ class MultiTaskLasso(BaseTransformer):
|
|
465
478
|
print("\n".join(fields[1:]))
|
466
479
|
|
467
480
|
session.file.get(
|
468
|
-
|
481
|
+
posixpath.join(stage_result_file_name, sproc_export_file_name),
|
469
482
|
local_result_file_name,
|
470
483
|
statement_params=statement_params
|
471
484
|
)
|
@@ -511,7 +524,7 @@ class MultiTaskLasso(BaseTransformer):
|
|
511
524
|
|
512
525
|
# Register vectorized UDF for batch inference
|
513
526
|
batch_inference_udf_name = "SNOWML_BATCH_INFERENCE_{safe_id}_{method}".format(
|
514
|
-
safe_id=self.
|
527
|
+
safe_id=self._get_rand_id(), method=inference_method)
|
515
528
|
|
516
529
|
# Need to do this since if we use self._sklearn_object directly in the UDF, Snowpark
|
517
530
|
# will try to pickle all of self which fails.
|
@@ -603,7 +616,7 @@ class MultiTaskLasso(BaseTransformer):
|
|
603
616
|
return transformed_pandas_df.to_dict("records")
|
604
617
|
|
605
618
|
batch_inference_table_name = "SNOWML_BATCH_INFERENCE_INPUT_TABLE_{safe_id}".format(
|
606
|
-
safe_id=self.
|
619
|
+
safe_id=self._get_rand_id()
|
607
620
|
)
|
608
621
|
|
609
622
|
pass_through_columns = self._get_pass_through_columns(dataset)
|
@@ -659,26 +672,37 @@ class MultiTaskLasso(BaseTransformer):
|
|
659
672
|
# input cols need to match unquoted / quoted
|
660
673
|
input_cols = self.input_cols
|
661
674
|
unquoted_input_cols = identifier.get_unescaped_names(self.input_cols)
|
675
|
+
quoted_input_cols = identifier.get_escaped_names(unquoted_input_cols)
|
662
676
|
|
663
677
|
estimator = self._sklearn_object
|
664
678
|
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
679
|
+
features_required_by_estimator = getattr(estimator, "feature_names_in_") if hasattr(estimator, "feature_names_in_") else unquoted_input_cols
|
680
|
+
missing_features = []
|
681
|
+
features_in_dataset = set(dataset.columns)
|
682
|
+
columns_to_select = []
|
683
|
+
for i, f in enumerate(features_required_by_estimator):
|
684
|
+
if (
|
685
|
+
i >= len(input_cols)
|
686
|
+
or (input_cols[i] != f and unquoted_input_cols[i] != f and quoted_input_cols[i] != f)
|
687
|
+
or (input_cols[i] not in features_in_dataset and unquoted_input_cols[i] not in features_in_dataset
|
688
|
+
and quoted_input_cols[i] not in features_in_dataset)
|
689
|
+
):
|
690
|
+
missing_features.append(f)
|
691
|
+
elif input_cols[i] in features_in_dataset:
|
692
|
+
columns_to_select.append(input_cols[i])
|
693
|
+
elif unquoted_input_cols[i] in features_in_dataset:
|
694
|
+
columns_to_select.append(unquoted_input_cols[i])
|
695
|
+
else:
|
696
|
+
columns_to_select.append(quoted_input_cols[i])
|
697
|
+
|
698
|
+
if len(missing_features) > 0:
|
699
|
+
raise ValueError(
|
700
|
+
"The feature names should match with those that were passed during fit.\n"
|
701
|
+
f"Features seen during fit call but not present in the input: {missing_features}\n"
|
702
|
+
f"Features in the input dataframe : {input_cols}\n"
|
703
|
+
)
|
704
|
+
input_df = dataset[columns_to_select]
|
705
|
+
input_df.columns = features_required_by_estimator
|
682
706
|
|
683
707
|
transformed_numpy_array = getattr(estimator, inference_method)(
|
684
708
|
input_df
|
@@ -759,11 +783,18 @@ class MultiTaskLasso(BaseTransformer):
|
|
759
783
|
Transformed dataset.
|
760
784
|
"""
|
761
785
|
if isinstance(dataset, DataFrame):
|
786
|
+
expected_type_inferred = "float"
|
787
|
+
# when it is classifier, infer the datatype from label columns
|
788
|
+
if expected_type_inferred == "" and 'predict' in self.model_signatures:
|
789
|
+
expected_type_inferred = convert_sp_to_sf_type(
|
790
|
+
self.model_signatures['predict'].outputs[0].as_snowpark_type()
|
791
|
+
)
|
792
|
+
|
762
793
|
output_df = self._batch_inference(
|
763
794
|
dataset=dataset,
|
764
795
|
inference_method="predict",
|
765
796
|
expected_output_cols_list=self.output_cols,
|
766
|
-
expected_output_cols_type=
|
797
|
+
expected_output_cols_type=expected_type_inferred,
|
767
798
|
)
|
768
799
|
elif isinstance(dataset, pd.DataFrame):
|
769
800
|
output_df = self._sklearn_inference(
|
@@ -834,10 +865,10 @@ class MultiTaskLasso(BaseTransformer):
|
|
834
865
|
|
835
866
|
def _get_output_column_names(self, output_cols_prefix: str) -> List[str]:
|
836
867
|
""" Returns the list of output columns for predict_proba(), decision_function(), etc.. functions.
|
837
|
-
Returns
|
868
|
+
Returns a list with output_cols_prefix as the only element if the estimator is not a classifier.
|
838
869
|
"""
|
839
870
|
if getattr(self._sklearn_object, "classes_", None) is None:
|
840
|
-
return []
|
871
|
+
return [output_cols_prefix]
|
841
872
|
|
842
873
|
classes = self._sklearn_object.classes_
|
843
874
|
if isinstance(classes, numpy.ndarray):
|
@@ -1062,7 +1093,7 @@ class MultiTaskLasso(BaseTransformer):
|
|
1062
1093
|
cp.dump(self._sklearn_object, local_score_file)
|
1063
1094
|
|
1064
1095
|
# Create temp stage to run score.
|
1065
|
-
score_stage_name = "SNOWML_SCORE_{safe_id}".format(safe_id=self.
|
1096
|
+
score_stage_name = "SNOWML_SCORE_{safe_id}".format(safe_id=self._get_rand_id())
|
1066
1097
|
session = dataset._session
|
1067
1098
|
stage_creation_query = f"CREATE OR REPLACE TEMPORARY STAGE {score_stage_name};"
|
1068
1099
|
SqlResultValidator(
|
@@ -1076,8 +1107,9 @@ class MultiTaskLasso(BaseTransformer):
|
|
1076
1107
|
expected_value=f"Stage area {score_stage_name} successfully created."
|
1077
1108
|
).validate()
|
1078
1109
|
|
1079
|
-
|
1080
|
-
|
1110
|
+
# Use posixpath to construct stage paths
|
1111
|
+
stage_score_file_name = posixpath.join(score_stage_name, os.path.basename(local_score_file_name))
|
1112
|
+
score_sproc_name = "SNOWML_SCORE_{safe_id}".format(safe_id=self._get_rand_id())
|
1081
1113
|
statement_params = telemetry.get_function_usage_statement_params(
|
1082
1114
|
project=_PROJECT,
|
1083
1115
|
subproject=_SUBPROJECT,
|
@@ -1103,6 +1135,7 @@ class MultiTaskLasso(BaseTransformer):
|
|
1103
1135
|
replace=True,
|
1104
1136
|
session=session,
|
1105
1137
|
statement_params=statement_params,
|
1138
|
+
anonymous=True
|
1106
1139
|
)
|
1107
1140
|
def score_wrapper_sproc(
|
1108
1141
|
session: Session,
|
@@ -1110,7 +1143,8 @@ class MultiTaskLasso(BaseTransformer):
|
|
1110
1143
|
stage_score_file_name: str,
|
1111
1144
|
input_cols: List[str],
|
1112
1145
|
label_cols: List[str],
|
1113
|
-
sample_weight_col: Optional[str]
|
1146
|
+
sample_weight_col: Optional[str],
|
1147
|
+
statement_params: Dict[str, str]
|
1114
1148
|
) -> float:
|
1115
1149
|
import cloudpickle as cp
|
1116
1150
|
import numpy as np
|
@@ -1160,14 +1194,14 @@ class MultiTaskLasso(BaseTransformer):
|
|
1160
1194
|
api_calls=[Session.call],
|
1161
1195
|
custom_tags=dict([("autogen", True)]),
|
1162
1196
|
)
|
1163
|
-
score =
|
1164
|
-
|
1197
|
+
score = score_wrapper_sproc(
|
1198
|
+
session,
|
1165
1199
|
query,
|
1166
1200
|
stage_score_file_name,
|
1167
1201
|
identifier.get_unescaped_names(self.input_cols),
|
1168
1202
|
identifier.get_unescaped_names(self.label_cols),
|
1169
1203
|
identifier.get_unescaped_names(self.sample_weight_col),
|
1170
|
-
statement_params
|
1204
|
+
statement_params,
|
1171
1205
|
)
|
1172
1206
|
|
1173
1207
|
cleanup_temp_files([local_score_file_name])
|
@@ -1185,18 +1219,20 @@ class MultiTaskLasso(BaseTransformer):
|
|
1185
1219
|
if self._sklearn_object._estimator_type == 'classifier':
|
1186
1220
|
outputs = _infer_signature(dataset[self.label_cols], "output") # label columns is the desired type for output
|
1187
1221
|
outputs = _rename_features(outputs, self.output_cols) # rename the output columns
|
1188
|
-
self._model_signature_dict["predict"] = ModelSignature(inputs,
|
1222
|
+
self._model_signature_dict["predict"] = ModelSignature(inputs,
|
1223
|
+
([] if self._drop_input_cols else inputs) + outputs)
|
1189
1224
|
# For regressor, the type of predict is float64
|
1190
1225
|
elif self._sklearn_object._estimator_type == 'regressor':
|
1191
1226
|
outputs = [FeatureSpec(dtype=DataType.DOUBLE, name=c) for c in self.output_cols]
|
1192
|
-
self._model_signature_dict["predict"] = ModelSignature(inputs,
|
1193
|
-
|
1227
|
+
self._model_signature_dict["predict"] = ModelSignature(inputs,
|
1228
|
+
([] if self._drop_input_cols else inputs) + outputs)
|
1194
1229
|
for prob_func in PROB_FUNCTIONS:
|
1195
1230
|
if hasattr(self, prob_func):
|
1196
1231
|
output_cols_prefix: str = f"{prob_func}_"
|
1197
1232
|
output_column_names = self._get_output_column_names(output_cols_prefix)
|
1198
1233
|
outputs = [FeatureSpec(dtype=DataType.DOUBLE, name=c) for c in output_column_names]
|
1199
|
-
self._model_signature_dict[prob_func] = ModelSignature(inputs,
|
1234
|
+
self._model_signature_dict[prob_func] = ModelSignature(inputs,
|
1235
|
+
([] if self._drop_input_cols else inputs) + outputs)
|
1200
1236
|
|
1201
1237
|
@property
|
1202
1238
|
def model_signatures(self) -> Dict[str, ModelSignature]:
|
@@ -7,6 +7,7 @@
|
|
7
7
|
#
|
8
8
|
import inspect
|
9
9
|
import os
|
10
|
+
import posixpath
|
10
11
|
from typing import Iterable, Optional, Union, List, Any, Dict, Callable, Set
|
11
12
|
from uuid import uuid4
|
12
13
|
|
@@ -27,6 +28,7 @@ from snowflake.ml._internal.utils.temp_file_utils import cleanup_temp_files, get
|
|
27
28
|
from snowflake.snowpark import DataFrame, Session
|
28
29
|
from snowflake.snowpark.functions import pandas_udf, sproc
|
29
30
|
from snowflake.snowpark.types import PandasSeries
|
31
|
+
from snowflake.snowpark._internal.type_utils import convert_sp_to_sf_type
|
30
32
|
|
31
33
|
from snowflake.ml.model.model_signature import (
|
32
34
|
DataType,
|
@@ -255,7 +257,6 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
255
257
|
sample_weight_col: Optional[str] = None,
|
256
258
|
) -> None:
|
257
259
|
super().__init__()
|
258
|
-
self.id = str(uuid4()).replace("-", "_").upper()
|
259
260
|
deps: Set[str] = set([f'numpy=={np.__version__}', f'scikit-learn=={sklearn.__version__}', f'cloudpickle=={cp.__version__}'])
|
260
261
|
|
261
262
|
self._deps = list(deps)
|
@@ -286,6 +287,15 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
286
287
|
self.set_drop_input_cols(drop_input_cols)
|
287
288
|
self.set_sample_weight_col(sample_weight_col)
|
288
289
|
|
290
|
+
def _get_rand_id(self) -> str:
|
291
|
+
"""
|
292
|
+
Generate random id to be used in sproc and stage names.
|
293
|
+
|
294
|
+
Returns:
|
295
|
+
Random id string usable in sproc, table, and stage names.
|
296
|
+
"""
|
297
|
+
return str(uuid4()).replace("-", "_").upper()
|
298
|
+
|
289
299
|
def _infer_input_output_cols(self, dataset: Union[DataFrame, pd.DataFrame]) -> None:
|
290
300
|
"""
|
291
301
|
Infer `self.input_cols` and `self.output_cols` if they are not explicitly set.
|
@@ -364,7 +374,7 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
364
374
|
cp.dump(self._sklearn_object, local_transform_file)
|
365
375
|
|
366
376
|
# Create temp stage to run fit.
|
367
|
-
transform_stage_name = "SNOWML_TRANSFORM_{safe_id}".format(safe_id=self.
|
377
|
+
transform_stage_name = "SNOWML_TRANSFORM_{safe_id}".format(safe_id=self._get_rand_id())
|
368
378
|
stage_creation_query = f"CREATE OR REPLACE TEMPORARY STAGE {transform_stage_name};"
|
369
379
|
SqlResultValidator(
|
370
380
|
session=session,
|
@@ -377,11 +387,12 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
377
387
|
expected_value=f"Stage area {transform_stage_name} successfully created."
|
378
388
|
).validate()
|
379
389
|
|
380
|
-
|
390
|
+
# Use posixpath to construct stage paths
|
391
|
+
stage_transform_file_name = posixpath.join(transform_stage_name, os.path.basename(local_transform_file_name))
|
392
|
+
stage_result_file_name = posixpath.join(transform_stage_name, os.path.basename(local_transform_file_name))
|
381
393
|
local_result_file_name = get_temp_file_path()
|
382
|
-
stage_result_file_name = os.path.join(transform_stage_name, os.path.basename(local_transform_file_name))
|
383
394
|
|
384
|
-
fit_sproc_name = "SNOWML_FIT_{safe_id}".format(safe_id=self.
|
395
|
+
fit_sproc_name = "SNOWML_FIT_{safe_id}".format(safe_id=self._get_rand_id())
|
385
396
|
statement_params = telemetry.get_function_usage_statement_params(
|
386
397
|
project=_PROJECT,
|
387
398
|
subproject=_SUBPROJECT,
|
@@ -407,6 +418,7 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
407
418
|
replace=True,
|
408
419
|
session=session,
|
409
420
|
statement_params=statement_params,
|
421
|
+
anonymous=True
|
410
422
|
)
|
411
423
|
def fit_wrapper_sproc(
|
412
424
|
session: Session,
|
@@ -415,7 +427,8 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
415
427
|
stage_result_file_name: str,
|
416
428
|
input_cols: List[str],
|
417
429
|
label_cols: List[str],
|
418
|
-
sample_weight_col: Optional[str]
|
430
|
+
sample_weight_col: Optional[str],
|
431
|
+
statement_params: Dict[str, str]
|
419
432
|
) -> str:
|
420
433
|
import cloudpickle as cp
|
421
434
|
import numpy as np
|
@@ -482,15 +495,15 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
482
495
|
api_calls=[Session.call],
|
483
496
|
custom_tags=dict([("autogen", True)]),
|
484
497
|
)
|
485
|
-
sproc_export_file_name =
|
486
|
-
|
498
|
+
sproc_export_file_name = fit_wrapper_sproc(
|
499
|
+
session,
|
487
500
|
query,
|
488
501
|
stage_transform_file_name,
|
489
502
|
stage_result_file_name,
|
490
503
|
identifier.get_unescaped_names(self.input_cols),
|
491
504
|
identifier.get_unescaped_names(self.label_cols),
|
492
505
|
identifier.get_unescaped_names(self.sample_weight_col),
|
493
|
-
statement_params
|
506
|
+
statement_params,
|
494
507
|
)
|
495
508
|
|
496
509
|
if "|" in sproc_export_file_name:
|
@@ -500,7 +513,7 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
500
513
|
print("\n".join(fields[1:]))
|
501
514
|
|
502
515
|
session.file.get(
|
503
|
-
|
516
|
+
posixpath.join(stage_result_file_name, sproc_export_file_name),
|
504
517
|
local_result_file_name,
|
505
518
|
statement_params=statement_params
|
506
519
|
)
|
@@ -546,7 +559,7 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
546
559
|
|
547
560
|
# Register vectorized UDF for batch inference
|
548
561
|
batch_inference_udf_name = "SNOWML_BATCH_INFERENCE_{safe_id}_{method}".format(
|
549
|
-
safe_id=self.
|
562
|
+
safe_id=self._get_rand_id(), method=inference_method)
|
550
563
|
|
551
564
|
# Need to do this since if we use self._sklearn_object directly in the UDF, Snowpark
|
552
565
|
# will try to pickle all of self which fails.
|
@@ -638,7 +651,7 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
638
651
|
return transformed_pandas_df.to_dict("records")
|
639
652
|
|
640
653
|
batch_inference_table_name = "SNOWML_BATCH_INFERENCE_INPUT_TABLE_{safe_id}".format(
|
641
|
-
safe_id=self.
|
654
|
+
safe_id=self._get_rand_id()
|
642
655
|
)
|
643
656
|
|
644
657
|
pass_through_columns = self._get_pass_through_columns(dataset)
|
@@ -694,26 +707,37 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
694
707
|
# input cols need to match unquoted / quoted
|
695
708
|
input_cols = self.input_cols
|
696
709
|
unquoted_input_cols = identifier.get_unescaped_names(self.input_cols)
|
710
|
+
quoted_input_cols = identifier.get_escaped_names(unquoted_input_cols)
|
697
711
|
|
698
712
|
estimator = self._sklearn_object
|
699
713
|
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
714
|
+
features_required_by_estimator = getattr(estimator, "feature_names_in_") if hasattr(estimator, "feature_names_in_") else unquoted_input_cols
|
715
|
+
missing_features = []
|
716
|
+
features_in_dataset = set(dataset.columns)
|
717
|
+
columns_to_select = []
|
718
|
+
for i, f in enumerate(features_required_by_estimator):
|
719
|
+
if (
|
720
|
+
i >= len(input_cols)
|
721
|
+
or (input_cols[i] != f and unquoted_input_cols[i] != f and quoted_input_cols[i] != f)
|
722
|
+
or (input_cols[i] not in features_in_dataset and unquoted_input_cols[i] not in features_in_dataset
|
723
|
+
and quoted_input_cols[i] not in features_in_dataset)
|
724
|
+
):
|
725
|
+
missing_features.append(f)
|
726
|
+
elif input_cols[i] in features_in_dataset:
|
727
|
+
columns_to_select.append(input_cols[i])
|
728
|
+
elif unquoted_input_cols[i] in features_in_dataset:
|
729
|
+
columns_to_select.append(unquoted_input_cols[i])
|
730
|
+
else:
|
731
|
+
columns_to_select.append(quoted_input_cols[i])
|
732
|
+
|
733
|
+
if len(missing_features) > 0:
|
734
|
+
raise ValueError(
|
735
|
+
"The feature names should match with those that were passed during fit.\n"
|
736
|
+
f"Features seen during fit call but not present in the input: {missing_features}\n"
|
737
|
+
f"Features in the input dataframe : {input_cols}\n"
|
738
|
+
)
|
739
|
+
input_df = dataset[columns_to_select]
|
740
|
+
input_df.columns = features_required_by_estimator
|
717
741
|
|
718
742
|
transformed_numpy_array = getattr(estimator, inference_method)(
|
719
743
|
input_df
|
@@ -794,11 +818,18 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
794
818
|
Transformed dataset.
|
795
819
|
"""
|
796
820
|
if isinstance(dataset, DataFrame):
|
821
|
+
expected_type_inferred = "float"
|
822
|
+
# when it is classifier, infer the datatype from label columns
|
823
|
+
if expected_type_inferred == "" and 'predict' in self.model_signatures:
|
824
|
+
expected_type_inferred = convert_sp_to_sf_type(
|
825
|
+
self.model_signatures['predict'].outputs[0].as_snowpark_type()
|
826
|
+
)
|
827
|
+
|
797
828
|
output_df = self._batch_inference(
|
798
829
|
dataset=dataset,
|
799
830
|
inference_method="predict",
|
800
831
|
expected_output_cols_list=self.output_cols,
|
801
|
-
expected_output_cols_type=
|
832
|
+
expected_output_cols_type=expected_type_inferred,
|
802
833
|
)
|
803
834
|
elif isinstance(dataset, pd.DataFrame):
|
804
835
|
output_df = self._sklearn_inference(
|
@@ -869,10 +900,10 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
869
900
|
|
870
901
|
def _get_output_column_names(self, output_cols_prefix: str) -> List[str]:
|
871
902
|
""" Returns the list of output columns for predict_proba(), decision_function(), etc.. functions.
|
872
|
-
Returns
|
903
|
+
Returns a list with output_cols_prefix as the only element if the estimator is not a classifier.
|
873
904
|
"""
|
874
905
|
if getattr(self._sklearn_object, "classes_", None) is None:
|
875
|
-
return []
|
906
|
+
return [output_cols_prefix]
|
876
907
|
|
877
908
|
classes = self._sklearn_object.classes_
|
878
909
|
if isinstance(classes, numpy.ndarray):
|
@@ -1097,7 +1128,7 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
1097
1128
|
cp.dump(self._sklearn_object, local_score_file)
|
1098
1129
|
|
1099
1130
|
# Create temp stage to run score.
|
1100
|
-
score_stage_name = "SNOWML_SCORE_{safe_id}".format(safe_id=self.
|
1131
|
+
score_stage_name = "SNOWML_SCORE_{safe_id}".format(safe_id=self._get_rand_id())
|
1101
1132
|
session = dataset._session
|
1102
1133
|
stage_creation_query = f"CREATE OR REPLACE TEMPORARY STAGE {score_stage_name};"
|
1103
1134
|
SqlResultValidator(
|
@@ -1111,8 +1142,9 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
1111
1142
|
expected_value=f"Stage area {score_stage_name} successfully created."
|
1112
1143
|
).validate()
|
1113
1144
|
|
1114
|
-
|
1115
|
-
|
1145
|
+
# Use posixpath to construct stage paths
|
1146
|
+
stage_score_file_name = posixpath.join(score_stage_name, os.path.basename(local_score_file_name))
|
1147
|
+
score_sproc_name = "SNOWML_SCORE_{safe_id}".format(safe_id=self._get_rand_id())
|
1116
1148
|
statement_params = telemetry.get_function_usage_statement_params(
|
1117
1149
|
project=_PROJECT,
|
1118
1150
|
subproject=_SUBPROJECT,
|
@@ -1138,6 +1170,7 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
1138
1170
|
replace=True,
|
1139
1171
|
session=session,
|
1140
1172
|
statement_params=statement_params,
|
1173
|
+
anonymous=True
|
1141
1174
|
)
|
1142
1175
|
def score_wrapper_sproc(
|
1143
1176
|
session: Session,
|
@@ -1145,7 +1178,8 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
1145
1178
|
stage_score_file_name: str,
|
1146
1179
|
input_cols: List[str],
|
1147
1180
|
label_cols: List[str],
|
1148
|
-
sample_weight_col: Optional[str]
|
1181
|
+
sample_weight_col: Optional[str],
|
1182
|
+
statement_params: Dict[str, str]
|
1149
1183
|
) -> float:
|
1150
1184
|
import cloudpickle as cp
|
1151
1185
|
import numpy as np
|
@@ -1195,14 +1229,14 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
1195
1229
|
api_calls=[Session.call],
|
1196
1230
|
custom_tags=dict([("autogen", True)]),
|
1197
1231
|
)
|
1198
|
-
score =
|
1199
|
-
|
1232
|
+
score = score_wrapper_sproc(
|
1233
|
+
session,
|
1200
1234
|
query,
|
1201
1235
|
stage_score_file_name,
|
1202
1236
|
identifier.get_unescaped_names(self.input_cols),
|
1203
1237
|
identifier.get_unescaped_names(self.label_cols),
|
1204
1238
|
identifier.get_unescaped_names(self.sample_weight_col),
|
1205
|
-
statement_params
|
1239
|
+
statement_params,
|
1206
1240
|
)
|
1207
1241
|
|
1208
1242
|
cleanup_temp_files([local_score_file_name])
|
@@ -1220,18 +1254,20 @@ class MultiTaskLassoCV(BaseTransformer):
|
|
1220
1254
|
if self._sklearn_object._estimator_type == 'classifier':
|
1221
1255
|
outputs = _infer_signature(dataset[self.label_cols], "output") # label columns is the desired type for output
|
1222
1256
|
outputs = _rename_features(outputs, self.output_cols) # rename the output columns
|
1223
|
-
self._model_signature_dict["predict"] = ModelSignature(inputs,
|
1257
|
+
self._model_signature_dict["predict"] = ModelSignature(inputs,
|
1258
|
+
([] if self._drop_input_cols else inputs) + outputs)
|
1224
1259
|
# For regressor, the type of predict is float64
|
1225
1260
|
elif self._sklearn_object._estimator_type == 'regressor':
|
1226
1261
|
outputs = [FeatureSpec(dtype=DataType.DOUBLE, name=c) for c in self.output_cols]
|
1227
|
-
self._model_signature_dict["predict"] = ModelSignature(inputs,
|
1228
|
-
|
1262
|
+
self._model_signature_dict["predict"] = ModelSignature(inputs,
|
1263
|
+
([] if self._drop_input_cols else inputs) + outputs)
|
1229
1264
|
for prob_func in PROB_FUNCTIONS:
|
1230
1265
|
if hasattr(self, prob_func):
|
1231
1266
|
output_cols_prefix: str = f"{prob_func}_"
|
1232
1267
|
output_column_names = self._get_output_column_names(output_cols_prefix)
|
1233
1268
|
outputs = [FeatureSpec(dtype=DataType.DOUBLE, name=c) for c in output_column_names]
|
1234
|
-
self._model_signature_dict[prob_func] = ModelSignature(inputs,
|
1269
|
+
self._model_signature_dict[prob_func] = ModelSignature(inputs,
|
1270
|
+
([] if self._drop_input_cols else inputs) + outputs)
|
1235
1271
|
|
1236
1272
|
@property
|
1237
1273
|
def model_signatures(self) -> Dict[str, ModelSignature]:
|