コード例 #1
0
def get_best_parameterization(config_fn,data_fn,metric_name='d_metric',o_config=None,o_data=None):
    _analyzer = PyposmatDataAnalyzer()
    _analyzer.read_configuration_file(filename=config_fn)
    _analyzer.read_data_file(filename=data_fn)

    # calculate the scoring metric
    if metric_name is 'd_metric':
        _df = _analyzer.calculate_d_metric(df=_analyzer.datafile.df)
    else:
        s = "The metric name {} is unsupported"
        s = s.format(metric_name)
        raise PyposmatUnsupportedPotentialScoringMetric(s)

    _data = PyposmatDataFile()
    _data.read(filename=data_fn)
    _data.df = _df
    _data.subselect_by_score(score_name='d_metric',n=1)

    _free_parameter_names = _analyzer.configuration.free_parameter_names
    
    _parameter_best_dict = OrderedDict()
    for pn in _free_parameter_names:
        _parameter_best_dict[pn] = _data.sub_parameter_df.iloc[0][pn]

    return _parameter_best_dict
コード例 #2
0
def test__read_configuration_file__validpath():
    rscs=testing_resources()
    fn_config=rscs['fn_config']

    pda=PyposmatDataAnalyzer()
    pda.read_configuration_file(filename=fn_config)

    assert type(pda.configuration) is PyposmatConfigurationfile
コード例 #3
0
    def analyze_results(self, i_iteration):
        data_fn = os.path.join(\
                self.root_directory,
                self.data_directory,
                'pyposmat.results.{}.out'.format(i_iteration))
        config_fn = os.path.join(\
                self.root_directory,
                self.configuration_filename)
        kde_fn = os.path.join(\
                self.root_directory,
                self.data_directory,
                'pyposmat.kde.{}.out'.format(i_iteration+1))

        data_analyzer = PyposmatDataAnalyzer()
        data_analyzer.read_configuration_file(filename=config_fn)
        data_analyzer.read_data_file(filename=data_fn)
        data_analyzer.write_kde_file(filename=kde_fn)
コード例 #4
0
def get_parameter_variance(
        config_fn,data_fn,
        metric_name='d_metric',
        n=100,
        o_config=None,
        o_data=None):
    """
    Args:
        config_fn (str):
        data_fn (str):
        metric_name (str):  (default:d_metric)
        n (int): the number of best metric values
        o_config (pypospack.config.data.PyposmatConfigurationFile)
        o_data (pypospack.config.data.PyposmatDataFile)
    Returns:
        collections.OrderedDict
    Raises:
        PyposmatUnknownPotentialScoringMetric
    """

    _analyzer = PyposmatDataAnalyzer()
    _analyzer.read_configuration_file(filename=config_fn)
    _analyzer.read_data_file(filename=data_fn)
   
    # calculate the scoring metric
    if metric_name is 'd_metric':
        _df = _analyzer.calculate_d_metric(df=_analyzer.datafile.df)
    else:
        s = "The metric name {} is unsupported"
        s = s.format(metric_name)
        raise PyposmatUnsupportedPotentialScoringMetric(s)

    _data = PyposmatDataFile()
    _data.read(filename=data_fn)
    _data.df = _df
    _data.subselect_by_score(score_name='d_metric',n=n)

    _param_std_df = _data.sub_parameter_df.std(axis=0)
   
    _parameter_std_dict = OrderedDict()
    for pn in _analyzer.parameter_names:
        _parameter_std_dict[pn] =_param_std_df.to_dict()[pn]
    
    return _parameter_std_dict
コード例 #5
0
from pypospack.pyposmat.data import PyposmatDataFile, PyposmatDataAnalyzer

if __name__ == "__main__":
    import os
    import pypospack.utils
    _pypospack_root = pypospack.utils.get_pypospack_root_directory()
    _data_in_directory = os.path.join(
        _pypospack_root, 'examples',
        'Ni__eam__born_exp_fs__sensitivityanalysis',
        'data__from_pareto_optimization')
    _pyposmat_data_fn = os.path.join(_data_in_directory, 'pyposmat.kde.6.out')
    _pyposmat_config_fn = os.path.join(_data_in_directory,
                                       'pyposmat.config.in')

    analyzer = PyposmatDataAnalyzer()
    analyzer.read_configuration_file(filename=_pyposmat_config_fn)
    analyzer.read_data_file(filename=_pyposmat_data_fn)
    df = analyzer.calculate_d_metric(df=analyzer.datafile.df)

    data = PyposmatDataFile()
    data.read(filename=_pyposmat_data_fn)
    data.df = df
    data.subselect_by_score(score_name="d_metric", n=100)
    # print(data.sub_df)

    param_stdev_df = data.sub_parameter_df.std(axis=0)
    param_mean_df = data.sub_parameter_df.mean(axis=0)
    print("parameter standard deviations:\n{}".format(param_stdev_df))
    print("parameter means:\n{}".format(param_mean_df))

    data.subselect_by_score(score_name="d_metric", n=1)
コード例 #6
0
    configuration.qoi_constraints = config.qoi_constraints
    configuration.structures = config.structure_db
    configuration.potential = config.potential_formalism
    configuration.sampling_type = config.sampling
    configuration.sampling_distribution = config.parameter_distribution
    configuration.sampling_constraints = config.parameter_constraints
    #<------------- write configuration file
    configuration.write(filename=_configuration_filename)
    #--------------------------------------------------------------------------
    # TEST CONFIGURATION FILE
    #--------------------------------------------------------------------------
    configuration.read(filename=_configuration_filename)

    #--------------------------------------------------------------------------
    # ANALYZE DATA
    #--------------------------------------------------------------------------
    data_directory = 'data'
    pyposmat_data_filename = 'pyposmat.results.9.out'
    pyposmat_configuration_filename = 'pyposmat.config.in'
    data_analyzer = PyposmatDataAnalyzer()
    data_analyzer.read_configuration_file(
        filename=pyposmat_configuration_filename)
    data_analyzer.read_data_file(
        filename=os.path.join(data_directory, pyposmat_data_filename))

    #data_analyzer.filter_performance_requirements()
    #data_analyzer.calculate_pareto_set()

    data_analyzer.write_kde_file(filename='pyposmat.kde.out')
    exit()