# Path: palladium/interfaces.py
# class DatasetLoader(metaclass=DatasetLoaderMeta):
#     """A :class:`~palladium.interfaces.DatasetLoader` is responsible for
#     loading datasets for use in training and evaluation.
#     """
# 
#     @abstractmethod
#     def __call__(self):
#         """Loads the data and returns a tuple *(data, target)*, or
#         *(X, y)*.
# 
#         :return:
#           A tuple *(data, target*).
# 
#           *data* is a two dimensional numpy array with shape n x m
#           (one row per example).
# 
#           *target* is a one dimensional array with n target values.
# 
#           *target* may be ``None`` if there is no target value,
#           e.g. in an unsupervised learning setting.
# 
#         :rtype: tuple
#         """
# 
# Path: palladium/interfaces.py
# class Model(BaseEstimator, metaclass=ABCMeta):
#     """A :class:`Model` can be :meth:`~Model.fit` to data and can be
#     used to :meth:`~Model.predict` data.
# 
#     :class:`Model` corresponds to the *estimators* interface of
#     scikit-learn.
#     """
# 
#     @abstractmethod
#     def fit(self, X, y=None):
#         """Fit to data array *X* and possibly a target array *y*.
# 
#         :return: self
#         """
# 
#     @abstractmethod
#     def predict(self, X, **kw):
#         """Predict classes for data array *X* with shape n x m.
# 
#         Some models may accept additional keyword arguments.
# 
#         :return:
#           A numpy array of length n with the predicted classes (for
#           classification problems) or numeric values (for regression
#           problems).
# 
#         :raises:
#           May raise a :class:`PredictError` to indicate that some
#           condition made it impossible to deliver a prediction.
#         """
# 
#     def predict_proba(self, X, **kw):
#         """Predict probabilities for data array *X* with shape n x m.
# 
#         :return:
#           A numpy array of length n x c with a list class
#           probabilities per sample.
# 
#         :raises:
#           :class:`NotImplementedError` if not applicable.
#         """
#         raise NotImplementedError()  # pragma: no cover


from palladium.interfaces import DatasetLoader
from palladium.interfaces import Model
from pandas import Categorical
from pandas import DataFrame
from pandas import Series
from rpy2 import robjects
from rpy2.robjects import pandas2ri
from rpy2.robjects.pandas2ri import py2ri
from rpy2.robjects.numpy2ri import numpy2ri
from sklearn.base import TransformerMixin
from sklearn.metrics import accuracy_score
from sklearn.metrics import r2_score
from sklearn.preprocessing import LabelEncoder
import numpy as np
"""Support for building models using the R programming language.
"""



pandas2ri.activate()


class ObjectMixin:
    r = robjects.r

    def __init__(self, scriptname, funcname, **kwargs):
        self.scriptname = scriptname
        self.funcname = funcname
        self.r.source(scriptname)
        self.rfunc = self.r[funcname]
        self.kwargs = kwargs



# Path: palladium/interfaces.py
# class DatasetLoader(metaclass=DatasetLoaderMeta):
#     """A :class:`~palladium.interfaces.DatasetLoader` is responsible for
#     loading datasets for use in training and evaluation.
#     """
# 
#     @abstractmethod
#     def __call__(self):
#         """Loads the data and returns a tuple *(data, target)*, or
#         *(X, y)*.
# 
#         :return:
#           A tuple *(data, target*).
# 
#           *data* is a two dimensional numpy array with shape n x m
#           (one row per example).
# 
#           *target* is a one dimensional array with n target values.
# 
#           *target* may be ``None`` if there is no target value,
#           e.g. in an unsupervised learning setting.
# 
#         :rtype: tuple
#         """
# 
# Path: palladium/interfaces.py
# class Model(BaseEstimator, metaclass=ABCMeta):
#     """A :class:`Model` can be :meth:`~Model.fit` to data and can be
#     used to :meth:`~Model.predict` data.
# 
#     :class:`Model` corresponds to the *estimators* interface of
#     scikit-learn.
#     """
# 
#     @abstractmethod
#     def fit(self, X, y=None):
#         """Fit to data array *X* and possibly a target array *y*.
# 
#         :return: self
#         """
# 
#     @abstractmethod
#     def predict(self, X, **kw):
#         """Predict classes for data array *X* with shape n x m.
# 
#         Some models may accept additional keyword arguments.
# 
#         :return:
#           A numpy array of length n with the predicted classes (for
#           classification problems) or numeric values (for regression
#           problems).
# 
#         :raises:
#           May raise a :class:`PredictError` to indicate that some
#           condition made it impossible to deliver a prediction.
#         """
# 
#     def predict_proba(self, X, **kw):
#         """Predict probabilities for data array *X* with shape n x m.
# 
#         :return:
#           A numpy array of length n x c with a list class
#           probabilities per sample.
# 
#         :raises:
#           :class:`NotImplementedError` if not applicable.
#         """
#         raise NotImplementedError()  # pragma: no cover


# Path: palladium/R.py
from palladium.interfaces import DatasetLoader
from palladium.interfaces import Model
from pandas import Categorical
from pandas import DataFrame
from pandas import Series
from rpy2 import robjects
from rpy2.robjects import pandas2ri
from rpy2.robjects.pandas2ri import py2ri
from rpy2.robjects.numpy2ri import numpy2ri
from sklearn.base import TransformerMixin
from sklearn.metrics import accuracy_score
from sklearn.metrics import r2_score
from sklearn.preprocessing import LabelEncoder
import numpy as np

"""Support for building models using the R programming language.
"""



pandas2ri.activate()


class ObjectMixin:
    r = robjects.r

    def __init__(self, scriptname, funcname, **kwargs):
        self.scriptname = scriptname
        self.funcname = funcname
        self.r.source(scriptname)
        self.rfunc = self.r[funcname]
        self.kwargs = kwargs



class DatasetLoader(DatasetLoader, ObjectMixin):