Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
1daaaff
1
Parent(s):
9ddc851
Clean up paper file generator
Browse files- docs/generate_papers.py +28 -10
- docs/papers_header.md +2 -2
docs/generate_papers.py
CHANGED
@@ -1,7 +1,7 @@
|
|
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:
|
@@ -12,10 +12,9 @@ papers:
|
|
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 |
-
"""
|
16 |
|
17 |
# Corresponding example papers.md:
|
18 |
-
|
19 |
<div class="row"><div class="image_column">
|
20 |
|
21 |
![](images/economic_theory_gravity.png)
|
@@ -33,6 +32,8 @@ Sergiy Verstyuk<sup>1</sup>, Michael R. Douglas.<sup>1</sup><br><sup>1</sup>Harv
|
|
33 |
"""
|
34 |
|
35 |
import yaml
|
|
|
|
|
36 |
|
37 |
data_file = "papers.yml"
|
38 |
papers_header = "papers_header.md"
|
@@ -61,9 +62,26 @@ with open(output_file, "w") as f:
|
|
61 |
abstract = paper["abstract"]
|
62 |
image_file = paper["image"]
|
63 |
|
64 |
-
|
65 |
-
f
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
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 |
|
16 |
# Corresponding example papers.md:
|
17 |
+
|
18 |
<div class="row"><div class="image_column">
|
19 |
|
20 |
![](images/economic_theory_gravity.png)
|
|
|
32 |
"""
|
33 |
|
34 |
import yaml
|
35 |
+
# Import dedent:
|
36 |
+
from textwrap import dedent
|
37 |
|
38 |
data_file = "papers.yml"
|
39 |
papers_header = "papers_header.md"
|
|
|
62 |
abstract = paper["abstract"]
|
63 |
image_file = paper["image"]
|
64 |
|
65 |
+
# Begin:
|
66 |
+
paper_snippet = f"""
|
67 |
+
<div class="row">
|
68 |
+
|
69 |
+
<!-- Image column: -->
|
70 |
+
<div class="image_column">
|
71 |
+
|
72 |
+
![](images/{image_file})\n\n
|
73 |
+
|
74 |
+
</div>
|
75 |
+
|
76 |
+
<!-- Text column: -->
|
77 |
+
<div class="text_column"><div class="center">
|
78 |
+
|
79 |
+
<a href="{link}">{title}</a><br>{authors}<br>{affiliations}<br>
|
80 |
+
|
81 |
+
**Abstract:** {abstract}
|
82 |
+
|
83 |
+
</div></div>
|
84 |
+
|
85 |
+
</div>"""
|
86 |
+
clean_paper_snippet = dedent(paper_snippet)
|
87 |
+
f.write(clean_paper_snippet)
|
docs/papers_header.md
CHANGED
@@ -16,7 +16,7 @@ please submit a pull request to add your paper to [this file](https://github.com
|
|
16 |
clear: both;
|
17 |
}
|
18 |
.image_column {
|
19 |
-
flex:
|
20 |
float: left;
|
21 |
padding: 10px;
|
22 |
display: flex;
|
@@ -25,7 +25,7 @@ please submit a pull request to add your paper to [this file](https://github.com
|
|
25 |
text-align: center;
|
26 |
}
|
27 |
.text_column {
|
28 |
-
flex:
|
29 |
padding: 10px;
|
30 |
}
|
31 |
.center {
|
|
|
16 |
clear: both;
|
17 |
}
|
18 |
.image_column {
|
19 |
+
flex: 50%;
|
20 |
float: left;
|
21 |
padding: 10px;
|
22 |
display: flex;
|
|
|
25 |
text-align: center;
|
26 |
}
|
27 |
.text_column {
|
28 |
+
flex: 50%;
|
29 |
padding: 10px;
|
30 |
}
|
31 |
.center {
|