This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Author: Krishnamurthy Koduvayur Viswanathan | |
| from __future__ import division | |
| import collections | |
| import math | |
| class Model: | |
| def __init__(self, arffFile): | |
| self.trainingFile = arffFile | |
| self.features = {} #all feature names and their possible values (including the class label) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void do_cal(char str[],int n,int p); | |
| int main() | |
| { | |
| char str[6]; | |
| int n,i,t,r[125]; | |
| while(scanf("%s%d",str,&n)==2) | |
| { | |
| for(i=0;str[i]!='.';i++); | |
| t=(5-i)*n; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def Classify(self, featureVector): #featureVector is a simple list like the ones that we use to train | |
| probabilityPerLabel = {} #store the final probability for each class label | |
| for label in self.labelCounts: | |
| logProb = 0 | |
| for featureValue in featureVector: | |
| logProb += math.log(self.featureCounts[(label, self.featureNameList[featureVector.index(featureValue)], featureValue)]/self.labelCounts[label]) | |
| probabilityPerLabel[label] = (self.labelCounts[label]/sum(self.labelCounts.values())) * math.exp(logProb) | |
| print probabilityPerLabel | |
| return max(probabilityPerLabel, key = lambda classLabel: probabilityPerLabel[classLabel]) |