Skip to content

Commit

Permalink
fix some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
shiodat committed Apr 17, 2017
1 parent 722a772 commit 9c3f45d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
8 changes: 6 additions & 2 deletions example/regression_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
from __future__ import absolute_import, division, print_function, unicode_literals

"""
Using Regression and Boston dataset
Using Regression and CSV file
==================================================
In this example we show regression using Boston dataset.
This is a simple example that illustrates:
* How to load CSV files and convert int into Jubakit dataset.
* Training the regression using the dataset.
* Getting regression result.
"""

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion example/regression_sklearn_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from sklearn.pipeline import Pipeline
from sklearn.utils import shuffle

# load hand-writtern number recognition dataset
# load boston housing values dataset
boston = load_boston()
# shuffle and separate the dataset
X, y = shuffle(boston.data, boston.target, random_state=42)
Expand Down
4 changes: 2 additions & 2 deletions jubakit/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def _default_parameter(cls, method):
return {'learning_rate': 1.0}
elif method in ('PA', 'passive_aggressive'):
return {'sensitivity': 1.0}
elif method in ('PA1', 'passive_aggressive1',
'PA2', 'passive_aggressive2',
elif method in ('PA1', 'passive_aggressive_1',
'PA2', 'passive_aggressive_2',
'CW', 'confidence_weighted',
'AROW',
'NHERD', 'normal_herd'):
Expand Down
34 changes: 17 additions & 17 deletions jubakit/wrapper/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BaseJubatusClassifier(BaseEstimator, ClassifierMixin):
"""
scikit-learn Wrapper for Jubatus Classifiers.
"""

def __init__(self, n_iter=1, shuffle=False, softmax=False, embedded=True, seed=None):
"""
Creates a base class for Jubatus Classifiers.
Expand All @@ -24,8 +24,8 @@ def __init__(self, n_iter=1, shuffle=False, softmax=False, embedded=True, seed=N

@classmethod
def _launch_classifier(self):
"""
Launch Jubatus Classifier
"""
Launch Jubatus Classifier
"""
raise NotImplementedError()

Expand Down Expand Up @@ -81,11 +81,11 @@ def decision_function(self, X):

@classmethod
def get_params(self, deep=True):
"""
Return parameters.
"""
Return parameters.
"""
raise NotImplementedError()

def set_params(self, **params):
"""
Set parameters
Expand All @@ -95,7 +95,7 @@ def set_params(self, **params):
return self

def save(self, name):
"""
"""
Save the classifier model using name.
"""
if self.classifier_ is not None:
Expand All @@ -111,22 +111,22 @@ def stop(self):


class LinearClassifier(BaseJubatusClassifier):
def __init__(self, method='AROW', regularization_weight=1.0,

def __init__(self, method='AROW', regularization_weight=1.0,
softmax=False, n_iter=1, shuffle=False, embedded=True, seed=None):
super(LinearClassifier, self).__init__(n_iter, shuffle, softmax, embedded, seed)
self.method = method
self.regularization_weight = regularization_weight

def _launch_classifier(self):
if self.method in ('perceptron', 'PA'):
self.config_ = Config(method=self.method)
elif self.method in ('PA1', 'PA2', 'CW', 'AROW', 'NHERD'):
self.config_ = Config(method=self.method,
self.config_ = Config(method=self.method,
parameter={'regularization_weight': self.regularization_weight})
else:
raise NotImplementedError('method {} is not implememented yet.'.format(self.method))
self.classifier_ = Classifier.run(config=self.config_, embedded=self.embedded)
raise NotImplementedError('method {} is not implemented yet.'.format(self.method))
self.classifier_ = Classifier.run(config=self.config_, embedded=self.embedded)

def get_params(self, deep=True):
return {
Expand All @@ -141,7 +141,7 @@ def get_params(self, deep=True):


class NearestNeighborsClassifier(BaseJubatusClassifier):

def __init__(self, method='euclid_lsh', nearest_neighbor_num=5, local_sensitivity=1.0,
hash_num=128, n_iter=1, shuffle=False, softmax=False, embedded=True, seed=None):
super(NearestNeighborsClassifier, self).__init__(n_iter, shuffle, softmax, embedded, seed)
Expand All @@ -157,12 +157,12 @@ def _launch_classifier(self):
'local_sensitivity': self.local_sensitivity,
'parameter': {'hash_num': self.hash_num}})
elif self.method in ('euclidean', 'cosine'):
self.config_ = Config(method=self.method,
self.config_ = Config(method=self.method,
parameter={'nearest_neighbor_num': self.nearest_neighbor_num,
'local_sensitivity': self.local_sensitivity})
else:
raise NotImplementedError('method {} is not implememented yet.'.format(self.method))
self.classifier_ = Classifier.run(config=self.config_, embedded=self.embedded)
raise NotImplementedError('method {} is not implemented yet.'.format(self.method))
self.classifier_ = Classifier.run(config=self.config_, embedded=self.embedded)

def get_params(self, deep=True):
return {
Expand Down
6 changes: 3 additions & 3 deletions jubakit/wrapper/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ def _launch_regression(self):
if self.method in ('perceptron'):
self.config_ = Config(method=self.method,
parameter={'learning_rate': self.learning_rate})
if self.method in ('PA'):
elif self.method in ('PA'):
self.config_ = Config(method=self.method,
parameter={'sensitivity': self.sensitivity})
elif self.method in ('PA1', 'PA2', 'CW', 'AROW', 'NHERD'):
self.config_ = Config(method=self.method,
parameter={'regularization_weight': self.regularization_weight,
'sensitivity': self.sensitivity})
else:
raise NotImplementedError('method {} is not implememented yet.'.format(self.method))
raise NotImplementedError('method {} is not implemented yet.'.format(self.method))
self.regression_ = Regression.run(config=self.config_, embedded=self.embedded)

def get_params(self, deep=True):
Expand Down Expand Up @@ -158,7 +158,7 @@ def _launch_regression(self):
self.config_ = Config(method=self.method,
parameter={'nearest_neighbor_num': self.nearest_neighbor_num})
else:
raise NotImplementedError('method {} is not implememented yet.'.format(self.method))
raise NotImplementedError('method {} is not implemented yet.'.format(self.method))
self.regression_ = Regression.run(config=self.config_, embedded=self.embedded)

def get_params(self, deep=True):
Expand Down

0 comments on commit 9c3f45d

Please sign in to comment.