snowflake-ml-python 1.7.3__py3-none-any.whl → 1.7.5__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.
Files changed (208) hide show
  1. snowflake/cortex/_complete.py +19 -0
  2. snowflake/ml/_internal/env_utils.py +64 -21
  3. snowflake/ml/_internal/platform_capabilities.py +87 -0
  4. snowflake/ml/_internal/relax_version_strategy.py +16 -0
  5. snowflake/ml/_internal/telemetry.py +21 -0
  6. snowflake/ml/data/_internal/arrow_ingestor.py +1 -1
  7. snowflake/ml/dataset/dataset.py +0 -1
  8. snowflake/ml/feature_store/feature_store.py +18 -0
  9. snowflake/ml/feature_store/feature_view.py +46 -1
  10. snowflake/ml/fileset/fileset.py +6 -0
  11. snowflake/ml/jobs/__init__.py +21 -0
  12. snowflake/ml/jobs/_utils/constants.py +57 -0
  13. snowflake/ml/jobs/_utils/payload_utils.py +438 -0
  14. snowflake/ml/jobs/_utils/spec_utils.py +296 -0
  15. snowflake/ml/jobs/_utils/types.py +39 -0
  16. snowflake/ml/jobs/decorators.py +71 -0
  17. snowflake/ml/jobs/job.py +113 -0
  18. snowflake/ml/jobs/manager.py +298 -0
  19. snowflake/ml/model/_client/ops/model_ops.py +11 -2
  20. snowflake/ml/model/_client/ops/service_ops.py +1 -11
  21. snowflake/ml/model/_client/sql/service.py +13 -6
  22. snowflake/ml/model/_packager/model_env/model_env.py +45 -28
  23. snowflake/ml/model/_packager/model_handlers/_utils.py +19 -6
  24. snowflake/ml/model/_packager/model_handlers/custom.py +1 -2
  25. snowflake/ml/model/_packager/model_handlers/huggingface_pipeline.py +17 -0
  26. snowflake/ml/model/_packager/model_handlers/keras.py +230 -0
  27. snowflake/ml/model/_packager/model_handlers/pytorch.py +1 -0
  28. snowflake/ml/model/_packager/model_handlers/sklearn.py +28 -3
  29. snowflake/ml/model/_packager/model_handlers/snowmlmodel.py +74 -21
  30. snowflake/ml/model/_packager/model_handlers/tensorflow.py +27 -49
  31. snowflake/ml/model/_packager/model_handlers_migrator/tensorflow_migrator_2023_12_01.py +48 -0
  32. snowflake/ml/model/_packager/model_meta/model_meta.py +1 -1
  33. snowflake/ml/model/_packager/model_meta/model_meta_schema.py +3 -0
  34. snowflake/ml/model/_packager/model_runtime/_snowml_inference_alternative_requirements.py +2 -2
  35. snowflake/ml/model/_packager/model_runtime/model_runtime.py +4 -1
  36. snowflake/ml/model/_packager/model_task/model_task_utils.py +5 -1
  37. snowflake/ml/model/_signatures/base_handler.py +1 -2
  38. snowflake/ml/model/_signatures/builtins_handler.py +2 -2
  39. snowflake/ml/model/_signatures/core.py +2 -2
  40. snowflake/ml/model/_signatures/numpy_handler.py +11 -12
  41. snowflake/ml/model/_signatures/pandas_handler.py +11 -9
  42. snowflake/ml/model/_signatures/pytorch_handler.py +3 -6
  43. snowflake/ml/model/_signatures/snowpark_handler.py +3 -3
  44. snowflake/ml/model/_signatures/tensorflow_handler.py +2 -7
  45. snowflake/ml/model/model_signature.py +25 -4
  46. snowflake/ml/model/type_hints.py +15 -0
  47. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_handlers.py +14 -1
  48. snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +6 -3
  49. snowflake/ml/modeling/cluster/affinity_propagation.py +6 -3
  50. snowflake/ml/modeling/cluster/agglomerative_clustering.py +6 -3
  51. snowflake/ml/modeling/cluster/birch.py +6 -3
  52. snowflake/ml/modeling/cluster/bisecting_k_means.py +6 -3
  53. snowflake/ml/modeling/cluster/dbscan.py +6 -3
  54. snowflake/ml/modeling/cluster/feature_agglomeration.py +6 -3
  55. snowflake/ml/modeling/cluster/k_means.py +6 -3
  56. snowflake/ml/modeling/cluster/mean_shift.py +6 -3
  57. snowflake/ml/modeling/cluster/mini_batch_k_means.py +6 -3
  58. snowflake/ml/modeling/cluster/optics.py +6 -3
  59. snowflake/ml/modeling/cluster/spectral_biclustering.py +6 -3
  60. snowflake/ml/modeling/cluster/spectral_clustering.py +6 -3
  61. snowflake/ml/modeling/cluster/spectral_coclustering.py +6 -3
  62. snowflake/ml/modeling/compose/column_transformer.py +6 -3
  63. snowflake/ml/modeling/compose/transformed_target_regressor.py +6 -3
  64. snowflake/ml/modeling/covariance/elliptic_envelope.py +6 -3
  65. snowflake/ml/modeling/covariance/empirical_covariance.py +6 -3
  66. snowflake/ml/modeling/covariance/graphical_lasso.py +6 -3
  67. snowflake/ml/modeling/covariance/graphical_lasso_cv.py +6 -3
  68. snowflake/ml/modeling/covariance/ledoit_wolf.py +6 -3
  69. snowflake/ml/modeling/covariance/min_cov_det.py +6 -3
  70. snowflake/ml/modeling/covariance/oas.py +6 -3
  71. snowflake/ml/modeling/covariance/shrunk_covariance.py +6 -3
  72. snowflake/ml/modeling/decomposition/dictionary_learning.py +6 -3
  73. snowflake/ml/modeling/decomposition/factor_analysis.py +6 -3
  74. snowflake/ml/modeling/decomposition/fast_ica.py +6 -3
  75. snowflake/ml/modeling/decomposition/incremental_pca.py +6 -3
  76. snowflake/ml/modeling/decomposition/kernel_pca.py +6 -3
  77. snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +6 -3
  78. snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +6 -3
  79. snowflake/ml/modeling/decomposition/pca.py +6 -3
  80. snowflake/ml/modeling/decomposition/sparse_pca.py +6 -3
  81. snowflake/ml/modeling/decomposition/truncated_svd.py +6 -3
  82. snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +6 -3
  83. snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +6 -3
  84. snowflake/ml/modeling/ensemble/ada_boost_classifier.py +6 -3
  85. snowflake/ml/modeling/ensemble/ada_boost_regressor.py +6 -3
  86. snowflake/ml/modeling/ensemble/bagging_classifier.py +6 -3
  87. snowflake/ml/modeling/ensemble/bagging_regressor.py +6 -3
  88. snowflake/ml/modeling/ensemble/extra_trees_classifier.py +6 -3
  89. snowflake/ml/modeling/ensemble/extra_trees_regressor.py +6 -3
  90. snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +6 -3
  91. snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +6 -3
  92. snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +6 -3
  93. snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +6 -3
  94. snowflake/ml/modeling/ensemble/isolation_forest.py +6 -3
  95. snowflake/ml/modeling/ensemble/random_forest_classifier.py +6 -3
  96. snowflake/ml/modeling/ensemble/random_forest_regressor.py +6 -3
  97. snowflake/ml/modeling/ensemble/stacking_regressor.py +6 -3
  98. snowflake/ml/modeling/ensemble/voting_classifier.py +6 -3
  99. snowflake/ml/modeling/ensemble/voting_regressor.py +6 -3
  100. snowflake/ml/modeling/feature_selection/generic_univariate_select.py +6 -3
  101. snowflake/ml/modeling/feature_selection/select_fdr.py +6 -3
  102. snowflake/ml/modeling/feature_selection/select_fpr.py +6 -3
  103. snowflake/ml/modeling/feature_selection/select_fwe.py +6 -3
  104. snowflake/ml/modeling/feature_selection/select_k_best.py +6 -3
  105. snowflake/ml/modeling/feature_selection/select_percentile.py +6 -3
  106. snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +6 -3
  107. snowflake/ml/modeling/feature_selection/variance_threshold.py +6 -3
  108. snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +6 -3
  109. snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +6 -3
  110. snowflake/ml/modeling/impute/iterative_imputer.py +6 -3
  111. snowflake/ml/modeling/impute/knn_imputer.py +6 -3
  112. snowflake/ml/modeling/impute/missing_indicator.py +6 -3
  113. snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +6 -3
  114. snowflake/ml/modeling/kernel_approximation/nystroem.py +6 -3
  115. snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +6 -3
  116. snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +6 -3
  117. snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +6 -3
  118. snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +6 -3
  119. snowflake/ml/modeling/lightgbm/lgbm_classifier.py +6 -3
  120. snowflake/ml/modeling/lightgbm/lgbm_regressor.py +6 -3
  121. snowflake/ml/modeling/linear_model/ard_regression.py +6 -3
  122. snowflake/ml/modeling/linear_model/bayesian_ridge.py +6 -3
  123. snowflake/ml/modeling/linear_model/elastic_net.py +6 -3
  124. snowflake/ml/modeling/linear_model/elastic_net_cv.py +6 -3
  125. snowflake/ml/modeling/linear_model/gamma_regressor.py +6 -3
  126. snowflake/ml/modeling/linear_model/huber_regressor.py +6 -3
  127. snowflake/ml/modeling/linear_model/lars.py +6 -3
  128. snowflake/ml/modeling/linear_model/lars_cv.py +6 -3
  129. snowflake/ml/modeling/linear_model/lasso.py +6 -3
  130. snowflake/ml/modeling/linear_model/lasso_cv.py +6 -3
  131. snowflake/ml/modeling/linear_model/lasso_lars.py +6 -3
  132. snowflake/ml/modeling/linear_model/lasso_lars_cv.py +6 -3
  133. snowflake/ml/modeling/linear_model/lasso_lars_ic.py +6 -3
  134. snowflake/ml/modeling/linear_model/linear_regression.py +6 -3
  135. snowflake/ml/modeling/linear_model/logistic_regression.py +6 -3
  136. snowflake/ml/modeling/linear_model/logistic_regression_cv.py +6 -3
  137. snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +6 -3
  138. snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +6 -3
  139. snowflake/ml/modeling/linear_model/multi_task_lasso.py +6 -3
  140. snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +6 -3
  141. snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +6 -3
  142. snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +6 -3
  143. snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +6 -3
  144. snowflake/ml/modeling/linear_model/perceptron.py +6 -3
  145. snowflake/ml/modeling/linear_model/poisson_regressor.py +6 -3
  146. snowflake/ml/modeling/linear_model/ransac_regressor.py +6 -3
  147. snowflake/ml/modeling/linear_model/ridge.py +6 -3
  148. snowflake/ml/modeling/linear_model/ridge_classifier.py +6 -3
  149. snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +6 -3
  150. snowflake/ml/modeling/linear_model/ridge_cv.py +6 -3
  151. snowflake/ml/modeling/linear_model/sgd_classifier.py +6 -3
  152. snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +6 -3
  153. snowflake/ml/modeling/linear_model/sgd_regressor.py +6 -3
  154. snowflake/ml/modeling/linear_model/theil_sen_regressor.py +6 -3
  155. snowflake/ml/modeling/linear_model/tweedie_regressor.py +6 -3
  156. snowflake/ml/modeling/manifold/isomap.py +6 -3
  157. snowflake/ml/modeling/manifold/mds.py +6 -3
  158. snowflake/ml/modeling/manifold/spectral_embedding.py +6 -3
  159. snowflake/ml/modeling/manifold/tsne.py +6 -3
  160. snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +6 -3
  161. snowflake/ml/modeling/mixture/gaussian_mixture.py +6 -3
  162. snowflake/ml/modeling/model_selection/grid_search_cv.py +17 -2
  163. snowflake/ml/modeling/model_selection/randomized_search_cv.py +17 -2
  164. snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +6 -3
  165. snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +6 -3
  166. snowflake/ml/modeling/multiclass/output_code_classifier.py +6 -3
  167. snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +6 -3
  168. snowflake/ml/modeling/naive_bayes/categorical_nb.py +6 -3
  169. snowflake/ml/modeling/naive_bayes/complement_nb.py +6 -3
  170. snowflake/ml/modeling/naive_bayes/gaussian_nb.py +6 -3
  171. snowflake/ml/modeling/naive_bayes/multinomial_nb.py +6 -3
  172. snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +6 -3
  173. snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +6 -3
  174. snowflake/ml/modeling/neighbors/kernel_density.py +6 -3
  175. snowflake/ml/modeling/neighbors/local_outlier_factor.py +6 -3
  176. snowflake/ml/modeling/neighbors/nearest_centroid.py +6 -3
  177. snowflake/ml/modeling/neighbors/nearest_neighbors.py +6 -3
  178. snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +6 -3
  179. snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +6 -3
  180. snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +6 -3
  181. snowflake/ml/modeling/neural_network/bernoulli_rbm.py +6 -3
  182. snowflake/ml/modeling/neural_network/mlp_classifier.py +6 -3
  183. snowflake/ml/modeling/neural_network/mlp_regressor.py +6 -3
  184. snowflake/ml/modeling/pipeline/pipeline.py +28 -3
  185. snowflake/ml/modeling/preprocessing/polynomial_features.py +8 -5
  186. snowflake/ml/modeling/semi_supervised/label_propagation.py +6 -3
  187. snowflake/ml/modeling/semi_supervised/label_spreading.py +6 -3
  188. snowflake/ml/modeling/svm/linear_svc.py +6 -3
  189. snowflake/ml/modeling/svm/linear_svr.py +6 -3
  190. snowflake/ml/modeling/svm/nu_svc.py +6 -3
  191. snowflake/ml/modeling/svm/nu_svr.py +6 -3
  192. snowflake/ml/modeling/svm/svc.py +6 -3
  193. snowflake/ml/modeling/svm/svr.py +6 -3
  194. snowflake/ml/modeling/tree/decision_tree_classifier.py +6 -3
  195. snowflake/ml/modeling/tree/decision_tree_regressor.py +6 -3
  196. snowflake/ml/modeling/tree/extra_tree_classifier.py +6 -3
  197. snowflake/ml/modeling/tree/extra_tree_regressor.py +6 -3
  198. snowflake/ml/modeling/xgboost/xgb_classifier.py +6 -3
  199. snowflake/ml/modeling/xgboost/xgb_regressor.py +6 -3
  200. snowflake/ml/modeling/xgboost/xgbrf_classifier.py +6 -3
  201. snowflake/ml/modeling/xgboost/xgbrf_regressor.py +6 -3
  202. snowflake/ml/registry/registry.py +34 -4
  203. snowflake/ml/version.py +1 -1
  204. {snowflake_ml_python-1.7.3.dist-info → snowflake_ml_python-1.7.5.dist-info}/METADATA +81 -33
  205. {snowflake_ml_python-1.7.3.dist-info → snowflake_ml_python-1.7.5.dist-info}/RECORD +208 -196
  206. {snowflake_ml_python-1.7.3.dist-info → snowflake_ml_python-1.7.5.dist-info}/WHEEL +1 -1
  207. {snowflake_ml_python-1.7.3.dist-info → snowflake_ml_python-1.7.5.dist-info}/LICENSE.txt +0 -0
  208. {snowflake_ml_python-1.7.3.dist-info → snowflake_ml_python-1.7.5.dist-info}/top_level.txt +0 -0
@@ -37,6 +37,7 @@ from snowflake.ml.model.model_signature import (
37
37
  FeatureSpec,
38
38
  ModelSignature,
39
39
  _infer_signature,
40
+ _truncate_data,
40
41
  _rename_signature_with_snowflake_identifiers,
41
42
  )
42
43
 
@@ -57,6 +58,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.ensemble".replace("sklea
57
58
 
58
59
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
59
60
 
61
+ INFER_SIGNATURE_MAX_ROWS = 100
62
+
60
63
  class RandomForestClassifier(BaseTransformer):
61
64
  r"""A random forest classifier
62
65
  For more details on this class, see [sklearn.ensemble.RandomForestClassifier]
@@ -599,7 +602,7 @@ class RandomForestClassifier(BaseTransformer):
599
602
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
600
603
  expected_dtype = "array"
601
604
  else:
602
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
605
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
603
606
  # We can only infer the output types from the input types if the following two statemetns are true:
604
607
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
605
608
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1260,7 +1263,7 @@ class RandomForestClassifier(BaseTransformer):
1260
1263
 
1261
1264
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1262
1265
 
1263
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1266
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1264
1267
  outputs: List[BaseFeatureSpec] = []
1265
1268
  if hasattr(self, "predict"):
1266
1269
  # keep mypy happy
@@ -1268,7 +1271,7 @@ class RandomForestClassifier(BaseTransformer):
1268
1271
  # For classifier, the type of predict is the same as the type of label
1269
1272
  if self._sklearn_object._estimator_type == "classifier":
1270
1273
  # label columns is the desired type for output
1271
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1274
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1272
1275
  # rename the output columns
1273
1276
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1274
1277
  self._model_signature_dict["predict"] = ModelSignature(
@@ -37,6 +37,7 @@ from snowflake.ml.model.model_signature import (
37
37
  FeatureSpec,
38
38
  ModelSignature,
39
39
  _infer_signature,
40
+ _truncate_data,
40
41
  _rename_signature_with_snowflake_identifiers,
41
42
  )
42
43
 
@@ -57,6 +58,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.ensemble".replace("sklea
57
58
 
58
59
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
59
60
 
61
+ INFER_SIGNATURE_MAX_ROWS = 100
62
+
60
63
  class RandomForestRegressor(BaseTransformer):
61
64
  r"""A random forest regressor
62
65
  For more details on this class, see [sklearn.ensemble.RandomForestRegressor]
@@ -575,7 +578,7 @@ class RandomForestRegressor(BaseTransformer):
575
578
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
576
579
  expected_dtype = "array"
577
580
  else:
578
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
581
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
579
582
  # We can only infer the output types from the input types if the following two statemetns are true:
580
583
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
581
584
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1232,7 +1235,7 @@ class RandomForestRegressor(BaseTransformer):
1232
1235
 
1233
1236
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1234
1237
 
1235
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1238
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1236
1239
  outputs: List[BaseFeatureSpec] = []
1237
1240
  if hasattr(self, "predict"):
1238
1241
  # keep mypy happy
@@ -1240,7 +1243,7 @@ class RandomForestRegressor(BaseTransformer):
1240
1243
  # For classifier, the type of predict is the same as the type of label
1241
1244
  if self._sklearn_object._estimator_type == "classifier":
1242
1245
  # label columns is the desired type for output
1243
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1246
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1244
1247
  # rename the output columns
1245
1248
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1246
1249
  self._model_signature_dict["predict"] = ModelSignature(
@@ -37,6 +37,7 @@ from snowflake.ml.model.model_signature import (
37
37
  FeatureSpec,
38
38
  ModelSignature,
39
39
  _infer_signature,
40
+ _truncate_data,
40
41
  _rename_signature_with_snowflake_identifiers,
41
42
  )
42
43
 
@@ -57,6 +58,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.ensemble".replace("sklea
57
58
 
58
59
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
59
60
 
61
+ INFER_SIGNATURE_MAX_ROWS = 100
62
+
60
63
  class StackingRegressor(BaseTransformer):
61
64
  r"""Stack of estimators with a final regressor
62
65
  For more details on this class, see [sklearn.ensemble.StackingRegressor]
@@ -462,7 +465,7 @@ class StackingRegressor(BaseTransformer):
462
465
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
463
466
  expected_dtype = "array"
464
467
  else:
465
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
468
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
466
469
  # We can only infer the output types from the input types if the following two statemetns are true:
467
470
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
468
471
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1121,7 +1124,7 @@ class StackingRegressor(BaseTransformer):
1121
1124
 
1122
1125
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1123
1126
 
1124
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1127
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1125
1128
  outputs: List[BaseFeatureSpec] = []
1126
1129
  if hasattr(self, "predict"):
1127
1130
  # keep mypy happy
@@ -1129,7 +1132,7 @@ class StackingRegressor(BaseTransformer):
1129
1132
  # For classifier, the type of predict is the same as the type of label
1130
1133
  if self._sklearn_object._estimator_type == "classifier":
1131
1134
  # label columns is the desired type for output
1132
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1135
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1133
1136
  # rename the output columns
1134
1137
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1135
1138
  self._model_signature_dict["predict"] = ModelSignature(
@@ -37,6 +37,7 @@ from snowflake.ml.model.model_signature import (
37
37
  FeatureSpec,
38
38
  ModelSignature,
39
39
  _infer_signature,
40
+ _truncate_data,
40
41
  _rename_signature_with_snowflake_identifiers,
41
42
  )
42
43
 
@@ -57,6 +58,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.ensemble".replace("sklea
57
58
 
58
59
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
59
60
 
61
+ INFER_SIGNATURE_MAX_ROWS = 100
62
+
60
63
  class VotingClassifier(BaseTransformer):
61
64
  r"""Soft Voting/Majority Rule classifier for unfitted estimators
62
65
  For more details on this class, see [sklearn.ensemble.VotingClassifier]
@@ -444,7 +447,7 @@ class VotingClassifier(BaseTransformer):
444
447
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
445
448
  expected_dtype = "array"
446
449
  else:
447
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
450
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
448
451
  # We can only infer the output types from the input types if the following two statemetns are true:
449
452
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
450
453
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1107,7 +1110,7 @@ class VotingClassifier(BaseTransformer):
1107
1110
 
1108
1111
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1109
1112
 
1110
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1113
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1111
1114
  outputs: List[BaseFeatureSpec] = []
1112
1115
  if hasattr(self, "predict"):
1113
1116
  # keep mypy happy
@@ -1115,7 +1118,7 @@ class VotingClassifier(BaseTransformer):
1115
1118
  # For classifier, the type of predict is the same as the type of label
1116
1119
  if self._sklearn_object._estimator_type == "classifier":
1117
1120
  # label columns is the desired type for output
1118
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1121
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1119
1122
  # rename the output columns
1120
1123
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1121
1124
  self._model_signature_dict["predict"] = ModelSignature(
@@ -37,6 +37,7 @@ from snowflake.ml.model.model_signature import (
37
37
  FeatureSpec,
38
38
  ModelSignature,
39
39
  _infer_signature,
40
+ _truncate_data,
40
41
  _rename_signature_with_snowflake_identifiers,
41
42
  )
42
43
 
@@ -57,6 +58,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.ensemble".replace("sklea
57
58
 
58
59
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
59
60
 
61
+ INFER_SIGNATURE_MAX_ROWS = 100
62
+
60
63
  class VotingRegressor(BaseTransformer):
61
64
  r"""Prediction voting regressor for unfitted estimators
62
65
  For more details on this class, see [sklearn.ensemble.VotingRegressor]
@@ -426,7 +429,7 @@ class VotingRegressor(BaseTransformer):
426
429
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
427
430
  expected_dtype = "array"
428
431
  else:
429
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
432
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
430
433
  # We can only infer the output types from the input types if the following two statemetns are true:
431
434
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
432
435
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1085,7 +1088,7 @@ class VotingRegressor(BaseTransformer):
1085
1088
 
1086
1089
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1087
1090
 
1088
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1091
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1089
1092
  outputs: List[BaseFeatureSpec] = []
1090
1093
  if hasattr(self, "predict"):
1091
1094
  # keep mypy happy
@@ -1093,7 +1096,7 @@ class VotingRegressor(BaseTransformer):
1093
1096
  # For classifier, the type of predict is the same as the type of label
1094
1097
  if self._sklearn_object._estimator_type == "classifier":
1095
1098
  # label columns is the desired type for output
1096
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1099
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1097
1100
  # rename the output columns
1098
1101
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1099
1102
  self._model_signature_dict["predict"] = ModelSignature(
@@ -38,6 +38,7 @@ from snowflake.ml.model.model_signature import (
38
38
  FeatureSpec,
39
39
  ModelSignature,
40
40
  _infer_signature,
41
+ _truncate_data,
41
42
  _rename_signature_with_snowflake_identifiers,
42
43
  )
43
44
 
@@ -58,6 +59,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.feature_selection".repla
58
59
 
59
60
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
60
61
 
62
+ INFER_SIGNATURE_MAX_ROWS = 100
63
+
61
64
  class GenericUnivariateSelect(BaseTransformer):
62
65
  r"""Univariate feature selector with configurable strategy
63
66
  For more details on this class, see [sklearn.feature_selection.GenericUnivariateSelect]
@@ -415,7 +418,7 @@ class GenericUnivariateSelect(BaseTransformer):
415
418
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
416
419
  expected_dtype = "array"
417
420
  else:
418
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
421
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
419
422
  # We can only infer the output types from the input types if the following two statemetns are true:
420
423
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
421
424
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1072,7 +1075,7 @@ class GenericUnivariateSelect(BaseTransformer):
1072
1075
 
1073
1076
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1074
1077
 
1075
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1078
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1076
1079
  outputs: List[BaseFeatureSpec] = []
1077
1080
  if hasattr(self, "predict"):
1078
1081
  # keep mypy happy
@@ -1080,7 +1083,7 @@ class GenericUnivariateSelect(BaseTransformer):
1080
1083
  # For classifier, the type of predict is the same as the type of label
1081
1084
  if self._sklearn_object._estimator_type == "classifier":
1082
1085
  # label columns is the desired type for output
1083
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1086
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1084
1087
  # rename the output columns
1085
1088
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1086
1089
  self._model_signature_dict["predict"] = ModelSignature(
@@ -38,6 +38,7 @@ from snowflake.ml.model.model_signature import (
38
38
  FeatureSpec,
39
39
  ModelSignature,
40
40
  _infer_signature,
41
+ _truncate_data,
41
42
  _rename_signature_with_snowflake_identifiers,
42
43
  )
43
44
 
@@ -58,6 +59,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.feature_selection".repla
58
59
 
59
60
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
60
61
 
62
+ INFER_SIGNATURE_MAX_ROWS = 100
63
+
61
64
  class SelectFdr(BaseTransformer):
62
65
  r"""Filter: Select the p-values for an estimated false discovery rate
63
66
  For more details on this class, see [sklearn.feature_selection.SelectFdr]
@@ -410,7 +413,7 @@ class SelectFdr(BaseTransformer):
410
413
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
411
414
  expected_dtype = "array"
412
415
  else:
413
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
416
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
414
417
  # We can only infer the output types from the input types if the following two statemetns are true:
415
418
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
416
419
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1067,7 +1070,7 @@ class SelectFdr(BaseTransformer):
1067
1070
 
1068
1071
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1069
1072
 
1070
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1073
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1071
1074
  outputs: List[BaseFeatureSpec] = []
1072
1075
  if hasattr(self, "predict"):
1073
1076
  # keep mypy happy
@@ -1075,7 +1078,7 @@ class SelectFdr(BaseTransformer):
1075
1078
  # For classifier, the type of predict is the same as the type of label
1076
1079
  if self._sklearn_object._estimator_type == "classifier":
1077
1080
  # label columns is the desired type for output
1078
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1081
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1079
1082
  # rename the output columns
1080
1083
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1081
1084
  self._model_signature_dict["predict"] = ModelSignature(
@@ -38,6 +38,7 @@ from snowflake.ml.model.model_signature import (
38
38
  FeatureSpec,
39
39
  ModelSignature,
40
40
  _infer_signature,
41
+ _truncate_data,
41
42
  _rename_signature_with_snowflake_identifiers,
42
43
  )
43
44
 
@@ -58,6 +59,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.feature_selection".repla
58
59
 
59
60
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
60
61
 
62
+ INFER_SIGNATURE_MAX_ROWS = 100
63
+
61
64
  class SelectFpr(BaseTransformer):
62
65
  r"""Filter: Select the pvalues below alpha based on a FPR test
63
66
  For more details on this class, see [sklearn.feature_selection.SelectFpr]
@@ -410,7 +413,7 @@ class SelectFpr(BaseTransformer):
410
413
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
411
414
  expected_dtype = "array"
412
415
  else:
413
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
416
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
414
417
  # We can only infer the output types from the input types if the following two statemetns are true:
415
418
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
416
419
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1067,7 +1070,7 @@ class SelectFpr(BaseTransformer):
1067
1070
 
1068
1071
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1069
1072
 
1070
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1073
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1071
1074
  outputs: List[BaseFeatureSpec] = []
1072
1075
  if hasattr(self, "predict"):
1073
1076
  # keep mypy happy
@@ -1075,7 +1078,7 @@ class SelectFpr(BaseTransformer):
1075
1078
  # For classifier, the type of predict is the same as the type of label
1076
1079
  if self._sklearn_object._estimator_type == "classifier":
1077
1080
  # label columns is the desired type for output
1078
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1081
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1079
1082
  # rename the output columns
1080
1083
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1081
1084
  self._model_signature_dict["predict"] = ModelSignature(
@@ -38,6 +38,7 @@ from snowflake.ml.model.model_signature import (
38
38
  FeatureSpec,
39
39
  ModelSignature,
40
40
  _infer_signature,
41
+ _truncate_data,
41
42
  _rename_signature_with_snowflake_identifiers,
42
43
  )
43
44
 
@@ -58,6 +59,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.feature_selection".repla
58
59
 
59
60
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
60
61
 
62
+ INFER_SIGNATURE_MAX_ROWS = 100
63
+
61
64
  class SelectFwe(BaseTransformer):
62
65
  r"""Filter: Select the p-values corresponding to Family-wise error rate
63
66
  For more details on this class, see [sklearn.feature_selection.SelectFwe]
@@ -410,7 +413,7 @@ class SelectFwe(BaseTransformer):
410
413
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
411
414
  expected_dtype = "array"
412
415
  else:
413
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
416
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
414
417
  # We can only infer the output types from the input types if the following two statemetns are true:
415
418
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
416
419
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1067,7 +1070,7 @@ class SelectFwe(BaseTransformer):
1067
1070
 
1068
1071
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1069
1072
 
1070
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1073
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1071
1074
  outputs: List[BaseFeatureSpec] = []
1072
1075
  if hasattr(self, "predict"):
1073
1076
  # keep mypy happy
@@ -1075,7 +1078,7 @@ class SelectFwe(BaseTransformer):
1075
1078
  # For classifier, the type of predict is the same as the type of label
1076
1079
  if self._sklearn_object._estimator_type == "classifier":
1077
1080
  # label columns is the desired type for output
1078
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1081
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1079
1082
  # rename the output columns
1080
1083
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1081
1084
  self._model_signature_dict["predict"] = ModelSignature(
@@ -38,6 +38,7 @@ from snowflake.ml.model.model_signature import (
38
38
  FeatureSpec,
39
39
  ModelSignature,
40
40
  _infer_signature,
41
+ _truncate_data,
41
42
  _rename_signature_with_snowflake_identifiers,
42
43
  )
43
44
 
@@ -58,6 +59,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.feature_selection".repla
58
59
 
59
60
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
60
61
 
62
+ INFER_SIGNATURE_MAX_ROWS = 100
63
+
61
64
  class SelectKBest(BaseTransformer):
62
65
  r"""Select features according to the k highest scores
63
66
  For more details on this class, see [sklearn.feature_selection.SelectKBest]
@@ -411,7 +414,7 @@ class SelectKBest(BaseTransformer):
411
414
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
412
415
  expected_dtype = "array"
413
416
  else:
414
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
417
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
415
418
  # We can only infer the output types from the input types if the following two statemetns are true:
416
419
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
417
420
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1068,7 +1071,7 @@ class SelectKBest(BaseTransformer):
1068
1071
 
1069
1072
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1070
1073
 
1071
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1074
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1072
1075
  outputs: List[BaseFeatureSpec] = []
1073
1076
  if hasattr(self, "predict"):
1074
1077
  # keep mypy happy
@@ -1076,7 +1079,7 @@ class SelectKBest(BaseTransformer):
1076
1079
  # For classifier, the type of predict is the same as the type of label
1077
1080
  if self._sklearn_object._estimator_type == "classifier":
1078
1081
  # label columns is the desired type for output
1079
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1082
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1080
1083
  # rename the output columns
1081
1084
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1082
1085
  self._model_signature_dict["predict"] = ModelSignature(
@@ -38,6 +38,7 @@ from snowflake.ml.model.model_signature import (
38
38
  FeatureSpec,
39
39
  ModelSignature,
40
40
  _infer_signature,
41
+ _truncate_data,
41
42
  _rename_signature_with_snowflake_identifiers,
42
43
  )
43
44
 
@@ -58,6 +59,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.feature_selection".repla
58
59
 
59
60
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
60
61
 
62
+ INFER_SIGNATURE_MAX_ROWS = 100
63
+
61
64
  class SelectPercentile(BaseTransformer):
62
65
  r"""Select features according to a percentile of the highest scores
63
66
  For more details on this class, see [sklearn.feature_selection.SelectPercentile]
@@ -410,7 +413,7 @@ class SelectPercentile(BaseTransformer):
410
413
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
411
414
  expected_dtype = "array"
412
415
  else:
413
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
416
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
414
417
  # We can only infer the output types from the input types if the following two statemetns are true:
415
418
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
416
419
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1067,7 +1070,7 @@ class SelectPercentile(BaseTransformer):
1067
1070
 
1068
1071
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1069
1072
 
1070
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1073
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1071
1074
  outputs: List[BaseFeatureSpec] = []
1072
1075
  if hasattr(self, "predict"):
1073
1076
  # keep mypy happy
@@ -1075,7 +1078,7 @@ class SelectPercentile(BaseTransformer):
1075
1078
  # For classifier, the type of predict is the same as the type of label
1076
1079
  if self._sklearn_object._estimator_type == "classifier":
1077
1080
  # label columns is the desired type for output
1078
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1081
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1079
1082
  # rename the output columns
1080
1083
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1081
1084
  self._model_signature_dict["predict"] = ModelSignature(
@@ -37,6 +37,7 @@ from snowflake.ml.model.model_signature import (
37
37
  FeatureSpec,
38
38
  ModelSignature,
39
39
  _infer_signature,
40
+ _truncate_data,
40
41
  _rename_signature_with_snowflake_identifiers,
41
42
  )
42
43
 
@@ -57,6 +58,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.feature_selection".repla
57
58
 
58
59
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
59
60
 
61
+ INFER_SIGNATURE_MAX_ROWS = 100
62
+
60
63
  class SequentialFeatureSelector(BaseTransformer):
61
64
  r"""Transformer that performs Sequential Feature Selection
62
65
  For more details on this class, see [sklearn.feature_selection.SequentialFeatureSelector]
@@ -472,7 +475,7 @@ class SequentialFeatureSelector(BaseTransformer):
472
475
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
473
476
  expected_dtype = "array"
474
477
  else:
475
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
478
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
476
479
  # We can only infer the output types from the input types if the following two statemetns are true:
477
480
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
478
481
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1129,7 +1132,7 @@ class SequentialFeatureSelector(BaseTransformer):
1129
1132
 
1130
1133
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1131
1134
 
1132
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1135
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1133
1136
  outputs: List[BaseFeatureSpec] = []
1134
1137
  if hasattr(self, "predict"):
1135
1138
  # keep mypy happy
@@ -1137,7 +1140,7 @@ class SequentialFeatureSelector(BaseTransformer):
1137
1140
  # For classifier, the type of predict is the same as the type of label
1138
1141
  if self._sklearn_object._estimator_type == "classifier":
1139
1142
  # label columns is the desired type for output
1140
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1143
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1141
1144
  # rename the output columns
1142
1145
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1143
1146
  self._model_signature_dict["predict"] = ModelSignature(
@@ -37,6 +37,7 @@ from snowflake.ml.model.model_signature import (
37
37
  FeatureSpec,
38
38
  ModelSignature,
39
39
  _infer_signature,
40
+ _truncate_data,
40
41
  _rename_signature_with_snowflake_identifiers,
41
42
  )
42
43
 
@@ -57,6 +58,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.feature_selection".repla
57
58
 
58
59
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
59
60
 
61
+ INFER_SIGNATURE_MAX_ROWS = 100
62
+
60
63
  class VarianceThreshold(BaseTransformer):
61
64
  r"""Feature selector that removes all low-variance features
62
65
  For more details on this class, see [sklearn.feature_selection.VarianceThreshold]
@@ -403,7 +406,7 @@ class VarianceThreshold(BaseTransformer):
403
406
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
404
407
  expected_dtype = "array"
405
408
  else:
406
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
409
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
407
410
  # We can only infer the output types from the input types if the following two statemetns are true:
408
411
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
409
412
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1060,7 +1063,7 @@ class VarianceThreshold(BaseTransformer):
1060
1063
 
1061
1064
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1062
1065
 
1063
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1066
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1064
1067
  outputs: List[BaseFeatureSpec] = []
1065
1068
  if hasattr(self, "predict"):
1066
1069
  # keep mypy happy
@@ -1068,7 +1071,7 @@ class VarianceThreshold(BaseTransformer):
1068
1071
  # For classifier, the type of predict is the same as the type of label
1069
1072
  if self._sklearn_object._estimator_type == "classifier":
1070
1073
  # label columns is the desired type for output
1071
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1074
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1072
1075
  # rename the output columns
1073
1076
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1074
1077
  self._model_signature_dict["predict"] = ModelSignature(
@@ -37,6 +37,7 @@ from snowflake.ml.model.model_signature import (
37
37
  FeatureSpec,
38
38
  ModelSignature,
39
39
  _infer_signature,
40
+ _truncate_data,
40
41
  _rename_signature_with_snowflake_identifiers,
41
42
  )
42
43
 
@@ -57,6 +58,8 @@ _SUBPROJECT = "".join([s.capitalize() for s in "sklearn.gaussian_process".replac
57
58
 
58
59
  DATAFRAME_TYPE = Union[DataFrame, pd.DataFrame]
59
60
 
61
+ INFER_SIGNATURE_MAX_ROWS = 100
62
+
60
63
  class GaussianProcessClassifier(BaseTransformer):
61
64
  r"""Gaussian process classification (GPC) based on Laplace approximation
62
65
  For more details on this class, see [sklearn.gaussian_process.GaussianProcessClassifier]
@@ -496,7 +499,7 @@ class GaussianProcessClassifier(BaseTransformer):
496
499
  elif hasattr(self._sklearn_object, "n_components") and getattr(self._sklearn_object, "n_components") != len(self.output_cols):
497
500
  expected_dtype = "array"
498
501
  else:
499
- output_types = [signature.as_snowpark_type() for signature in _infer_signature(dataset[self.input_cols], "output", use_snowflake_identifiers=True)]
502
+ output_types = [signature.as_snowpark_type() for signature in _infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True)]
500
503
  # We can only infer the output types from the input types if the following two statemetns are true:
501
504
  # 1) All of the output types are the same. Otherwise, we still have to fall back to variant because `_sklearn_inference` only accepts one type.
502
505
  # 2) The length of the input columns equals the length of the output columns. Otherwise the transform will likely result in an `ARRAY`.
@@ -1157,7 +1160,7 @@ class GaussianProcessClassifier(BaseTransformer):
1157
1160
 
1158
1161
  PROB_FUNCTIONS = ["predict_log_proba", "predict_proba", "decision_function"]
1159
1162
 
1160
- inputs = list(_infer_signature(dataset[self.input_cols], "input", use_snowflake_identifiers=True))
1163
+ inputs = list(_infer_signature(_truncate_data(dataset[self.input_cols], INFER_SIGNATURE_MAX_ROWS), "input", use_snowflake_identifiers=True))
1161
1164
  outputs: List[BaseFeatureSpec] = []
1162
1165
  if hasattr(self, "predict"):
1163
1166
  # keep mypy happy
@@ -1165,7 +1168,7 @@ class GaussianProcessClassifier(BaseTransformer):
1165
1168
  # For classifier, the type of predict is the same as the type of label
1166
1169
  if self._sklearn_object._estimator_type == "classifier":
1167
1170
  # label columns is the desired type for output
1168
- outputs = list(_infer_signature(dataset[self.label_cols], "output", use_snowflake_identifiers=True))
1171
+ outputs = list(_infer_signature(_truncate_data(dataset[self.label_cols], INFER_SIGNATURE_MAX_ROWS), "output", use_snowflake_identifiers=True))
1169
1172
  # rename the output columns
1170
1173
  outputs = list(model_signature_utils.rename_features(outputs, self.output_cols))
1171
1174
  self._model_signature_dict["predict"] = ModelSignature(