# Path: bartpy/extensions/baseestimator.py
# class ResidualBART(SklearnModel):
# 
#     def __init__(self,
#                  base_estimator: RegressorMixin = None,
#                  **kwargs):
# 
#         if base_estimator is not None:
#             self.base_estimator = clone(base_estimator)
#         else:
#             base_estimator = LinearRegression()
#         self.base_estimator = base_estimator
#         super().__init__(**kwargs)
# 
#     def fit(self, X: np.ndarray, y: np.ndarray) -> 'ResidualBART':
#         self.base_estimator.fit(X, y)
#         SklearnModel.fit(self, X, y - self.base_estimator.predict(X))
#         return self
# 
#     def predict(self, X: np.ndarray=None) -> np.ndarray:
#         if X is None:
#             X = self.data.X
#         sm_prediction = self.base_estimator.predict(X)
#         bart_prediction = SklearnModel.predict(self, X)
#         return sm_prediction + bart_prediction


import pandas as pd
import numpy as np
    import warnings
from matplotlib import pyplot as plt
from sklearn.model_selection import train_test_split
from bartpy.extensions.baseestimator import ResidualBART



def run(size=100,
        alpha=0.95,
        beta=2.0,
        n_trees=50):


    warnings.simplefilter("error", UserWarning)
    x = np.linspace(0, 5, size)
    X = pd.DataFrame(x)
    y = np.random.normal(0, 0.1, size=size) + np.sin(x)


# Path: bartpy/extensions/baseestimator.py
# class ResidualBART(SklearnModel):
# 
#     def __init__(self,
#                  base_estimator: RegressorMixin = None,
#                  **kwargs):
# 
#         if base_estimator is not None:
#             self.base_estimator = clone(base_estimator)
#         else:
#             base_estimator = LinearRegression()
#         self.base_estimator = base_estimator
#         super().__init__(**kwargs)
# 
#     def fit(self, X: np.ndarray, y: np.ndarray) -> 'ResidualBART':
#         self.base_estimator.fit(X, y)
#         SklearnModel.fit(self, X, y - self.base_estimator.predict(X))
#         return self
# 
#     def predict(self, X: np.ndarray=None) -> np.ndarray:
#         if X is None:
#             X = self.data.X
#         sm_prediction = self.base_estimator.predict(X)
#         bart_prediction = SklearnModel.predict(self, X)
#         return sm_prediction + bart_prediction


# Path: examples/score/extensions/sin.py
import pandas as pd
import numpy as np
    import warnings
from matplotlib import pyplot as plt
from sklearn.model_selection import train_test_split
from bartpy.extensions.baseestimator import ResidualBART




def run(size=100,
        alpha=0.95,
        beta=2.0,
        n_trees=50):


    warnings.simplefilter("error", UserWarning)
    x = np.linspace(0, 5, size)
    X = pd.DataFrame(x)
    y = np.random.normal(0, 0.1, size=size) + np.sin(x)


    model = ResidualBART(