<jupyter_start><jupyter_text>load data<jupyter_code># dumped data:
#
# dump(r, 
#      '/home/cham/PycharmProjects/regli/regli/data/regli_lamostdr5_data_snr60_200_star5000_0p80.dump')
# dump((test_flux_norm, test_ivar_norm, test_err_norm, test_labels),
#      '/home/cham/PycharmProjects/regli/regli/data/test_data.dump')

r = load('/home/cham/PycharmProjects/regli/regli/data/regli_lamostdr5_data_snr60_200_star5000_0p80.dump')
test_flux_norm, test_ivar_norm, test_err_norm, test_labels = \
    load('/home/cham/PycharmProjects/regli/regli/data/test_data.dump')
r<jupyter_output><empty_output><jupyter_text>without prior<jupyter_code>i_test = 668

# run MCMC
sampler = r.run_mcmc(test_flux_norm[i_test], obs_err=test_err_norm[i_test], p0=None,
                     n_burnin=(200,300), n_step=3000, lnlike=None, lnprior=None, pos_eps=0.01, full=False)

# result values
truths=sampler.flatchain[np.argmax(sampler.flatlnprobability)]
print("max likelihood ", truths)
print("test label     ", test_labels[i_test])

# corner plot
fig = corner(sampler.flatchain, truths=test_labels[i_test], labels=["Teff", "logg", "[Fe/H]"])<jupyter_output>@Regli.best_match:  [5.97651318e+03 4.32899990e+00 1.92684199e-01]
@Regli: using the default gaissian *lnlike* function...
@Regli: No prior is adopted ...
@Regli: running burn-in [200]...
@Regli: running burn-in [300]...
@Regli: running chains [3000]...
max likelihood  [5.95568808e+03 4.24566333e+00 1.99470992e-01]
test label      [5.948e+03 4.226e+00 1.900e-01]<jupyter_text>covariance / correlation coefficients<jupyter_code>from regli.mcmc import sample_covariance, cov_to_rho, cov_to_std
_cov = sample_covariance(sampler.flatchain)
_rho = cov_to_rho(_cov)
_std = cov_to_std(_cov)
print("cov\n", _cov)
print("rho\n", _rho)
print("std\n", _std)<jupyter_output>cov
 [[1.12222989e+02 1.38826136e-01 5.08478787e-02]
 [1.38826136e-01 4.46191682e-04 1.75533077e-05]
 [5.08478787e-02 1.75533077e-05 9.86935678e-05]]
rho
 [[1.         0.62039685 0.48315613]
 [0.62039685 1.         0.08364766]
 [0.48315613 0.08364766 1.        ]]
std
 [1.05935353e+01 2.11232498e-02 9.93446364e-03]<jupyter_text>with prior<jupyter_code># define your prior
def lnprior(x):
    if 5955<=x[0]<=6000:
        return 0
    else:
        return -np.inf

i_test = 668

# run MCMC
sampler = r.run_mcmc(test_flux_norm[i_test], obs_err=test_err_norm[i_test], p0=None,
                     n_burnin=(200,300), n_step=3000, lnlike=None, lnprior=lnprior, pos_eps=0.01, full=False)

# result values
truths=sampler.flatchain[np.argmax(sampler.flatlnprobability)]
print("max likelihood ", truths)
print("test label     ", test_labels[i_test])

# corner plot
fig = corner(sampler.flatchain, truths=test_labels[i_test], labels=["Teff", "logg", "[Fe/H]"])<jupyter_output>@Regli.best_match:  [5.97651318e+03 4.32899990e+00 1.92684199e-01]
@Regli: using the default gaissian *lnlike* function...
@Regli: using user-defined *lnprior* function...
@Regli: running burn-in [200]...
@Regli: running burn-in [300]...
@Regli: running chains [3000]...
max likelihood  [5.95603672e+03 4.24601687e+00 1.99418182e-01]
test label      [5.948e+03 4.226e+00 1.900e-01]
{'fraction_non_alphanumeric': 0.1492063492063492, 'fraction_numerical': 0.1419047619047619, 'mean_word_length': 4.96780303030303, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '533609', 'license': 'MIT', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1334, 'n_words': 210, 'path': 'regli_regression_example.ipynb', 'repo_name': 'hypergravity/regli', 'size': '3150'}