@@ -127,7 +127,7 @@ def __call__(self,
127127 :param groupby_features: Strings indicating the feature(s) to group/segment on, so as to observe different
128128 effects per segment. By default will be binned by passing to :function:`foundry.evaluation.binned`. You can
129129 pass to this function yourself to manually control/remove binning.
130- :param vary_features_aggfun: The varying feature(s) will be binned, then within each bin we need to convert
130+ :param vary_features_aggfun: Numeric varying feature(s) will be binned, then within each bin we need to convert
131131 back to numeric before plugging into the model. This string indicates how to do so (default: mean). Either an
132132 aggregation that will be applied, or 'mid' to use the midpoint of the bin. The latter will be used regardless
133133 when no actual data exists in that bin. This argument can also be a dictionary with keys being feature-names.
@@ -139,15 +139,15 @@ def __call__(self,
139139 effect if ``marginalize_aggfun` is False/None.
140140 :param predict_kwargs: Keyword-arguments to pass to the pipeline's ``predict`` method.
141141 """
142+ X = X .copy (deep = False )
142143 if isinstance (marginalize_aggfun , str ) and marginalize_aggfun .startswith ('downsample' ):
143144 downsample_int = int (marginalize_aggfun .replace ('downsample' , '' ).rstrip ('_' ))
144- idx = np .random .choice (X .shape [0 ], size = downsample_int , replace = False )
145- X = _safe_indexing (X , idx )
146- if y is not None :
147- y = _safe_indexing (y , idx )
145+ if X .shape [0 ] > downsample_int :
146+ idx = np .random .choice (X .shape [0 ], size = downsample_int , replace = False )
147+ X = _safe_indexing (X , idx )
148+ if y is not None :
149+ y = _safe_indexing (y , idx )
148150 marginalize_aggfun = False
149- else :
150- X = X .copy (deep = False )
151151
152152 # validate/standardize args:
153153 vary_features = self ._standardize_maybe_binned (X , vary_features )
@@ -175,7 +175,6 @@ def __call__(self,
175175 )
176176
177177 # vary features ----
178- # TODO: this gets ignored for categorical features
179178 default = vary_features_aggfun .pop ('_default' , 'mean' ) if isinstance (vary_features_aggfun , dict ) else 'mean'
180179 vary_features_aggfuns = self ._standardize_maybe_dict (
181180 maybe_dict = vary_features_aggfun ,
0 commit comments