rishabh-ranjan commited on
Commit
5e8aa46
·
verified ·
1 Parent(s): ff824d9

rel-stack: YAML manifests + descriptions + schema card

Browse files
rel-stack/README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - relbench
4
+ - relational-deep-learning
5
+ pretty_name: rel-stack
6
+ ---
7
+
8
+ # rel-stack
9
+
10
+ Stack Exchange Q&A: users, posts, comments, votes, badges, and post links.
11
+
12
+ ## Schema
13
+
14
+ ```mermaid
15
+ erDiagram
16
+ badges {
17
+ key Id PK
18
+ key UserId FK
19
+ datetime Date
20
+ }
21
+ votes {
22
+ key Id PK
23
+ key PostId FK
24
+ key UserId FK
25
+ datetime CreationDate
26
+ }
27
+ users {
28
+ key Id PK
29
+ datetime CreationDate
30
+ }
31
+ comments {
32
+ key Id PK
33
+ key UserId FK
34
+ key PostId FK
35
+ datetime CreationDate
36
+ }
37
+ posts {
38
+ key Id PK
39
+ key OwnerUserId FK
40
+ key ParentId FK
41
+ datetime CreationDate
42
+ }
43
+ postLinks {
44
+ key Id PK
45
+ key PostId FK
46
+ key RelatedPostId FK
47
+ datetime CreationDate
48
+ }
49
+ postHistory {
50
+ key Id PK
51
+ key PostId FK
52
+ key UserId FK
53
+ datetime CreationDate
54
+ }
55
+ badges }o--|| users : UserId
56
+ votes }o--|| posts : PostId
57
+ votes }o--|| users : UserId
58
+ comments }o--|| users : UserId
59
+ comments }o--|| posts : PostId
60
+ posts }o--|| users : OwnerUserId
61
+ posts }o--|| posts : ParentId
62
+ postLinks }o--|| posts : PostId
63
+ postLinks }o--|| posts : RelatedPostId
64
+ postHistory }o--|| posts : PostId
65
+ postHistory }o--|| users : UserId
66
+ ```
67
+
68
+ Splits: validation `2020-10-01`, test `2021-01-01` (rows up to a split's timestamp are the inputs for that split).
69
+
70
+ ## Tasks
71
+
72
+ | task | kind | type | description |
73
+ |---|---|---|---|
74
+ | `badges-class` | autocomplete | multiclass_classification | Predict the `Class` column of the `badges` table. |
75
+ | `post-post-related` | forecast | link_prediction | Predict a list of existing posts that users will link a given post to in the next two years. |
76
+ | `post-votes` | forecast | regression | Predict the number of upvotes that an existing question will receive in the next 2 years. |
77
+ | `user-badge` | forecast | binary_classification | Predict if each user will receive in a new badge the next 2 years. |
78
+ | `user-engagement` | forecast | binary_classification | Predict if a user will make any votes/posts/comments in the next 2 years. |
79
+ | `user-post-comment` | forecast | link_prediction | Predict a list of existing posts that a user will comment in the next two years. |
80
+
81
+ ## Loading
82
+
83
+ ```python
84
+ import relbench
85
+ ds = relbench.load_dataset("rel-stack")
86
+ task = relbench.load_task("rel-stack", "<task>")
87
+ ```
88
+
89
+ Manifest layout (`manifest.yaml` + plain parquet); see the RelBench [CONTRIBUTING guide](https://github.com/snap-stanford/relbench/blob/main/CONTRIBUTING.md).
rel-stack/manifest.json DELETED
@@ -1,60 +0,0 @@
1
- {
2
- "name": "rel-stack",
3
- "manifest_version": 1,
4
- "val_timestamp": "2020-10-01",
5
- "test_timestamp": "2021-01-01",
6
- "tables": {
7
- "badges": {
8
- "pkey": "Id",
9
- "time_col": "Date",
10
- "fkeys": {
11
- "UserId": "users"
12
- }
13
- },
14
- "votes": {
15
- "pkey": "Id",
16
- "time_col": "CreationDate",
17
- "fkeys": {
18
- "PostId": "posts",
19
- "UserId": "users"
20
- }
21
- },
22
- "users": {
23
- "pkey": "Id",
24
- "time_col": "CreationDate",
25
- "fkeys": {}
26
- },
27
- "comments": {
28
- "pkey": "Id",
29
- "time_col": "CreationDate",
30
- "fkeys": {
31
- "UserId": "users",
32
- "PostId": "posts"
33
- }
34
- },
35
- "posts": {
36
- "pkey": "Id",
37
- "time_col": "CreationDate",
38
- "fkeys": {
39
- "OwnerUserId": "users",
40
- "ParentId": "posts"
41
- }
42
- },
43
- "postLinks": {
44
- "pkey": "Id",
45
- "time_col": "CreationDate",
46
- "fkeys": {
47
- "PostId": "posts",
48
- "RelatedPostId": "posts"
49
- }
50
- },
51
- "postHistory": {
52
- "pkey": "Id",
53
- "time_col": "CreationDate",
54
- "fkeys": {
55
- "PostId": "posts",
56
- "UserId": "users"
57
- }
58
- }
59
- }
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rel-stack/manifest.yaml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: rel-stack
2
+ manifest_version: 1
3
+ description: 'Stack Exchange Q&A: users, posts, comments, votes, badges, and post links.'
4
+ val_timestamp: '2020-10-01'
5
+ test_timestamp: '2021-01-01'
6
+ tables:
7
+ badges:
8
+ pkey: Id
9
+ time_col: Date
10
+ fkeys:
11
+ UserId: users
12
+ votes:
13
+ pkey: Id
14
+ time_col: CreationDate
15
+ fkeys:
16
+ PostId: posts
17
+ UserId: users
18
+ users:
19
+ pkey: Id
20
+ time_col: CreationDate
21
+ fkeys: {}
22
+ comments:
23
+ pkey: Id
24
+ time_col: CreationDate
25
+ fkeys:
26
+ UserId: users
27
+ PostId: posts
28
+ posts:
29
+ pkey: Id
30
+ time_col: CreationDate
31
+ fkeys:
32
+ OwnerUserId: users
33
+ ParentId: posts
34
+ postLinks:
35
+ pkey: Id
36
+ time_col: CreationDate
37
+ fkeys:
38
+ PostId: posts
39
+ RelatedPostId: posts
40
+ postHistory:
41
+ pkey: Id
42
+ time_col: CreationDate
43
+ fkeys:
44
+ PostId: posts
45
+ UserId: users
rel-stack/tasks/badges-class/manifest.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "name": "badges-class",
3
- "kind": "autocomplete",
4
- "task_type": "multiclass_classification",
5
- "entity_table": "badges",
6
- "target_col": "Class",
7
- "metrics": [],
8
- "remove_columns": [
9
- [
10
- "badges",
11
- "TagBased"
12
- ],
13
- [
14
- "badges",
15
- "Name"
16
- ]
17
- ],
18
- "manifest_version": 1
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rel-stack/tasks/badges-class/manifest.yaml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: badges-class
2
+ kind: autocomplete
3
+ task_type: multiclass_classification
4
+ description: Predict the `Class` column of the `badges` table.
5
+ entity_table: badges
6
+ target_col: Class
7
+ remove_columns:
8
+ - - badges
9
+ - TagBased
10
+ - - badges
11
+ - Name
12
+ manifest_version: 1
rel-stack/tasks/post-post-related/manifest.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "name": "post-post-related",
3
- "kind": "forecast",
4
- "task_type": "link_prediction",
5
- "target_col": "postLinksIdList",
6
- "time_col": "timestamp",
7
- "src_entity_table": "posts",
8
- "src_entity_col": "PostId",
9
- "dst_entity_table": "posts",
10
- "dst_entity_col": "postLinksIdList",
11
- "eval_k": 100,
12
- "timedelta": "91 days",
13
- "metrics": [
14
- "link_prediction_precision",
15
- "link_prediction_recall",
16
- "link_prediction_map"
17
- ],
18
- "sql": "\n SELECT\n t.timestamp,\n pl.PostId as PostId,\n LIST(DISTINCT pl.RelatedPostId) AS postLinksIdList\n FROM\n timestamps t\n LEFT JOIN\n postLinks pl\n ON\n pl.CreationDate > t.timestamp AND\n pl.CreationDate <= t.timestamp + INTERVAL '{timedelta}'\n LEFT JOIN\n posts p1\n ON\n pl.PostId = p1.Id\n LEFT JOIN\n posts p2\n ON\n pl.RelatedPostId = p2.Id\n WHERE\n pl.PostId IS NOT NULL AND\n pl.RelatedPostId IS NOT NULL AND\n p1.CreationDate <= t.timestamp AND\n p2.CreationDate <= t.timestamp\n GROUP BY\n t.timestamp,\n pl.PostId;\n ",
19
- "manifest_version": 1
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rel-stack/tasks/post-post-related/manifest.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: post-post-related
2
+ kind: forecast
3
+ task_type: link_prediction
4
+ description: Predict a list of existing posts that users will link a given post to in the next two years.
5
+ target_col: postLinksIdList
6
+ time_col: timestamp
7
+ src_entity_table: posts
8
+ src_entity_col: PostId
9
+ dst_entity_table: posts
10
+ dst_entity_col: postLinksIdList
11
+ eval_k: 100
12
+ timedelta: 91 days
13
+ sql: "\n SELECT\n t.timestamp,\n pl.PostId as PostId,\n LIST(DISTINCT pl.RelatedPostId) AS postLinksIdList\n FROM\n timestamps t\n LEFT JOIN\n postLinks pl\n ON\n pl.CreationDate > t.timestamp AND\n pl.CreationDate <= t.timestamp + INTERVAL '{timedelta}'\n LEFT JOIN\n posts p1\n ON\n pl.PostId = p1.Id\n LEFT JOIN\n posts p2\n ON\n pl.RelatedPostId = p2.Id\n WHERE\n pl.PostId IS NOT NULL AND\n pl.RelatedPostId IS NOT NULL AND\n p1.CreationDate <= t.timestamp AND\n p2.CreationDate <= t.timestamp\n GROUP BY\n t.timestamp,\n pl.PostId;\n "
14
+ manifest_version: 1
rel-stack/tasks/post-votes/manifest.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "name": "post-votes",
3
- "kind": "forecast",
4
- "task_type": "regression",
5
- "entity_table": "posts",
6
- "entity_col": "PostId",
7
- "target_col": "popularity",
8
- "time_col": "timestamp",
9
- "timedelta": "91 days",
10
- "metrics": [
11
- "r2",
12
- "mae",
13
- "rmse"
14
- ],
15
- "sql": "\n SELECT\n t.timestamp,\n p.id AS PostId,\n COUNT(distinct v.id) AS popularity\n FROM\n timestamps t\n LEFT JOIN\n posts p\n ON\n p.CreationDate <= t.timestamp AND\n p.owneruserid != -1 AND\n p.owneruserid is not null AND\n p.PostTypeId = 1\n LEFT JOIN\n votes v\n ON\n p.id = v.PostId AND\n v.CreationDate > t.timestamp AND\n v.CreationDate <= t.timestamp + INTERVAL '{timedelta}' AND\n v.votetypeid = 2\n GROUP BY\n t.timestamp,\n p.id\n ;\n\n ",
16
- "manifest_version": 1
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rel-stack/tasks/post-votes/manifest.yaml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: post-votes
2
+ kind: forecast
3
+ task_type: regression
4
+ description: Predict the number of upvotes that an existing question will receive in the next 2 years.
5
+ entity_table: posts
6
+ entity_col: PostId
7
+ target_col: popularity
8
+ time_col: timestamp
9
+ timedelta: 91 days
10
+ sql: "\n SELECT\n t.timestamp,\n p.id AS PostId,\n COUNT(distinct v.id) AS popularity\n FROM\n timestamps t\n LEFT JOIN\n posts p\n ON\n p.CreationDate <= t.timestamp AND\n p.owneruserid != -1 AND\n p.owneruserid is not null AND\n p.PostTypeId = 1\n LEFT JOIN\n votes v\n ON\n p.id = v.PostId AND\n v.CreationDate > t.timestamp AND\n v.CreationDate <= t.timestamp + INTERVAL '{timedelta}' AND\n v.votetypeid = 2\n GROUP BY\n t.timestamp,\n p.id\n ;\n\n "
11
+ manifest_version: 1
rel-stack/tasks/user-badge/manifest.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "name": "user-badge",
3
- "kind": "forecast",
4
- "task_type": "binary_classification",
5
- "entity_table": "users",
6
- "entity_col": "UserId",
7
- "target_col": "WillGetBadge",
8
- "time_col": "timestamp",
9
- "timedelta": "91 days",
10
- "metrics": [
11
- "average_precision",
12
- "accuracy",
13
- "f1",
14
- "roc_auc"
15
- ],
16
- "sql": "\n SELECT\n timestamp,\n CAST(UserId AS BIGINT) AS UserId,\n WillGetBadge\n FROM (\n SELECT\n t.timestamp,\n u.Id as UserId,\n CASE WHEN\n COUNT(b.Id) >= 1 THEN 1 ELSE 0 END AS WillGetBadge\n FROM\n timestamps t\n LEFT JOIN\n users u\n ON\n u.CreationDate <= t.timestamp\n LEFT JOIN\n badges b\n ON\n u.Id = b.UserID\n AND b.Date > t.timestamp\n AND b.Date <= t.timestamp + INTERVAL '{timedelta}'\n GROUP BY\n t.timestamp,\n u.Id\n )\n WHERE UserId IS NOT NULL\n ",
17
- "manifest_version": 1
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rel-stack/tasks/user-badge/manifest.yaml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: user-badge
2
+ kind: forecast
3
+ task_type: binary_classification
4
+ description: Predict if each user will receive in a new badge the next 2 years.
5
+ entity_table: users
6
+ entity_col: UserId
7
+ target_col: WillGetBadge
8
+ time_col: timestamp
9
+ timedelta: 91 days
10
+ sql: "\n SELECT\n timestamp,\n CAST(UserId AS BIGINT) AS UserId,\n WillGetBadge\n FROM (\n SELECT\n t.timestamp,\n u.Id as UserId,\n CASE WHEN\n COUNT(b.Id) >= 1 THEN 1 ELSE 0 END AS WillGetBadge\n FROM\n timestamps t\n LEFT JOIN\n users u\n ON\n u.CreationDate <= t.timestamp\n LEFT JOIN\n badges b\n ON\n u.Id = b.UserID\n AND b.Date > t.timestamp\n AND b.Date <= t.timestamp + INTERVAL '{timedelta}'\n GROUP BY\n t.timestamp,\n u.Id\n )\n WHERE UserId IS NOT NULL\n "
11
+ manifest_version: 1
rel-stack/tasks/user-engagement/manifest.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "name": "user-engagement",
3
- "kind": "forecast",
4
- "task_type": "binary_classification",
5
- "entity_table": "users",
6
- "entity_col": "OwnerUserId",
7
- "target_col": "contribution",
8
- "time_col": "timestamp",
9
- "timedelta": "91 days",
10
- "metrics": [
11
- "average_precision",
12
- "accuracy",
13
- "f1",
14
- "roc_auc"
15
- ],
16
- "sql": "\n WITH\n ALL_ENGAGEMENT AS (\n SELECT\n p.id,\n p.owneruserid as userid,\n p.creationdate\n FROM\n posts p\n UNION\n SELECT\n v.id,\n v.userid,\n v.creationdate\n FROM\n votes v\n UNION\n SELECT\n c.id,\n c.userid,\n c.creationdate\n FROM\n comments c\n ),\n\n ACTIVE_USERS AS (\n SELECT\n t.timestamp,\n u.id,\n count(distinct a.id) as n_engagement\n FROM timestamps t\n CROSS JOIN users u\n LEFT JOIN all_engagement a\n ON u.id = a.UserId\n and a.CreationDate <= t.timestamp\n WHERE u.id != -1\n GROUP BY t.timestamp, u.id\n )\n SELECT\n u.timestamp,\n u.id as OwnerUserId,\n IF(count(distinct a.id) >= 1, 1, 0) as contribution\n FROM\n active_users u\n LEFT JOIN\n all_engagement a\n ON\n u.id = a.UserId AND\n a.CreationDate > u.timestamp AND\n a.CreationDate <= u.timestamp + INTERVAL '{timedelta}'\n where\n u.n_engagement >= 1\n GROUP BY\n u.timestamp, u.id\n ;\n\n ",
17
- "manifest_version": 1
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rel-stack/tasks/user-engagement/manifest.yaml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: user-engagement
2
+ kind: forecast
3
+ task_type: binary_classification
4
+ description: Predict if a user will make any votes/posts/comments in the next 2 years.
5
+ entity_table: users
6
+ entity_col: OwnerUserId
7
+ target_col: contribution
8
+ time_col: timestamp
9
+ timedelta: 91 days
10
+ sql: "\n WITH\n ALL_ENGAGEMENT AS (\n SELECT\n p.id,\n p.owneruserid as userid,\n p.creationdate\n FROM\n posts p\n UNION\n SELECT\n v.id,\n v.userid,\n v.creationdate\n FROM\n votes v\n UNION\n SELECT\n c.id,\n c.userid,\n c.creationdate\n FROM\n comments c\n ),\n\n ACTIVE_USERS AS (\n SELECT\n t.timestamp,\n u.id,\n count(distinct a.id) as n_engagement\n FROM timestamps t\n CROSS JOIN users u\n LEFT JOIN all_engagement a\n ON u.id = a.UserId\n and a.CreationDate <= t.timestamp\n WHERE u.id != -1\n GROUP BY t.timestamp, u.id\n )\n SELECT\n u.timestamp,\n u.id as OwnerUserId,\n IF(count(distinct a.id) >= 1, 1, 0) as contribution\n FROM\n active_users u\n LEFT JOIN\n all_engagement a\n ON\n u.id = a.UserId AND\n a.CreationDate > u.timestamp AND\n a.CreationDate <= u.timestamp + INTERVAL '{timedelta}'\n where\n u.n_engagement >= 1\n GROUP BY\n u.timestamp, u.id\n ;\n\n "
11
+ manifest_version: 1
rel-stack/tasks/user-post-comment/manifest.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "name": "user-post-comment",
3
- "kind": "forecast",
4
- "task_type": "link_prediction",
5
- "target_col": "PostId",
6
- "time_col": "timestamp",
7
- "src_entity_table": "users",
8
- "src_entity_col": "UserId",
9
- "dst_entity_table": "posts",
10
- "dst_entity_col": "PostId",
11
- "eval_k": 100,
12
- "timedelta": "91 days",
13
- "metrics": [
14
- "link_prediction_precision",
15
- "link_prediction_recall",
16
- "link_prediction_map"
17
- ],
18
- "sql": "\n SELECT\n t.timestamp,\n c.UserId as UserId,\n LIST(DISTINCT p.id) AS PostId\n FROM\n timestamps t\n LEFT JOIN\n posts p\n ON\n p.CreationDate <= t.timestamp\n LEFT JOIN\n comments c\n ON\n p.id = c.PostId AND\n c.CreationDate > t.timestamp AND\n c.CreationDate <= t.timestamp + INTERVAL '{timedelta}'\n WHERE\n c.UserId is not null AND\n p.owneruserid != -1 AND\n p.owneruserid is not null\n GROUP BY\n t.timestamp,\n c.UserId\n ",
19
- "manifest_version": 1
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
rel-stack/tasks/user-post-comment/manifest.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: user-post-comment
2
+ kind: forecast
3
+ task_type: link_prediction
4
+ description: Predict a list of existing posts that a user will comment in the next two years.
5
+ target_col: PostId
6
+ time_col: timestamp
7
+ src_entity_table: users
8
+ src_entity_col: UserId
9
+ dst_entity_table: posts
10
+ dst_entity_col: PostId
11
+ eval_k: 100
12
+ timedelta: 91 days
13
+ sql: "\n SELECT\n t.timestamp,\n c.UserId as UserId,\n LIST(DISTINCT p.id) AS PostId\n FROM\n timestamps t\n LEFT JOIN\n posts p\n ON\n p.CreationDate <= t.timestamp\n LEFT JOIN\n comments c\n ON\n p.id = c.PostId AND\n c.CreationDate > t.timestamp AND\n c.CreationDate <= t.timestamp + INTERVAL '{timedelta}'\n WHERE\n c.UserId is not null AND\n p.owneruserid != -1 AND\n p.owneruserid is not null\n GROUP BY\n t.timestamp,\n c.UserId\n "
14
+ manifest_version: 1