#NEWLINE# def train_self( self ) : #NEWLINE# #INDENT# '\n        Train the model on the data set in the model\n        :return:\n        ' #NEWLINE# for col in self . num_cols : #NEWLINE# #INDENT# self . prob_hub [ col ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for claz in self . class_list : #NEWLINE# #INDENT# ( mean , std ) = get_mean_std ( self . data [ ( self . data [ self . class_column ] == claz ) ] [ col ] ) #NEWLINE# self . prob_hub [ col ] [ claz ] = ( mean , std ) #NEWLINE# #UNINDENT# #UNINDENT# for col in self . cat_cols : #NEWLINE# #INDENT# ulist = unique_list ( self . data [ col ] ) #NEWLINE# self . prob_hub [ col ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# stat = ( self . data . groupby ( self . class_column ) [ col ] . value_counts ( ) / self . data . groupby ( self . class_column ) [ col ] . count ( ) ) #NEWLINE# for claz in self . class_list : #NEWLINE# #INDENT# self . prob_hub [ col ] [ claz ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for uni_element in ulist : #NEWLINE# #INDENT# self . prob_hub [ col ] [ claz ] [ uni_element ] = stat [ claz ] [ uni_element ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . predict ( self . data , True )