Modify Balanced Random Forest Sampling

231 views Asked by At

I want to change the sampling type in the BalancedRandomForest library from RandomUnderSampling to ClusterCentroid, I have changed this part

self.base_sampler_ = RandomUnderSampler(
        sampling_strategy=self._sampling_strategy,
        replacement=self.replacement,
    )

become this

 self.base_sampler_ = ClusterCentroids(
        sampling_strategy=self._sampling_strategy,
        replacement=self.replacement,
    )

That code i modified is in line #386.

after I run on jupyter notebook, I got an error like this

`---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-19-098f56165cd0> in <module>
      2 
      3 classifier = BalancedRandomForestClassifier(n_estimators=1000, random_state=5)
----> 4 classifier.fit(X_train, y_train)

~\Anaconda3\lib\site-packages\imblearn\ensemble\_forest.py in fit(self, X, y, sample_weight)
    481 
    482         # Check parameters
--> 483         self._validate_estimator()
    484 
    485         if not self.bootstrap and self.oob_score:

~\Anaconda3\lib\site-packages\imblearn\ensemble\_forest.py in _validate_estimator(self, default)
    371         self.base_sampler_ = ClusterCentroids(
    372             sampling_strategy=self._sampling_strategy,
--> 373             replacement=self.replacement,
    374         )
    375 

~\Anaconda3\lib\site-packages\imblearn\utils\_validation.py in inner_f(*args, **kwargs)
    638                           FutureWarning)
    639         kwargs.update({k: arg for k, arg in zip(sig.parameters, args)})
--> 640         return f(**kwargs)
    641     return inner_f

TypeError: __init__() got an unexpected keyword argument 'replacement'`

I don't know what to do now, is it still possible to change RandomSampling to ClusterCentroid ? Thanks.

0

There are 0 answers