CMSC_828C_Project1/bayes.py
def predict(self, data):
        """
        this function predicts the class of an unknown feature vector
        :param data: feature vectors whose class has to be determined
        :return: class of the feature vector
        """
        samples, feature_length = data.shape
        k = len(self.gaussian)
        p = np.zeros((samples, k))

        for category, g in iteritems(self.gaussian):
            mean, covariance = g["mean"], g["cov"]
            p[:, category] = mvn.logpdf(data, mean=mean, cov=covariance) + np.log(
                self.priors[category]
            )

        return np.argmax(p, axis=1)

        this function predicts the class of an unknown feature vector
        :param data: feature vectors whose class has to be determined
        :return: class of the feature vector
        
this function predicts the class of an unknown feature vector
this function predicts the class of an unknown feature vector
def predict(self, data):
        samples, feature_length = data.shape
        k = len(self.gaussian)
        p = np.zeros((samples, k))
        for category, g in iteritems(self.gaussian):
            mean, covariance = g["mean"], g["cov"]
            p[:, category] = mvn.logpdf(data, mean=mean, cov=covariance) + np.log(
                self.priors[category]
            )
        return np.argmax(p, axis=1)
def predict ( self , data ) : samples , feature_length = data . shape k = len ( self . gaussian ) p = np . zeros ( ( samples , k ) ) for category , g in iteritems ( self . gaussian ) : mean , covariance = g [ "mean" ] , g [ "cov" ] p [ : , category ] = mvn . logpdf ( data , mean = mean , cov = covariance ) + np . log ( self . priors [ category ] ) return np . argmax ( p , axis = 1 )
this function predicts the class of an unknown feature vector
this function predicts the class of an unknown feature vector
"""
        this function predicts the class of an unknown feature vector
        :param data: feature vectors whose class has to be determined
        :return: class of the feature vector
        """
class of the feature vector
class of the feature vector
self
data
feature vectors whose class has to be determined
feature vectors whose class has to be determined