pgmpy / pgmpy_notebook

Short Tutorial to Probabilistic Graphical Models(PGM) and pgmpy
http://pgmpy.org/
MIT License
369 stars 212 forks source link

HillClimbSearch -> TypeError: __init__() got an unexpected keyword argument 'scoring_method' #52

Closed fritol closed 2 years ago

fritol commented 2 years ago

i installed with : conda install -c ankurankan pgmpy

When running:

`from pgmpy.estimators import HillClimbSearch

data = pd.DataFrame(np.random.randint(0, 3, size=(2500, 8)), columns=list('ABCDEFGH')) data['A'] += data['B'] + data['C'] data['H'] = data['G'] - data['A']

hc = HillClimbSearch(data, scoring_method=BicScore(data)) best_model = hc.estimate() print(best_model.edges())`

i get this:

TypeError Traceback (most recent call last)

in 6 data['H'] = data['G'] - data['A'] 7 ----> 8 hc = HillClimbSearch(data, scoring_method=BicScore(data)) 9 best_model = hc.estimate() 10 print(best_model.edges()) ~\anaconda3\envs\backtest\lib\site-packages\pgmpy\estimators\HillClimbSearch.py in __init__(self, data, use_cache, **kwargs) 55 self.use_cache = use_cache 56 ---> 57 super(HillClimbSearch, self).__init__(data, **kwargs) 58 59 def _legal_operations( ~\anaconda3\envs\backtest\lib\site-packages\pgmpy\estimators\base.py in __init__(self, data, independencies, **kwargs) 292 self.variables = self.independencies.get_all_variables() 293 --> 294 super(StructureEstimator, self).__init__(data=data, **kwargs) 295 296 def estimate(self): TypeError: __init__() got an unexpected keyword argument 'scoring_method'
ankurankan commented 2 years ago

@fritol The scoring_method argument has been moved to the estimate method so that you don't have to create new objects for trying various scoring methods.