Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
d0922dd
1
Parent(s):
9f21464
Improve research showcase
Browse files- docs/generate_papers.py +22 -53
docs/generate_papers.py
CHANGED
@@ -1,43 +1,8 @@
|
|
1 |
-
"""Read papers.yml and generate papers.md
|
2 |
-
|
3 |
-
# Here is an example papers.yml:
|
4 |
-
|
5 |
-
papers:
|
6 |
-
- title: Machine Learning the Gravity Equation for International Trade
|
7 |
-
authors:
|
8 |
-
- Sergiy Verstyuk (1)
|
9 |
-
- Michael R. Douglas (1)
|
10 |
-
affiliations:
|
11 |
-
1: Harvard University
|
12 |
-
link: https://papers.ssrn.com/abstract=4053795
|
13 |
-
abstract: Machine learning (ML) is becoming more and more important throughout the mathematical and theoretical sciences. In this work we apply modern ML methods to gravity models of pairwise interactions in international economics. We explain the formulation of graphical neural networks (GNNs), models for graph-structured data that respect the properties of exchangeability and locality. GNNs are a natural and theoretically appealing class of models for international trade, which we demonstrate empirically by fitting them to a large panel of annual-frequency country-level data. We then use a symbolic regression algorithm to turn our fits into interpretable models with performance comparable to state of the art hand-crafted models motivated by economic theory. The resulting symbolic models contain objects resembling market access functions, which were developed in modern structural literature, but in our analysis arise ab initio without being explicitly postulated. Along the way, we also produce several model-consistent and model-agnostic ML-based measures of bilateral trade accessibility.
|
14 |
-
image: economic_theory_gravity.png
|
15 |
-
date: 2022-03-15
|
16 |
-
|
17 |
-
# Corresponding example papers.md:
|
18 |
-
|
19 |
-
<div class="row"><div class="image_column">
|
20 |
-
|
21 |
-
![](images/economic_theory_gravity.png)
|
22 |
-
|
23 |
-
</div><div class="text_column"><div class="center">
|
24 |
-
|
25 |
-
[Machine Learning the Gravity Equation for International Trade](https://papers.ssrn.com/abstract=4053795)<br>
|
26 |
-
Sergiy Verstyuk<sup>1</sup>, Michael R. Douglas.<sup>1</sup><br><sup>1</sup>Harvard University
|
27 |
-
|
28 |
-
</div>
|
29 |
-
|
30 |
-
**Abstract:** Machine learning (ML) is becoming more and more important throughout the mathematical and theoretical sciences. In this work we apply modern ML methods to gravity models of pairwise interactions in international economics. We explain the formulation of graphical neural networks (GNNs), models for graph-structured data that respect the properties of exchangeability and locality. GNNs are a natural and theoretically appealing class of models for international trade, which we demonstrate empirically by fitting them to a large panel of annual-frequency country-level data. We then use a symbolic regression algorithm to turn our fits into interpretable models with performance comparable to state of the art hand-crafted models motivated by economic theory. The resulting symbolic models contain objects resembling market access functions, which were developed in modern structural literature, but in our analysis arise ab initio without being explicitly postulated. Along the way, we also produce several model-consistent and model-agnostic ML-based measures of bilateral trade accessibility.
|
31 |
-
|
32 |
-
</div></div>
|
33 |
-
"""
|
34 |
-
|
35 |
import yaml
|
36 |
-
from textwrap import dedent
|
37 |
from pathlib import Path
|
38 |
|
39 |
data_file = "papers.yml"
|
40 |
-
papers_header = Path("
|
41 |
output_file = "papers.md"
|
42 |
|
43 |
# Load YAML file:
|
@@ -55,6 +20,7 @@ with open(output_file, "w") as f:
|
|
55 |
# This is in the format of "2022-03-15"
|
56 |
papers = sorted(papers, key=lambda paper: paper["date"], reverse=True)
|
57 |
|
|
|
58 |
for paper in papers:
|
59 |
title = paper["title"]
|
60 |
authors = (
|
@@ -69,22 +35,25 @@ with open(output_file, "w") as f:
|
|
69 |
|
70 |
# Begin:
|
71 |
paper_snippet = f"""
|
72 |
-
<div class="row">
|
73 |
-
|
74 |
-
|
75 |
-
<!-- Text column: -->
|
76 |
-
<div class="text_column"><div class="center">
|
77 |
-
<a href="{link}">{title}</a><br>{authors}<br><small>{affiliations}</small><br>\n\n
|
78 |
-
**Abstract:** {abstract}\n\n
|
79 |
-
</div></div>
|
80 |
-
|
81 |
-
|
82 |
-
<!-- Image column: -->
|
83 |
-
<div class="image_column">\n
|
84 |
-
[![](images/{image_file})]({link})\n\n
|
85 |
-
</div>
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
clean_paper_snippet = dedent(paper_snippet)
|
90 |
-
f.write(clean_paper_snippet)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import yaml
|
|
|
2 |
from pathlib import Path
|
3 |
|
4 |
data_file = "papers.yml"
|
5 |
+
papers_header = Path("stylesheets") / "papers_header.txt"
|
6 |
output_file = "papers.md"
|
7 |
|
8 |
# Load YAML file:
|
|
|
20 |
# This is in the format of "2022-03-15"
|
21 |
papers = sorted(papers, key=lambda paper: paper["date"], reverse=True)
|
22 |
|
23 |
+
snippets = []
|
24 |
for paper in papers:
|
25 |
title = paper["title"]
|
26 |
authors = (
|
|
|
35 |
|
36 |
# Begin:
|
37 |
paper_snippet = f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
<figure markdown>
|
40 |
+
![](images/{image_file}){{ width="500"}}
|
41 |
+
<figcaption>
|
42 |
+
<!-- Large font: -->
|
43 |
+
<h2>
|
44 |
+
<a href="{link}">{title}</a>
|
45 |
+
</h2>
|
46 |
+
</figcaption>
|
47 |
+
</figure>
|
48 |
+
|
49 |
+
<center>
|
50 |
+
{authors}
|
51 |
+
|
52 |
+
<small>{affiliations}</small>
|
53 |
+
</center>
|
54 |
+
|
55 |
+
**Abstract:** {abstract}\n\n
|
56 |
+
"""
|
57 |
+
snippets.append(paper_snippet)
|
58 |
|
59 |
+
f.write("\n\n---\n\n".join(snippets))
|
|
|
|