Problem in __update_mtry_tau_penality(self, x_t, x, y)
Dear socket778,
I was trying to run the file "example_gen.py" and I got this error: "/usr/local/lib/python3.10/dist-packages/xbcausalforest/xbcf_python.py in __update_mtry_tau_penality(self, x_t, x, y) 293 from math import log 294 --> 295 if self.params["no_split_penality"] < 0: 296 self.params["no_split_penality"] = log(self.params["num_cutpoints"]) 297 TypeError: '<' not supported between instances of 'str' and 'int'"
Unfortunatelly, my programming skills are not very good, so I cannot suggest a change in your code to solve this issue. My apologies!
However, if you could change the code to solve this issue, it would be highly appreciated!
Kind Regards,
Hugo
ChatGPT suggested this code adjustment:
from math import log
... other parts of your code ...
try: no_split_penalty = int(self.params["no_split_penality"]) except ValueError: # Handle the case where the conversion is not possible # For example, you could set it to a default integer value or raise an exception no_split_penalty = 0 # or some other default integer value # raise ValueError(f"Expected an integer for 'no_split_penality', got {self.params['no_split_penality']}")
if no_split_penalty < 0.00001: self.params["no_split_penality"] = log(self.params["num_cutpoints"])
Hi Hugo, I'm closing this issue as XBCF has become part of the StochasticTree package (available in both Python and R), please visit https://github.com/StochasticTree/stochtree-cpp for the most recent version of the package in case it's still relevant.