         return (left, right)
     }
     
-    static func probability(datum: Datum, _ data: [Datum]) -> Double {
+    static func probability(classification: String, _ data: [Datum]) -> Double {
         var count = 0
-        for curData in data {
-            if curData.classification == datum.classification { count++ }
+        for datum in data {
+            if datum.classification == classification { count++ }
         }
         return Double(count) / Double(data.count)
     }
     
     static func entropy(data: [Datum]) -> Double {
-        let uniqueData = unique(data)
+        let classifications = uniqueClassifications(data)
         var sum = 0.0
-        for datum in uniqueData {
-            let p = probability(datum, data)
+        for classification in classifications {
+            let p = probability(classification, data)
             sum += -p * log2(p)
         }
         return sum

        return data.filter { seen.updateValue(true, forKey: $0) == nil }
    }
    
    static func unique(data: [Datum]) -> [Datum] {
        var seen = [String: Bool]()
        return data.filter { seen.updateValue(true, forKey: $0.classification) == nil }
    }
    
    static func uniqueFeatures(data: [Datum], featureIndex: Int) -> [Feature] {
        let features = data.map { $0.features[featureIndex] }
        return unique(features)
    }
    
    static func split(data: [Datum], featureIndex: Int, cut: Feature) -> ([Datum], [Datum]) {

    if lhs.isNumeric != rhs.isNumeric { return false }
    return lhs.isNumeric ? lhs.number == rhs.number : lhs.category == rhs.category
}
