af0d98898e2be517096c18335ab10b43b9fd461e,mlxtend/classifier/perceptron.py,Perceptron,fit,#Perceptron#Any#Any#Any#,35
Before Change
if not len(X.shape) == 2:
raise ValueError("X must be a 2D array. Try X[:,np.newaxis]")
if not (np.unique(y) == np.array([-1, 1])).all():
raise ValueError("Supports only binary class labels -1 and 1")
if not isinstance(init_weights, np.ndarray):
self.w_ = np.random.random(1 + X.shape[1])
else:
self.w_ = init_weights
After Change
// check if {0, 1} or {-1, 1} class labels are used
self.classes_ = np.unique(y)
if not len(self.classes_) == 2 \
or not self.classes_[0] in (-1, 0) \
or not self.classes_[1] == 1:
raise ValueError("Only supports binary class labels {0, 1} or {-1, 1}.")
if self.classes_[0] == -1:
self.thres_ = 0
else:
self.thres_ = 0.5
// initialize weights
if not isinstance(init_weights, np.ndarray):
self.w_ = np.random.random(1 + X.shape[1])
else:
self.w_ = init_weights
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 12
Instances
Project Name: rasbt/mlxtend
Commit Name: af0d98898e2be517096c18335ab10b43b9fd461e
Time: 2015-03-17
Author: se.raschka@me.com
File Name: mlxtend/classifier/perceptron.py
Class Name: Perceptron
Method Name: fit
Project Name: rasbt/mlxtend
Commit Name: af0d98898e2be517096c18335ab10b43b9fd461e
Time: 2015-03-17
Author: se.raschka@me.com
File Name: mlxtend/classifier/perceptron.py
Class Name: Perceptron
Method Name: fit
Project Name: rasbt/mlxtend
Commit Name: af0d98898e2be517096c18335ab10b43b9fd461e
Time: 2015-03-17
Author: se.raschka@me.com
File Name: mlxtend/classifier/adaline.py
Class Name: Adaline
Method Name: fit
Project Name: pysb/pysb
Commit Name: eab2da81c65974e08b8245bbf8a052093f972df3
Time: 2009-08-09
Author: jmuhlich@bitflood.org
File Name: Pysb.py
Class Name: Rule
Method Name: __init__