@@ -250,6 +250,7 @@ def score(var1, var2, var3, var4):
250
250
input_var_list ,
251
251
missing_values = missing_values ,
252
252
dtype_list = input_dtypes_list ,
253
+ preprocess_function = preprocess_function
253
254
)
254
255
self ._predictions_to_metrics (
255
256
score_metrics ,
@@ -266,6 +267,7 @@ def score(var1, var2, var3, var4):
266
267
missing_values = missing_values ,
267
268
statsmodels_model = "statsmodels_model" in kwargs ,
268
269
tf_model = "tf_keras_model" in kwargs or "tf_core_model" in kwargs ,
270
+ preprocess_function = preprocess_function
269
271
)
270
272
# Include check for numpy values and a conversion operation as needed
271
273
self .score_code += (
@@ -814,14 +816,15 @@ def _predict_method(
814
816
input_frame = f'{{{ ", " .join (input_dict )} }}, index=index'
815
817
self .score_code += self ._wrap_indent_string (input_frame , 8 )
816
818
self .score_code += f"\n { '' :4} )\n "
817
- if preprocess_function :
818
- self .score_code += (
819
- f"{ '' :4} input_array = { preprocess_function .__name__ } (input_array)"
820
- )
819
+
821
820
if missing_values :
822
821
self .score_code += (
823
822
f"{ '' :4} input_array = impute_missing_values(input_array)\n "
824
823
)
824
+ if preprocess_function :
825
+ self .score_code += (
826
+ f"{ '' :4} input_array = { preprocess_function .__name__ } (input_array)\n "
827
+ )
825
828
self .score_code += (
826
829
f"{ '' :4} column_types = { column_types } \n "
827
830
f"{ '' :4} h2o_array = h2o.H2OFrame(input_array, "
@@ -860,14 +863,14 @@ def _predict_method(
860
863
input_frame = f'{{{ ", " .join (input_dict )} }}, index=index'
861
864
self .score_code += self ._wrap_indent_string (input_frame , 8 )
862
865
self .score_code += f"\n { '' :4} )\n "
863
- if preprocess_function :
864
- self .score_code += (
865
- f"{ '' :4} input_array = { preprocess_function .__name__ } (input_array)"
866
- )
867
866
if missing_values :
868
867
self .score_code += (
869
868
f"{ '' :4} input_array = impute_missing_values(input_array)\n "
870
869
)
870
+ if preprocess_function :
871
+ self .score_code += (
872
+ f"{ '' :4} input_array = { preprocess_function .__name__ } (input_array)\n "
873
+ )
871
874
self .score_code += (
872
875
f"{ '' :4} prediction = model.{ method .__name__ } (input_array)\n "
873
876
)
@@ -885,14 +888,14 @@ def _predict_method(
885
888
input_frame = f'{{{ ", " .join (input_dict )} }}, index=index'
886
889
self .score_code += self ._wrap_indent_string (input_frame , 8 )
887
890
self .score_code += f"\n { '' :4} )\n "
888
- if preprocess_function :
889
- self .score_code += (
890
- f"{ '' :4} input_array = { preprocess_function .__name__ } (input_array)"
891
- )
892
891
if missing_values :
893
892
self .score_code += (
894
893
f"{ '' :4} input_array = impute_missing_values(input_array)\n "
895
894
)
895
+ if preprocess_function :
896
+ self .score_code += (
897
+ f"{ '' :4} input_array = { preprocess_function .__name__ } (input_array)\n "
898
+ )
896
899
self .score_code += (
897
900
f"{ '' :4} prediction = model.{ method .__name__ } (input_array)\n \n "
898
901
f"{ '' :4} # Check if model returns logits or probabilities\n "
@@ -921,14 +924,14 @@ def _predict_method(
921
924
input_frame = f'{{{ ", " .join (input_dict )} }}, index=index'
922
925
self .score_code += self ._wrap_indent_string (input_frame , 8 )
923
926
self .score_code += f"\n { '' :4} )\n "
924
- if preprocess_function :
925
- self .score_code += (
926
- f"{ '' :4} input_array = { preprocess_function .__name__ } (input_array)"
927
- )
928
927
if missing_values :
929
928
self .score_code += (
930
929
f"{ '' :4} input_array = impute_missing_values(input_array)\n "
931
930
)
931
+ if preprocess_function :
932
+ self .score_code += (
933
+ f"{ '' :4} input_array = { preprocess_function .__name__ } (input_array)\n "
934
+ )
932
935
self .score_code += (
933
936
f"{ '' :4} prediction = model.{ method .__name__ } (input_array).tolist()\n "
934
937
)
0 commit comments