# 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
        pop_size = p * (self.mu + 1 + self.q)
        for _ in range(self.max_iter):
            # old_names = sorted(names[:])
            stall_iter += 1
            new_names = []
            new_data = []

            for i in range(3 * pop_size):
                f, new_name, parents = mutate(names, importance, self.toursize, self.operators, self.rng)
                if size(new_name) <= self.max_size and new_name not in new_names and new_name not in names:
                    with warnings.catch_warnings():
                        warnings.simplefilter("ignore")
                        feature = f(*[data[i] for i in parents])
                        if np.all(np.isfinite(feature)) and all(
                            abs(np.corrcoef(feature, data[i]))[1, 0] <= self.t for i in parents
                        ):
                            new_names.append(new_name)
                            new_data.append(feature)
                if len(new_names + names) < pop_size:
                    break
            else:
                warnings.warn(
                    "Failed to produce a new population given the tree-depth {} and correlation threshold {}.".format(
                        self.max_size, self.t
                    ),
                    ConvergenceWarning,
                )

            names.extend(new_names)
            data.extend(new_data)

# 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

        pop_size = p * (self.mu + 1 + self.q)
        for _ in range(self.max_iter):
            # old_names = sorted(names[:])
            stall_iter += 1
            new_names = []
            new_data = []

            for i in range(3 * pop_size):
                f, new_name, parents = mutate(names, importance, self.toursize, self.operators, self.rng)
                if size(new_name) <= self.max_size and new_name not in new_names and new_name not in names:
                    with warnings.catch_warnings():
                        warnings.simplefilter("ignore")
                        feature = f(*[data[i] for i in parents])
                        if np.all(np.isfinite(feature)) and all(
                            abs(np.corrcoef(feature, data[i]))[1, 0] <= self.t for i in parents
                        ):
                            new_names.append(new_name)
                            new_data.append(feature)
                if len(new_names + names) < pop_size:
                    break
            else:
                warnings.warn(
                    "Failed to produce a new population given the tree-depth {} and correlation threshold {}.".format(
                        self.max_size, self.t
                    ),
                    ConvergenceWarning,
                )

            names.extend(new_names)
            data.extend(new_data)

            models = net(Lasso, np.array(data).T, y, max_coarsity=self.max_coarsity).values()