public int Classify(DataRow row) { if (IsLeaf) { return Classification; } foreach(var kvp in _children) { if(kvp.Value(row)) { return kvp.Key.Classify(row); } } return 0; }
private double ProbabiltyOfClassification(DataRow row, int classification) { double chanceOfClassification = GetProbabilityOfClassification(classification); List<BayesContainer> probability = _probabilities[classification]; foreach(var attr in _attributes) { // evil extra loop... whatever. I don't care about speed here foreach(var container in probability) { if (container.Attribute == attr) chanceOfClassification *= container.Probability; } } return chanceOfClassification; }
private double GetWeightedSum(DataRow row) { double weightedSum = 0; for (int x = 0; x < _edges.Count; x++) { Edge currentEdge = _edges[x]; weightedSum += currentEdge.Weight * row.RetrieveValueAsInt(currentEdge.Attribute); } // now that we have the weighted sum, lets sigmoid it return weightedSum; }