Beispiel #1
0
def test__GmmAnalysis__make_gmm_models():
    gmm = GmmAnalysis(configuration=o_config,
                      data=o_data,
                      names=o_config.normalized_error_names,
                      output_path=output_path,
                      max_components=max_components)
    gmm.make_gmm_models()
    for k in gmm.models:
        assert isinstance(gmm.models[k]['obj'], GaussianMixture)
        assert isinstance(k, int)
Beispiel #2
0
def dev__GmmAnalysis__do_aic_analysis():
    gmm = GmmAnalysis(configuration=o_config,
                      data=o_data,
                      names=o_config.normalized_error_names,
                      output_path=output_path,
                      max_components=max_components)
    gmm.make_gmm_models()
    gmm.do_aic_analysis()
    for k in gmm.models:
        print(gmm.models[k])
Beispiel #3
0
def test__GmmAnalysis__do_cluster_analysis():
    n_components = 10
    gmm = GmmAnalysis(configuration=o_config,
                      data=o_data,
                      names=o_config.normalized_error_names,
                      output_path=output_path,
                      max_components=max_components)
    gmm.make_gmm_models()
    gmm.do_cluster_analysis(n_components=n_components)

    for k in gmm.cluster_ids:
        assert isinstance(k, int)
Beispiel #4
0
def test__GmmAnalysis__do_aic_analysis():
    gmm = GmmAnalysis(configuration=o_config,
                      data=o_data,
                      names=o_config.normalized_error_names,
                      output_path=output_path,
                      max_components=max_components)
    gmm.make_gmm_models()
    gmm.do_aic_analysis()
    for k in gmm.models:
        assert isinstance(gmm.models[k]['aic'], float)
    assert isinstance(gmm.aic_criteria, dict)
    assert isinstance(gmm.aic_criteria['min_components'], int)
    assert isinstance(gmm.aic_criteria['min_value'], float)
Beispiel #5
0
def dev__GmmAnalysis():
    max_components = 20
    n_components = 10
    gmm = GmmAnalysis(configuration=o_config,
                      data=o_data,
                      names='all',
                      output_path=output_path,
                      max_components=max_components)
    print(gmm.names)
    gmm.make_gmm_models()
    gmm.do_aic_analysis()
    gmm.do_bic_analysis()
    gmm.do_ic_analysis()
    gmm.do_cluster_analysis(n_components=n_components)

    # table__cluster_info(gmm)
    # table__cluster_parameters(gmm)
    # table__cluster_qois(gmm)
    plot__cluster_qoi(gmm)
    gmm.plot_gmm_analysis(n_components=20)
Beispiel #6
0
            'pyposmat.kde.1.out')

    o_config = PyposmatConfigurationFile()
    o_config.read(filename=config_fn)

    o_data = PyposmatDataFile()
    o_data.read(filename=data_fn)
    o_data.create_normalized_errors(
            normalize_type='by_qoi_target',
           qoi_targets=o_config.qoi_targets)

    max_components = 10
    gmm = GmmAnalysis(configuration=o_config,
                      data=o_data,
                      names=o_config.normalized_error_names)
    gmm.make_gmm_models(max_components=max_components)
    o_data.df['score'] = o_data.df[o_config.normalized_error_names].abs().sum(axis=1)

    exit()
    # do AIC and BIC analysis
    if True:
        name_1 = o_config.qoi_names[0]
        name_2 = o_config.qoi_names[1]
        data = o_data.df[[name_1,name_2]]
        max_components = 21
        gmm_analysis(
            config_fn=config_fn,
            data_fn=data_fn,
            names=[name_1,name_2],
            output_directory='gmm_analysis',
            max_components=20)