I am new to the world of machine learning, and have been really struggling with the following problem.
I am trying to use this module fanova (available on github; https://github.com/automl/fanova) which decomposes the functional variance of a function and its components. In the context of machine learning, I want to use it to determine the importance of the different hyperparameters that I have tried on my model.
My main issue is I think on lines 288-294 as when I try to run the piece of code:
# make prediction for all midpoints and weigh them by the corresponding size
for i, (m, s) in enumerate(zip(prod_midpoints, prod_sizes)):
sample[list(dimensions)] = list(m)
ls = self.the_forest.marginal_prediction_stat_of_tree(tree_idx, sample.tolist())
# self.logger.debug("%s, %s", (sample, ls.mean()))
if not np.isnan(ls.mean()):
stat.push(ls.mean(), np.prod(np.array(s)) * ls.sum_of_weights())
I get the following error:
“SwiPyObject has no attribute mean”.
Now I think it is because the object “ls” is a SwigPyObject, and therefore, does not allow me to take/access the mean directly.
I expect a list/array in the end which has the mean of all of the “ls” for all branches of the regression tree.
I have constructed the “pyrfr” module using Swig version 3.0.12 as suggested on the github page. However, I still get the same error.
I was wondering if there was a roundabout way to convert the ls object to a python object and then access the mean.
Apologies, I have never coded in C-related languages before, so any help is very much appreciated.
Thank you!
Adrija Mahapatra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.