-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] train with other accounts and account to be tested
- Loading branch information
1 parent
51eec9e
commit 3907980
Showing
5 changed files
with
30 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
from .decision_tree import train_classifier as train_decision_tree | ||
|
||
from .perceptron import train_classifier as train_perceptron | ||
|
||
type_classifier_mapping = { | ||
'decision_tree': train_decision_tree | ||
'decision_tree': train_decision_tree, | ||
'perceptron': train_perceptron | ||
} | ||
|
||
|
||
def train_classifier(samples, labels, classifier_type): | ||
def train_classifier(samples, labels, classifier_type, **kwargs): | ||
if len(samples) != len(labels): | ||
raise ValueError('Number of samples has to equal number of labels!') | ||
if classifier_type not in type_classifier_mapping: | ||
raise ValueError('Invalid classifier_type!') | ||
|
||
training_callable = type_classifier_mapping[classifier_type] | ||
return training_callable(samples, labels) | ||
return training_callable(samples, labels, **kwargs) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from sklearn import linear_model | ||
from sklearn import tree | ||
|
||
|
||
def train_classifier(samples, labels): | ||
classifier = linear_model.Perceptron() | ||
classifier = classifier.partial_fit(samples, labels, classes=labels) | ||
classifier = tree.DecisionTreeClassifier() | ||
classifier = classifier.fit(samples, labels) | ||
|
||
return classifier |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from sklearn import linear_model | ||
|
||
def train_classifier(samples, labels, classifier = None): | ||
classifier = classifier or linear_model.Perceptron() | ||
classifier = classifier.partial_fit(samples, labels, classes=labels) | ||
|
||
return classifier |