Skip to content

Commit

Permalink
Add growth graph (#227)
Browse files Browse the repository at this point in the history
* Add Publication per Year figure: creation in make_md.py and display in README.md

* adjust image path

* Add README to commit

* add numpy and matplotlib to CI env

* remove versions from numpy in requirements file

* remove latex rendering in plot for testing

* Add figure to top

* Adjust figure file paths

* Center the images

* Add dark and brigh version and make relative sizes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Small fix in make_md

---------

Co-authored-by: Claudius Krause <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 1, 2024
1 parent b84e445 commit 112c611
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[![download](https://img.shields.io/badge/download-review-blue.svg)](https://iml-wg.github.io/HEPML-LivingReview/assets/hepml_review.pdf)
[![github](https://badges.aleen42.com/src/github.svg)](https://github.com/iml-wg/HEPML-LivingReview)

<p align="center"><img src="docs/assets/per_year.png" width="75%", alt="Publications per Year"></p>

The purpose of this note is to collect references for modern machine learning as applied to particle physics. A minimal number of categories is chosen in order to be as useful as possible. Note that papers may be referenced in more than one category. The fact that a paper is listed in this document does not endorse or validate its content - that is for the community (and for peer-review) to decide. Furthermore, the classification here is a best attempt and may have flaws - please let us know if (a) we have missed a paper you think should be included, (b) a paper has been misclassified, or (c) a citation for a paper is not correct or if the journal information is now available. In order to be as useful as possible, this document will continue to evolve so please check back before you write your next paper. If you find this review helpful, please consider citing it using ```\cite{hepmllivingreview}``` in `HEPML.bib`.

This review was built with the help of the HEP-ML community, the [INSPIRE REST API](https://github.com/inspirehep/rest-api-doc), and the moderators Benjamin Nachman, Matthew Feickert, Claudius Krause, and Ramon Winterhalder.
Expand Down
Binary file added docs/assets/dark_per_year.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/per_year.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const expandElements = shouldExpand => {
[![download](https://img.shields.io/badge/download-review-blue.svg)](https://iml-wg.github.io/HEPML-LivingReview/assets/hepml_review.pdf)
[![github](https://badges.aleen42.com/src/github.svg)](https://github.com/iml-wg/HEPML-LivingReview)

<p align="center"><img src="assets/per_year.png#only-light" width="75%", alt="Publications per Year"></p>
<p align="center"><img src="assets/dark_per_year.png#only-dark" width="75%", alt="Publications per Year"></p>


<a class="md-button" onClick="expandElements(true)">Expand all sections</a>
<a class="md-button" onClick="expandElements(false)">Collapse all sections</a>
Expand Down
47 changes: 45 additions & 2 deletions make_md.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
from dataclasses import dataclass
from datetime import datetime
from datetime import date, datetime

import requests

update_journal = False
update_recent = False

update_plot = False

myfile = open("HEPML.tex", encoding="utf8")
myfile_readme = open("README.md","w", encoding="utf8")
Expand All @@ -28,6 +28,13 @@
file.write("[![download](https://img.shields.io/badge/download-review-blue.svg)](https://iml-wg.github.io/HEPML-LivingReview/assets/hepml_review.pdf)\n[![github](https://badges.aleen42.com/src/github.svg)](https://github.com/iml-wg/HEPML-LivingReview)\n\n")


# neccessary in testing since readme and out file are at different locations.
# once merged to master, link can point to file on master branch for both
myfile_readme.write('<p align="center"><img src="docs/assets/per_year.png" width="75%", alt="Publications per Year"></p>\n\n')
myfile_out.write('<p align="center"><img src="assets/per_year.png#only-light" width="75%", alt="Publications per Year"></p>\n')
myfile_out.write('<p align="center"><img src="assets/dark_per_year.png#only-dark" width="75%", alt="Publications per Year"></p>\n\n')


for file in myfile_readme,myfile_about:
file.write(r"The purpose of this note is to collect references for modern machine learning as applied to particle physics. A minimal number of categories is chosen in order to be as useful as possible. Note that papers may be referenced in more than one category. The fact that a paper is listed in this document does not endorse or validate its content - that is for the community (and for peer-review) to decide. Furthermore, the classification here is a best attempt and may have flaws - please let us know if (a) we have missed a paper you think should be included, (b) a paper has been misclassified, or (c) a citation for a paper is not correct or if the journal information is now available. In order to be as useful as possible, this document will continue to evolve so please check back before you write your next paper. If you find this review helpful, please consider citing it using ```\cite{hepmllivingreview}``` in `HEPML.bib`.")
file.write("\n\nThis review was built with the help of the HEP-ML community, the [INSPIRE REST API](https://github.com/inspirehep/rest-api-doc), and the moderators Benjamin Nachman, Matthew Feickert, Claudius Krause, and Ramon Winterhalder.\n\n")
Expand Down Expand Up @@ -171,21 +178,25 @@ def convert_from_bib(myline):
paper=f" [[DOI](https://doi.org/{myentry_dict['doi']})]"
elif "url" in myentry_dict:
paper=f" [[url]({myentry_dict['url']})]"
YEARS_FOR_PLOT.append(year)
return "["+myentry_dict["title"]+"](https://arxiv.org/abs/"+myentry_dict["eprint"]+")"+paper+year
elif "doi" in myentry_dict:
year=""
if "year" in myentry_dict:
year = f" ({myentry_dict['year']})"
YEARS_FOR_PLOT.append(year)
return "["+myentry_dict["title"]+"](https://doi.org/"+myentry_dict["doi"]+")"+year
elif "url" in myentry_dict:
year=""
if "year" in myentry_dict:
year = f" ({myentry_dict['year']})"
YEARS_FOR_PLOT.append(year)
return "["+myentry_dict["title"]+"]("+myentry_dict["url"]+")"+year
else:
year=""
if "year" in myentry_dict:
year = f" ({myentry_dict['year']})"
YEARS_FOR_PLOT.append(year)
return myentry_dict["title"]+year
return myline

Expand All @@ -209,6 +220,7 @@ def write_to_files(*args,readme=myfile_readme,webpage=myfile_out,add_header=Fals
webpage.write("\n??? example "+"\""+split[-1].strip()+"\"\n\n")

itemize_counter = 0
YEARS_FOR_PLOT = []
for line in myfile:

if "author" in line:
Expand Down Expand Up @@ -275,6 +287,37 @@ def write_to_files(*args,readme=myfile_readme,webpage=myfile_out,add_header=Fals
write_to_files(header+line.split(r"\item")[1]+"\n\n")
pass

if update_plot:
import matplotlib.pyplot as plt
import numpy as np
names =["per_year.png", "dark_per_year.png"]
for name in names:
if name == "dark_per_year.png":
plt.style.use('dark_background')
#plt.rcParams.update({"text.usetex": True,
# "font.family": "Helvetica"})
min_year = 2000
clean_list = []
for entry in YEARS_FOR_PLOT:
clean_list.append(int(entry.replace(" (", "").replace(")", "")))
years, counts = np.unique(clean_list, return_counts=True)
plt.figure(figsize=(6,4))
plt.bar(years, counts, zorder=5)
plt.title(r"Number of HEP-ML Papers by Year", fontsize=16)
plt.xlabel(r"Year", fontsize=12)
plt.ylabel(r"Number of Papers", fontsize=12)
plt.xlim(min_year, years.max()+1)
plt.grid(axis='y', zorder=0)
labels = np.arange(min_year, years.max()+1)
plt.gca().set_xticks(labels, [str(lbl) for lbl in labels], rotation=90, ha='center')
plt.xticks(rotation=90)
plt.tight_layout()
plt.gca().text(0.02, 0.98, f'As of {date.today().strftime("%d.%m.%Y")}',
verticalalignment='top', horizontalalignment='left',
transform=plt.gca().transAxes)
plt.savefig(f'docs/assets/{name}', transparent=True)


def get_year_month(period_months=3):
month_up = datetime.now().month
year = datetime.now().year
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
matplotlib
mkdocs~=1.4.3
mkdocs-material~=9.1.14
mkdocs-material-extensions~=1.1.1
numpy
requests~=2.27

0 comments on commit 112c611

Please sign in to comment.