build/lib/AutoMxL/Modelisation/HyperOpt.py
def model_res_to_df(self, d_model_infos, sort_metric='F1'):
        """Store models summary in DataFrame

        Parameters
        ----------
        d_model_info : dict
            {model_index : {'HP', 'probas', 'model', 'features_importance', 'train_metrics', 'metrics', 'output'}
        sort_metric : string (default = 'F1')
            metric to sort models (descendant)

        Returns
        -------
        DataFrame
            model infos and metrics
        """
        # dataFrame columns names
        model_col = ['model_index']
        HP_col = list(self.d_train_model[0]['HP'].keys())
        bagging_col = ['bagging']
        metrics_col = ['Accuracy', 'Roc_auc', 'F1', 'Logloss', 'Precision', 'Recall', 'delta_auc']
        feat_imp_col = ['TOP_feat1', 'TOP_feat2', 'TOP_feat3', 'TOP_feat4', 'TOP_feat5']

        df_local = pd.DataFrame(columns=model_col + HP_col + bagging_col + metrics_col + feat_imp_col)

        # store informations in df
        for key, value in self.d_train_model.items():
            dict_tmp = {'model_index': key}
            dict_tmp.update(value['HP'].copy())
            dict_tmp.update({x: d_model_infos[key]['metrics'][x] for x in metrics_col})

            dict_tmp.update({'bagging': self.bagging})
            df_tmp = pd.DataFrame.from_dict(self.d_train_model[key]['features_importance'],
                                            orient='index').reset_index().rename(
                columns={'index': 'feat', 0: 'importance'}).sort_values(by='importance', ascending=False).head(5)
            serie_tmp = df_tmp['feat'] + ' ' + round(df_tmp['importance'], 5).astype(str)
            dict_tmp.update(dict(zip(feat_imp_col, serie_tmp.tolist())))

            df_local = df_local.append(dict_tmp, ignore_index=True)

        return df_local.loc[df_local['delta_auc'] <= 0.03].sort_values(by=sort_metric, ascending=False)
Store models summary in DataFrame

        Parameters
        ----------
        d_model_info : dict
            {model_index : {'HP', 'probas', 'model', 'features_importance', 'train_metrics', 'metrics', 'output'}
        sort_metric : string (default = 'F1')
            metric to sort models (descendant)

        Returns
        -------
        DataFrame
            model infos and metrics
        
Store models summary in DataFrame
Parameters



Returns

DataFrame
model infos and metrics
Store models summary in DataFrame Parameters Returns DataFrame model infos and metrics
def model_res_to_df(self, d_model_infos, sort_metric='F1'):
        model_col = ['model_index']
        HP_col = list(self.d_train_model[0]['HP'].keys())
        bagging_col = ['bagging']
        metrics_col = ['Accuracy', 'Roc_auc', 'F1', 'Logloss', 'Precision', 'Recall', 'delta_auc']
        feat_imp_col = ['TOP_feat1', 'TOP_feat2', 'TOP_feat3', 'TOP_feat4', 'TOP_feat5']
        df_local = pd.DataFrame(columns=model_col + HP_col + bagging_col + metrics_col + feat_imp_col)
        for key, value in self.d_train_model.items():
            dict_tmp = {'model_index': key}
            dict_tmp.update(value['HP'].copy())
            dict_tmp.update({x: d_model_infos[key]['metrics'][x] for x in metrics_col})
            dict_tmp.update({'bagging': self.bagging})
            df_tmp = pd.DataFrame.from_dict(self.d_train_model[key]['features_importance'],
                                            orient='index').reset_index().rename(
                columns={'index': 'feat', 0: 'importance'}).sort_values(by='importance', ascending=False).head(5)
            serie_tmp = df_tmp['feat'] + ' ' + round(df_tmp['importance'], 5).astype(str)
            dict_tmp.update(dict(zip(feat_imp_col, serie_tmp.tolist())))
            df_local = df_local.append(dict_tmp, ignore_index=True)
        return df_local.loc[df_local['delta_auc'] <= 0.03].sort_values(by=sort_metric, ascending=False)
def model_res_to_df ( self , d_model_infos , sort_metric = 'F1' ) : model_col = [ 'model_index' ] HP_col = list ( self . d_train_model [ 0 ] [ 'HP' ] . keys ( ) ) bagging_col = [ 'bagging' ] metrics_col = [ 'Accuracy' , 'Roc_auc' , 'F1' , 'Logloss' , 'Precision' , 'Recall' , 'delta_auc' ] feat_imp_col = [ 'TOP_feat1' , 'TOP_feat2' , 'TOP_feat3' , 'TOP_feat4' , 'TOP_feat5' ] df_local = pd . DataFrame ( columns = model_col + HP_col + bagging_col + metrics_col + feat_imp_col ) for key , value in self . d_train_model . items ( ) : dict_tmp = { 'model_index' : key } dict_tmp . update ( value [ 'HP' ] . copy ( ) ) dict_tmp . update ( { x : d_model_infos [ key ] [ 'metrics' ] [ x ] for x in metrics_col } ) dict_tmp . update ( { 'bagging' : self . bagging } ) df_tmp = pd . DataFrame . from_dict ( self . d_train_model [ key ] [ 'features_importance' ] , orient = 'index' ) . reset_index ( ) . rename ( columns = { 'index' : 'feat' , 0 : 'importance' } ) . sort_values ( by = 'importance' , ascending = False ) . head ( 5 ) serie_tmp = df_tmp [ 'feat' ] + ' ' + round ( df_tmp [ 'importance' ] , 5 ) . astype ( str ) dict_tmp . update ( dict ( zip ( feat_imp_col , serie_tmp . tolist ( ) ) ) ) df_local = df_local . append ( dict_tmp , ignore_index = True ) return df_local . loc [ df_local [ 'delta_auc' ] <= 0.03 ] . sort_values ( by = sort_metric , ascending = False )
Store models summary in DataFrame
Parameters
Store models summary in DataFrame Parameters
"""Store models summary in DataFrame

        Parameters
        ----------
        d_model_info : dict
            {model_index : {'HP', 'probas', 'model', 'features_importance', 'train_metrics', 'metrics', 'output'}
        sort_metric : string (default = 'F1')
            metric to sort models (descendant)

        Returns
        -------
        DataFrame
            model infos and metrics
        """ # dataFrame columns names # store informations in df
self
d_model_infos
sort_metric