1414
1515# noqa: D400
1616"""
17- # fANOVA
17+ # MOfANOVA
1818
1919This module provides a tool for assessing the importance of an algorithms Hyperparameters.
2020
2121Utilities provide calculation of the data wrt the budget and train the forest on the encoded data.
2222
2323## Classes
24- - fANOVA : Calculate and provide midpoints and sizes.
24+ - MOfANOVA : Calculate and provide midpoints and sizes.
2525"""
2626
27- from typing import List , Optional , Union
27+ from typing import Any , List , Optional , Union
2828
2929import pandas as pd
3030
@@ -38,8 +38,6 @@ class MOfANOVA(fANOVA):
3838 """
3939 Multi-Objective fANOVA.
4040
41- Calculate and provide midpoints and sizes from the forest's split values in order to get
42- the marginals.
4341 Override: to train the random forest with an arbitrary weighting of the objectives
4442 (multi-objective case).
4543 """
@@ -58,6 +56,7 @@ def calculate(
5856 budget : Optional [Union [int , float ]] = None ,
5957 n_trees : int = 100 ,
6058 seed : int = 0 ,
59+ y : Any = None ,
6160 ) -> None :
6261 """
6362 Get the data with respect to budget and train the forest on the encoded data.
@@ -103,19 +102,24 @@ def calculate(
103102 df [normed ] = 1 - df [normed ]
104103 objectives_normed .append (normed )
105104 df = df .dropna (subset = objectives_normed )
106- # X = df[self.hp_names].to_numpy()
105+
107106 weightings = get_weightings (objectives_normed , df )
107+
108108 df_all = pd .DataFrame ([])
109109
110110 # calculate importance for each weighting generated from the pareto efficient points
111111 for w in weightings :
112- # Y = sum(df[obj] *weighting for obj, weighting in zip(objectives_normed, w)).to_numpy()
112+ Y = sum (df [obj ] * weighting for obj , weighting in zip (objectives_normed , w )).to_numpy ()
113+
114+ super ().calculate (
115+ objectives = objectives , budget = budget , seed = seed , n_trees = self .n_trees , y = Y
116+ )
117+ self .importances = super ().get_importances ()
113118
114- self .importances = super ().calculate (objectives , budget , seed )
115- print (self .importances )
116119 df_res = pd .DataFrame .from_dict (self .importances ).loc [0 :1 ].T .reset_index ()
117120 df_res ["weight" ] = w [0 ]
118121 df_all = pd .concat ([df_all , df_res ])
122+
119123 self .importances_ = df_all .rename (
120124 columns = {0 : "importance" , 1 : "variance" , "index" : "hp_name" }
121125 ).reset_index (drop = True )
0 commit comments