CMSC_828C_Project1/bayes.py
def fit(self, data, y):
        """
        calculates associated mean and covariance of each class in the data-set
        :param data: data
        :param y : data labels
        :return: None
        """
        smoothing_factor = 1e-2
        samples, feature_length = data.shape

        labels = set(y)
        for category in labels:
            current_data = data[y == category]
            self.gaussian[category] = {
                "mean": current_data.mean(axis=0),
                "cov": np.cov(current_data.T)
                + np.eye(feature_length) * smoothing_factor,
            }
            self.priors[category] = float(len(y[y == category])) / len(y)
        return 0

        calculates associated mean and covariance of each class in the data-set
        :param data: data
        :param y : data labels
        :return: None
        
calculates associated mean and covariance of each class in the data-set
calculates associated mean and covariance of each class in the data - set
def fit(self, data, y):
        smoothing_factor = 1e-2
        samples, feature_length = data.shape
        labels = set(y)
        for category in labels:
            current_data = data[y == category]
            self.gaussian[category] = {
                "mean": current_data.mean(axis=0),
                "cov": np.cov(current_data.T)
                + np.eye(feature_length) * smoothing_factor,
            }
            self.priors[category] = float(len(y[y == category])) / len(y)
        return 0
def fit ( self , data , y ) : smoothing_factor = 1e-2 samples , feature_length = data . shape labels = set ( y ) for category in labels : current_data = data [ y == category ] self . gaussian [ category ] = { "mean" : current_data . mean ( axis = 0 ) , "cov" : np . cov ( current_data . T ) + np . eye ( feature_length ) * smoothing_factor , } self . priors [ category ] = float ( len ( y [ y == category ] ) ) / len ( y ) return 0
calculates associated mean and covariance of each class in the data-set
calculates associated mean and covariance of each class in the data - set
"""
        calculates associated mean and covariance of each class in the data-set
        :param data: data
        :param y : data labels
        :return: None
        """
None
self
data
None
y
None