# 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 jubakit.wrapper.regression import LinearRegression, NearestNeighborsRegression
from sklearn.datasets import load_boston
from sklearn.decomposition import PCA
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error
from sklearn.pipeline import Pipeline
from sklearn.utils import shuffle
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals

"""
Pipeline Classification with scikit-learn wrapped Regression
============================================================

In this example, we show how to use scikit-learn wrapper's
`fit(X, y)` and `predict(X)` functions.

"""



# load boston housing values dataset
boston = load_boston()
# shuffle and separate the dataset
X, y = shuffle(boston.data, boston.target, random_state=42)
n_train = int(X.shape[0] / 2)
X_train, y_train = X[:n_train], y[:n_train]
X_test, y_test = X[n_train:], y[n_train:]

# launch linear regression (AROW)

# 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: example/regression_sklearn_wrapper.py
from jubakit.wrapper.regression import LinearRegression, NearestNeighborsRegression
from sklearn.datasets import load_boston
from sklearn.decomposition import PCA
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error
from sklearn.pipeline import Pipeline
from sklearn.utils import shuffle

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals

"""
Pipeline Classification with scikit-learn wrapped Regression
============================================================

In this example, we show how to use scikit-learn wrapper's
`fit(X, y)` and `predict(X)` functions.

"""



# load boston housing values dataset
boston = load_boston()
# shuffle and separate the dataset
X, y = shuffle(boston.data, boston.target, random_state=42)
n_train = int(X.shape[0] / 2)
X_train, y_train = X[:n_train], y[:n_train]
X_test, y_test = X[n_train:], y[n_train:]

# launch linear regression (AROW)

clf = LinearRegression(n_iter=5, method='AROW', embedded=False, seed=42)