probml / pyprobml

Python code for "Probabilistic Machine learning" book by Kevin Murphy
MIT License
6.45k stars 1.52k forks source link

rewrite dp_mixgauss_cluster notebook #1078

Closed xinglong-li closed 2 years ago

review-notebook-app[bot] commented 2 years ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

murphyk commented 2 years ago

It would be better to replace

samples_set[f"gmm_{n_clusters}_data_{str(m_precision).split('.')[0]}p{str(m_precision).split('.')[1]}"] = gmm_samples

with something like this

def replace_period(m):
  return str(m).split('.')[0]}p.split('.')[1]

fname = "gmm_{n_clusters}_data_{replace_period(m_precision)}}"
samples_set[fname] = gmm_samples
xinglong-li commented 2 years ago

Thanks, I'll change it in my future code!