let learn examples =
(* sort examples according to the categories *)
let sorted = Types.sort_by_cat examples in
(* count the occurence of each category
an the distribution of the attributes in each category *)
let rec loop categories akku =
match categories with
(cat,data) :: rest ->
(* get all the attribute counts in a category *)
let counted = Types.count data in
(* turn the counts into probapbilities *)
let probs = divide counted (List.length data) in
let result = {kn_category = cat; kn_count = List.length data; kn_data = probs} in
loop rest (result :: akku)
| [] -> akku
in
loop sorted []