Commit 84dc1f6a authored by Pauline Pommeret's avatar Pauline Pommeret

Supervised learning (decision tree algoritm)

parent 00b3ded6
#!/usr/bin/env python2.7
import sklearn
import sklearn.preprocessing
import sklearn.tree
import lib.database
LCURSOR = lib.database.LearningPGCursor()
def generate_learner():
"""
Returns an averaged DecisionTree
"""
imp = sklearn.preprocessing.Imputer(missing_values=0.0, strategy="mean", verbose=0, copy=False, axis=1)
datas, answers, possible_answers = LCURSOR.fetch_averaged_sequence_data()
imp.fit(datas)
datas = imp.transform(datas)
dtree = sklearn.tree.DecisionTreeClassifier()
dtree.fit(datas, answers)
return dtree, possible_answers
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment