Skip to content

Commit 8b9b0cb

Browse files
committed
[feat] demo for run on lsat dataset
1 parent a3ffc84 commit 8b9b0cb

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"metadata": {
7+
"collapsed": true,
8+
"pycharm": {
9+
"name": "#%%\n"
10+
}
11+
},
12+
"outputs": [],
13+
"source": [
14+
"import pandas as pd\n",
15+
"from pyirt import irt"
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": null,
21+
"outputs": [],
22+
"source": [
23+
"train_df = pd.read_csv(\"../../data/LSAT/train.csv\")\n",
24+
"train_df.head()"
25+
],
26+
"metadata": {
27+
"collapsed": false,
28+
"pycharm": {
29+
"name": "#%%\n"
30+
}
31+
}
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"outputs": [],
37+
"source": [
38+
"item_param, user_param = irt(train_df.values.tolist(), max_iter=10)\n",
39+
"\n",
40+
"item_df = pd.DataFrame.from_dict(item_param, orient=\"index\")\n",
41+
"item_df.reset_index(inplace=True)\n",
42+
"item_df.rename(columns={\"beta\": \"b\", \"alpha\": \"a\", \"index\": \"item_id\"}, inplace=True)\n",
43+
"user_df = pd.DataFrame(list(user_param.items()), columns=[\"user_id\", \"theta\"])"
44+
],
45+
"metadata": {
46+
"collapsed": false,
47+
"pycharm": {
48+
"name": "#%%\n"
49+
}
50+
}
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": null,
55+
"outputs": [],
56+
"source": [
57+
"item_df.describe()\n",
58+
"user_df.describe()"
59+
],
60+
"metadata": {
61+
"collapsed": false,
62+
"pycharm": {
63+
"name": "#%%\n"
64+
}
65+
}
66+
},
67+
{
68+
"cell_type": "code",
69+
"source": [
70+
"test_df = pd.read_csv(\"../../data/LSAT/test.csv\")\n",
71+
"test_df.head()"
72+
],
73+
"metadata": {
74+
"collapsed": false,
75+
"pycharm": {
76+
"name": "#%%\n"
77+
}
78+
},
79+
"execution_count": null,
80+
"outputs": []
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": null,
85+
"outputs": [],
86+
"source": [
87+
"from XCD.IRT.metrics import eval_irt\n",
88+
"eval_irt(test_df, user_df, item_df)"
89+
],
90+
"metadata": {
91+
"collapsed": false,
92+
"pycharm": {
93+
"name": "#%%\n"
94+
}
95+
}
96+
}
97+
],
98+
"metadata": {
99+
"kernelspec": {
100+
"display_name": "Python 3",
101+
"language": "python",
102+
"name": "python3"
103+
},
104+
"language_info": {
105+
"codemirror_mode": {
106+
"name": "ipython",
107+
"version": 2
108+
},
109+
"file_extension": ".py",
110+
"mimetype": "text/x-python",
111+
"name": "python",
112+
"nbconvert_exporter": "python",
113+
"pygments_lexer": "ipython2",
114+
"version": "2.7.6"
115+
}
116+
},
117+
"nbformat": 4,
118+
"nbformat_minor": 0
119+
}

0 commit comments

Comments
 (0)