emat/model/core_model.py
def create_metamodel_from_data(
            self,
            experiment_inputs:pd.DataFrame,
            experiment_outputs:pd.DataFrame,
            output_transforms: dict = None,
            metamodel_id:int = None,
            include_measures = None,
            exclude_measures = None,
            db = None,
            random_state = None,
            experiment_stratification = None,
            suppress_converge_warnings = False,
            regressor = None,
    ):
        """
        Create a MetaModel from a set of input and output observations.

        Args:
            experiment_inputs (pandas.DataFrame): This dataframe
                should contain all of the experimental inputs, including
                values for each uncertainty, level, and constant.
            experiment_outputs (pandas.DataFrame): This dataframe
                should contain all of the experimental outputs, including
                a column for each performance measure. The index
                for the outputs should match the index for the
                `experiment_inputs`, so that the I-O matches row-by-row.
            output_transforms (dict): A mapping of performance measure
                transforms to use in meta-model estimation and application.
            metamodel_id (int, optional): An identifier for this meta-model.
                If not given, a unique id number will be created randomly.
            include_measures (Collection[str], optional): If provided, only
                output performance measures with names in this set will be included.
            exclude_measures (Collection[str], optional): If provided, only
                output performance measures with names not in this set will be included.
            db (Database, optional): The database to use for loading and saving metamodels.
                If none is given, the default database for this model is used.
                If there is no default db, and none is given here,
                the metamodel is not stored in a database.
            random_state (int, optional): A random state to use in the metamodel
                regression fitting.
            experiment_stratification (pandas.Series, optional):
                A stratification of experiments, used in cross-validation.
            suppress_converge_warnings (bool, default False):
                Suppress convergence warnings during metamodel fitting.
            regressor (Estimator, optional): A scikit-learn estimator implementing a
                multi-target regression.  If not given, a detrended simple Gaussian
                process regression is used.

        Returns:
            MetaModel:
                a callable object that, when called as if a
                function, accepts keyword arguments as inputs and
                returns a dictionary of (measure name: value) pairs.
        """
        from .core_python import PythonCoreModel
        from .meta_model import MetaModel

        db = db if db is not None else self.db

        experiment_inputs = self.ensure_dtypes(experiment_inputs)

        if metamodel_id is None:
            if db is not None:
                scope_name = self.scope.name
                metamodel_id = db.get_new_metamodel_id(scope_name)
            else:
                metamodel_id = np.random.randint(1,2**63,dtype='int64')

        if output_transforms is None:
            output_transforms = {}

        if include_measures is not None:
            experiment_outputs = experiment_outputs[[i for i in include_measures
                                                     if i in experiment_outputs.columns]]
            output_transforms = {i: output_transforms[i]
                                 for i in include_measures
                                 if i in output_transforms }
            
        if exclude_measures is not None:
            experiment_outputs = experiment_outputs.drop(exclude_measures, axis=1)
            for i in exclude_measures:
                del output_transforms[i]

        disabled_outputs = [i for i in self.scope.get_measure_names()
                            if i not in experiment_outputs.columns]

        func = MetaModel(
            experiment_inputs,
            experiment_outputs,
            output_transforms,
            disabled_outputs,
            random_state,
            experiment_stratification,
            suppress_converge_warnings=suppress_converge_warnings,
            regressor=regressor,
        )

        scope_ = self.scope.duplicate(strip_measure_transforms=True, 
                                      include_measures=include_measures,
                                      exclude_measures=exclude_measures)

        return PythonCoreModel(
            func,
            configuration = None,
            scope=scope_,
            safe=True,
            db = db,
            name=self.name+"Meta",
            metamodel_id=metamodel_id,
        )

        Create a MetaModel from a set of input and output observations.

        Args:
            experiment_inputs (pandas.DataFrame): This dataframe
                should contain all of the experimental inputs, including
                values for each uncertainty, level, and constant.
            experiment_outputs (pandas.DataFrame): This dataframe
                should contain all of the experimental outputs, including
                a column for each performance measure. The index
                for the outputs should match the index for the
                `experiment_inputs`, so that the I-O matches row-by-row.
            output_transforms (dict): A mapping of performance measure
                transforms to use in meta-model estimation and application.
            metamodel_id (int, optional): An identifier for this meta-model.
                If not given, a unique id number will be created randomly.
            include_measures (Collection[str], optional): If provided, only
                output performance measures with names in this set will be included.
            exclude_measures (Collection[str], optional): If provided, only
                output performance measures with names not in this set will be included.
            db (Database, optional): The database to use for loading and saving metamodels.
                If none is given, the default database for this model is used.
                If there is no default db, and none is given here,
                the metamodel is not stored in a database.
            random_state (int, optional): A random state to use in the metamodel
                regression fitting.
            experiment_stratification (pandas.Series, optional):
                A stratification of experiments, used in cross-validation.
            suppress_converge_warnings (bool, default False):
                Suppress convergence warnings during metamodel fitting.
            regressor (Estimator, optional): A scikit-learn estimator implementing a
                multi-target regression.  If not given, a detrended simple Gaussian
                process regression is used.

        Returns:
            MetaModel:
                a callable object that, when called as if a
                function, accepts keyword arguments as inputs and
                returns a dictionary of (measure name: value) pairs.
        
Create a MetaModel from a set of input and output observations.
Create a MetaModel from a set of input and output observations .
def create_metamodel_from_data(
            self,
            experiment_inputs:pd.DataFrame,
            experiment_outputs:pd.DataFrame,
            output_transforms: dict = None,
            metamodel_id:int = None,
            include_measures = None,
            exclude_measures = None,
            db = None,
            random_state = None,
            experiment_stratification = None,
            suppress_converge_warnings = False,
            regressor = None,
    ):
        from .core_python import PythonCoreModel
        from .meta_model import MetaModel
        db = db if db is not None else self.db
        experiment_inputs = self.ensure_dtypes(experiment_inputs)
        if metamodel_id is None:
            if db is not None:
                scope_name = self.scope.name
                metamodel_id = db.get_new_metamodel_id(scope_name)
            else:
                metamodel_id = np.random.randint(1,2**63,dtype='int64')
        if output_transforms is None:
            output_transforms = {}
        if include_measures is not None:
            experiment_outputs = experiment_outputs[[i for i in include_measures
                                                     if i in experiment_outputs.columns]]
            output_transforms = {i: output_transforms[i]
                                 for i in include_measures
                                 if i in output_transforms }
        if exclude_measures is not None:
            experiment_outputs = experiment_outputs.drop(exclude_measures, axis=1)
            for i in exclude_measures:
                del output_transforms[i]
        disabled_outputs = [i for i in self.scope.get_measure_names()
                            if i not in experiment_outputs.columns]
        func = MetaModel(
            experiment_inputs,
            experiment_outputs,
            output_transforms,
            disabled_outputs,
            random_state,
            experiment_stratification,
            suppress_converge_warnings=suppress_converge_warnings,
            regressor=regressor,
        )
        scope_ = self.scope.duplicate(strip_measure_transforms=True, 
                                      include_measures=include_measures,
                                      exclude_measures=exclude_measures)
        return PythonCoreModel(
            func,
            configuration = None,
            scope=scope_,
            safe=True,
            db = db,
            name=self.name+"Meta",
            metamodel_id=metamodel_id,
        )
def create_metamodel_from_data ( self , experiment_inputs : pd . DataFrame , experiment_outputs : pd . DataFrame , output_transforms : dict = None , metamodel_id : int = None , include_measures = None , exclude_measures = None , db = None , random_state = None , experiment_stratification = None , suppress_converge_warnings = False , regressor = None , ) : from . core_python import PythonCoreModel from . meta_model import MetaModel db = db if db is not None else self . db experiment_inputs = self . ensure_dtypes ( experiment_inputs ) if metamodel_id is None : if db is not None : scope_name = self . scope . name metamodel_id = db . get_new_metamodel_id ( scope_name ) else : metamodel_id = np . random . randint ( 1 , 2 ** 63 , dtype = 'int64' ) if output_transforms is None : output_transforms = { } if include_measures is not None : experiment_outputs = experiment_outputs [ [ i for i in include_measures if i in experiment_outputs . columns ] ] output_transforms = { i : output_transforms [ i ] for i in include_measures if i in output_transforms } if exclude_measures is not None : experiment_outputs = experiment_outputs . drop ( exclude_measures , axis = 1 ) for i in exclude_measures : del output_transforms [ i ] disabled_outputs = [ i for i in self . scope . get_measure_names ( ) if i not in experiment_outputs . columns ] func = MetaModel ( experiment_inputs , experiment_outputs , output_transforms , disabled_outputs , random_state , experiment_stratification , suppress_converge_warnings = suppress_converge_warnings , regressor = regressor , ) scope_ = self . scope . duplicate ( strip_measure_transforms = True , include_measures = include_measures , exclude_measures = exclude_measures ) return PythonCoreModel ( func , configuration = None , scope = scope_ , safe = True , db = db , name = self . name + "Meta" , metamodel_id = metamodel_id , )
Create a MetaModel from a set of input and output observations.
Create a MetaModel from a set of input and output observations .
"""
        Create a MetaModel from a set of input and output observations.

        Args:
            experiment_inputs (pandas.DataFrame): This dataframe
                should contain all of the experimental inputs, including
                values for each uncertainty, level, and constant.
            experiment_outputs (pandas.DataFrame): This dataframe
                should contain all of the experimental outputs, including
                a column for each performance measure. The index
                for the outputs should match the index for the
                `experiment_inputs`, so that the I-O matches row-by-row.
            output_transforms (dict): A mapping of performance measure
                transforms to use in meta-model estimation and application.
            metamodel_id (int, optional): An identifier for this meta-model.
                If not given, a unique id number will be created randomly.
            include_measures (Collection[str], optional): If provided, only
                output performance measures with names in this set will be included.
            exclude_measures (Collection[str], optional): If provided, only
                output performance measures with names not in this set will be included.
            db (Database, optional): The database to use for loading and saving metamodels.
                If none is given, the default database for this model is used.
                If there is no default db, and none is given here,
                the metamodel is not stored in a database.
            random_state (int, optional): A random state to use in the metamodel
                regression fitting.
            experiment_stratification (pandas.Series, optional):
                A stratification of experiments, used in cross-validation.
            suppress_converge_warnings (bool, default False):
                Suppress convergence warnings during metamodel fitting.
            regressor (Estimator, optional): A scikit-learn estimator implementing a
                multi-target regression.  If not given, a detrended simple Gaussian
                process regression is used.

        Returns:
            MetaModel:
                a callable object that, when called as if a
                function, accepts keyword arguments as inputs and
                returns a dictionary of (measure name: value) pairs.
        """
a callable object that, when called as if a
function, accepts keyword arguments as inputs and
returns a dictionary of (measure name: value) pairs.
a callable object that when called as if a function accepts keyword arguments as inputs and returns a dictionary of ( measure name : value ) pairs .
MetaModel
self
experiment_inputs
pd.DataFrame
This dataframe
should contain all of the experimental inputs, including
values for each uncertainty, level, and constant.
This dataframe should contain all of the experimental inputs including values for each uncertainty level and constant .
experiment_outputs
pd.DataFrame
This dataframe
should contain all of the experimental outputs, including
a column for each performance measure. The index
for the outputs should match the index for the
`experiment_inputs`, so that the I-O matches row-by-row.
This dataframe should contain all of the experimental outputs including a column for each performance measure . The index for the outputs should match the index for the ` experiment_inputs ` so that the I - O matches row - by - row .
output_transforms
dict
A mapping of performance measure
transforms to use in meta-model estimation and application.
A mapping of performance measure transforms to use in meta - model estimation and application .
metamodel_id
int
An identifier for this meta-model.
If not given, a unique id number will be created randomly.
An identifier for this meta - model . If not given a unique id number will be created randomly .
include_measures
If provided, only
output performance measures with names in this set will be included.
If provided only output performance measures with names in this set will be included .
exclude_measures
If provided, only
output performance measures with names not in this set will be included.
If provided only output performance measures with names not in this set will be included .
db
The database to use for loading and saving metamodels.
If none is given, the default database for this model is used.
If there is no default db, and none is given here,
the metamodel is not stored in a database.
The database to use for loading and saving metamodels . If none is given the default database for this model is used . If there is no default db and none is given here the metamodel is not stored in a database .
random_state
A random state to use in the metamodel
regression fitting.
A random state to use in the metamodel regression fitting .
experiment_stratification
A stratification of experiments, used in cross-validation.
A stratification of experiments used in cross - validation .
suppress_converge_warnings
Suppress convergence warnings during metamodel fitting.
Suppress convergence warnings during metamodel fitting .
regressor
A scikit-learn estimator implementing a
multi-target regression.  If not given, a detrended simple Gaussian
process regression is used.
A scikit - learn estimator implementing a multi - target regression . If not given a detrended simple Gaussian process regression is used .