# Path: sparsereg/util/net.py
# def net(estimator, x, y, attr="alpha", max_coarsity=2, filter=True, r_max=1e3, **kw):
#     with warnings.catch_warnings():
#         warnings.simplefilter("ignore", UserWarning)
#         return _net(estimator, x, y, attr=attr, max_coarsity=max_coarsity, filter=filter, r_max=r_max, **kw)


import random
import re
import warnings
import numpy as np
from sklearn.base import BaseEstimator
from sklearn.base import RegressorMixin
from sklearn.base import TransformerMixin
from sklearn.exceptions import ConvergenceWarning
from sklearn.linear_model import Lasso
from sklearn.linear_model import LassoLarsCV
from sklearn.pipeline import Pipeline
from sparsereg.util.net import net

class LibTrafo(BaseEstimator, TransformerMixin):
    def __init__(self, names, operators):
        self.names = names[:]
        self.operators = operators

    def fit(self, x, y=None):
        return self

    def transform(self, x, y=None):
        return _transform(x, self.names, self.operators)


def _fit_model(x, y, names, operators, **kw):
    steps = [("trafo", LibTrafo(names, operators)), ("lasso", LassoLarsCV(**kw))]
    model = Pipeline(steps).fit(x, y)
    return model, model.score(x, y)


class EFS(BaseEstimator, RegressorMixin, TransformerMixin):
    def __init__(
        self,
        q=1,
        mu=1,
        max_size=5,
        t=0.95,
        toursize=5,
        max_stall_iter=20,
        max_iter=2000,
        random_state=None,

# Path: sparsereg/util/net.py
# def net(estimator, x, y, attr="alpha", max_coarsity=2, filter=True, r_max=1e3, **kw):
#     with warnings.catch_warnings():
#         warnings.simplefilter("ignore", UserWarning)
#         return _net(estimator, x, y, attr=attr, max_coarsity=max_coarsity, filter=filter, r_max=r_max, **kw)


# Path: sparsereg/model/efs.py
import random
import re
import warnings
import numpy as np
from sklearn.base import BaseEstimator
from sklearn.base import RegressorMixin
from sklearn.base import TransformerMixin
from sklearn.exceptions import ConvergenceWarning
from sklearn.linear_model import Lasso
from sklearn.linear_model import LassoLarsCV
from sklearn.pipeline import Pipeline
from sparsereg.util.net import net


class LibTrafo(BaseEstimator, TransformerMixin):
    def __init__(self, names, operators):
        self.names = names[:]
        self.operators = operators

    def fit(self, x, y=None):
        return self

    def transform(self, x, y=None):
        return _transform(x, self.names, self.operators)


def _fit_model(x, y, names, operators, **kw):
    steps = [("trafo", LibTrafo(names, operators)), ("lasso", LassoLarsCV(**kw))]
    model = Pipeline(steps).fit(x, y)
    return model, model.score(x, y)


class EFS(BaseEstimator, RegressorMixin, TransformerMixin):
    def __init__(
        self,
        q=1,
        mu=1,
        max_size=5,
        t=0.95,
        toursize=5,
        max_stall_iter=20,
        max_iter=2000,
        random_state=None,

        operators=operators,