# Path: jubakit/wrapper/regression.py
# class LinearRegression(BaseJubatusRegression):
# 
#   def __init__(self, method='AROW', regularization_weight=1.0, sensitivity=1.0, learning_rate=1.0,
#                n_iter=1, shuffle=False, embedded=True, seed=None):
#     super(LinearRegression, self).__init__(n_iter, shuffle, embedded, seed)
#     self.method = method
#     self.regularization_weight = regularization_weight
#     self.sensitivity = sensitivity
#     self.learning_rate = learning_rate
# 
#   def _launch_regression(self):
#     if self.method in ('perceptron'):
#       self.config_ = Config(method=self.method,
#                             parameter={'learning_rate': self.learning_rate})
#     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 implemented yet.'.format(self.method))
#     self.regression_ = Regression.run(config=self.config_, embedded=self.embedded)
# 
#   def get_params(self, deep=True):
#     return {
#       'method': self.method,
#       'regularization_weight': self.regularization_weight,
#       'sensitivity': self.sensitivity,
#       'learning_rate': self.learning_rate,
#       'n_iter': self.n_iter,
#       'shuffle': self.shuffle,
#       'embedded': self.embedded,
#       'seed': self.seed
#     }
# 
# class NearestNeighborsRegression(BaseJubatusRegression):
# 
#   def __init__(self, method='euclid_lsh', nearest_neighbor_num=5,
#                hash_num=128, n_iter=1, shuffle=False, embedded=True, seed=None):
#     super(NearestNeighborsRegression, self).__init__(n_iter, shuffle, embedded, seed)
#     self.method = method
#     self.nearest_neighbor_num = nearest_neighbor_num
#     self.hash_num = hash_num
# 
#   def _launch_regression(self):
#     if self.method in ('euclid_lsh', 'lsh', 'minhash'):
#       self.config_ = Config(method='NN', parameter={'method': self.method,
#                                                     'nearest_neighbor_num': self.nearest_neighbor_num,
#                                                     'parameter': {'hash_num': self.hash_num}})
#     elif self.method in ('euclidean', 'cosine'):
#       self.config_ = Config(method=self.method,
#                             parameter={'nearest_neighbor_num': self.nearest_neighbor_num})
#     else:
#       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):
#     return {
#       'method': self.method,
#       'nearest_neighbor_num': self.nearest_neighbor_num,
#       'hash_num': self.hash_num,
#       'n_iter': self.n_iter,
#       'shuffle': self.shuffle,
#       'softmax': self.softmax,
#       'embedded': self.embedded,
#       'seed': self.seed
#     }


from unittest import TestCase
from jubakit.wrapper.regression import LinearRegression, NearestNeighborsRegression
from . import requireEmbedded
  import numpy as np
      'method': 'CW',
      'regularization_weight': 5.0,
      'sensitivity': 1.0,
      'learning_rate': 0.1,
      'n_iter': 5,
      'shuffle': True,
      'embedded': True,
      'seed': 42
    }
    regression = LinearRegression()
    regression.set_params(**params)
    self.assertEqual(regression.method, params['method'])
    self.assertEqual(regression.regularization_weight, params['regularization_weight'])
    self.assertEqual(regression.sensitivity, params['sensitivity'])
    self.assertEqual(regression.learning_rate, params['learning_rate'])
    self.assertEqual(regression.n_iter, params['n_iter'])
    self.assertEqual(regression.shuffle, params['shuffle'])
    self.assertEqual(regression.embedded, params['embedded'])
    self.assertEqual(regression.seed, params['seed'])

  @requireEmbedded
  def test_save(self):
    name = 'test'
    regression = LinearRegression()
    regression.save(name)


class NearestNeighborsRegressionTest(TestCase):

  def test_simple(self):

# Path: jubakit/wrapper/regression.py
# class LinearRegression(BaseJubatusRegression):
# 
#   def __init__(self, method='AROW', regularization_weight=1.0, sensitivity=1.0, learning_rate=1.0,
#                n_iter=1, shuffle=False, embedded=True, seed=None):
#     super(LinearRegression, self).__init__(n_iter, shuffle, embedded, seed)
#     self.method = method
#     self.regularization_weight = regularization_weight
#     self.sensitivity = sensitivity
#     self.learning_rate = learning_rate
# 
#   def _launch_regression(self):
#     if self.method in ('perceptron'):
#       self.config_ = Config(method=self.method,
#                             parameter={'learning_rate': self.learning_rate})
#     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 implemented yet.'.format(self.method))
#     self.regression_ = Regression.run(config=self.config_, embedded=self.embedded)
# 
#   def get_params(self, deep=True):
#     return {
#       'method': self.method,
#       'regularization_weight': self.regularization_weight,
#       'sensitivity': self.sensitivity,
#       'learning_rate': self.learning_rate,
#       'n_iter': self.n_iter,
#       'shuffle': self.shuffle,
#       'embedded': self.embedded,
#       'seed': self.seed
#     }
# 
# class NearestNeighborsRegression(BaseJubatusRegression):
# 
#   def __init__(self, method='euclid_lsh', nearest_neighbor_num=5,
#                hash_num=128, n_iter=1, shuffle=False, embedded=True, seed=None):
#     super(NearestNeighborsRegression, self).__init__(n_iter, shuffle, embedded, seed)
#     self.method = method
#     self.nearest_neighbor_num = nearest_neighbor_num
#     self.hash_num = hash_num
# 
#   def _launch_regression(self):
#     if self.method in ('euclid_lsh', 'lsh', 'minhash'):
#       self.config_ = Config(method='NN', parameter={'method': self.method,
#                                                     'nearest_neighbor_num': self.nearest_neighbor_num,
#                                                     'parameter': {'hash_num': self.hash_num}})
#     elif self.method in ('euclidean', 'cosine'):
#       self.config_ = Config(method=self.method,
#                             parameter={'nearest_neighbor_num': self.nearest_neighbor_num})
#     else:
#       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):
#     return {
#       'method': self.method,
#       'nearest_neighbor_num': self.nearest_neighbor_num,
#       'hash_num': self.hash_num,
#       'n_iter': self.n_iter,
#       'shuffle': self.shuffle,
#       'softmax': self.softmax,
#       'embedded': self.embedded,
#       'seed': self.seed
#     }


# Path: jubakit/test/wrapper/test_regression.py
from unittest import TestCase
from jubakit.wrapper.regression import LinearRegression, NearestNeighborsRegression
from . import requireEmbedded
  import numpy as np

      'method': 'CW',
      'regularization_weight': 5.0,
      'sensitivity': 1.0,
      'learning_rate': 0.1,
      'n_iter': 5,
      'shuffle': True,
      'embedded': True,
      'seed': 42
    }
    regression = LinearRegression()
    regression.set_params(**params)
    self.assertEqual(regression.method, params['method'])
    self.assertEqual(regression.regularization_weight, params['regularization_weight'])
    self.assertEqual(regression.sensitivity, params['sensitivity'])
    self.assertEqual(regression.learning_rate, params['learning_rate'])
    self.assertEqual(regression.n_iter, params['n_iter'])
    self.assertEqual(regression.shuffle, params['shuffle'])
    self.assertEqual(regression.embedded, params['embedded'])
    self.assertEqual(regression.seed, params['seed'])

  @requireEmbedded
  def test_save(self):
    name = 'test'
    regression = LinearRegression()
    regression.save(name)


class NearestNeighborsRegressionTest(TestCase):

  def test_simple(self):

    regression = NearestNeighborsRegression()