def accuracy ( self ) : sub_observed = np . array ( [ self . observed . metadata [ i ] for i in self . observed . arr ] ) return float ( ( self . model_predictions ( ) == sub_observed ) . sum ( ) ) / self . data_size
decision tree for the data with all the categorical data in python
Calculates the accuracy of the tree by comparing the model predictions to the dataset ( TP + TN ) / ( TP + TN + FP + FN ) == ( T / ( T + F ))
def accuracy(self):
        """
        Calculates the accuracy of the tree by comparing
        the model predictions to the dataset
        (TP + TN) / (TP + TN + FP + FN) == (T / (T + F))
        """
        sub_observed = np.array([self.observed.metadata[i] for i in self.observed.arr])
        return float((self.model_predictions() == sub_observed).sum()) / self.data_size