Skip to content

Commit 6eca1a4

Browse files
committed
Polish quickstart adapter validation and propensity caveat
1 parent 1286cd1 commit 6eca1a4

1 file changed

Lines changed: 35 additions & 27 deletions

File tree

examples/quickstart_own_data_ru.ipynb

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
"id": "a7dc85d4",
2727
"metadata": {
2828
"execution": {
29-
"iopub.execute_input": "2026-04-15T11:48:46.950173Z",
30-
"iopub.status.busy": "2026-04-15T11:48:46.949455Z",
31-
"iopub.status.idle": "2026-04-15T11:48:51.464433Z",
32-
"shell.execute_reply": "2026-04-15T11:48:51.461888Z"
29+
"iopub.execute_input": "2026-04-15T12:51:31.970528Z",
30+
"iopub.status.busy": "2026-04-15T12:51:31.970334Z",
31+
"iopub.status.idle": "2026-04-15T12:51:33.760421Z",
32+
"shell.execute_reply": "2026-04-15T12:51:33.759220Z"
3333
}
3434
},
3535
"outputs": [],
@@ -77,10 +77,10 @@
7777
"id": "34eb1d72",
7878
"metadata": {
7979
"execution": {
80-
"iopub.execute_input": "2026-04-15T11:48:51.473375Z",
81-
"iopub.status.busy": "2026-04-15T11:48:51.472289Z",
82-
"iopub.status.idle": "2026-04-15T11:48:51.528923Z",
83-
"shell.execute_reply": "2026-04-15T11:48:51.526616Z"
80+
"iopub.execute_input": "2026-04-15T12:51:33.763410Z",
81+
"iopub.status.busy": "2026-04-15T12:51:33.763012Z",
82+
"iopub.status.idle": "2026-04-15T12:51:33.787338Z",
83+
"shell.execute_reply": "2026-04-15T12:51:33.786535Z"
8484
}
8585
},
8686
"outputs": [
@@ -184,6 +184,10 @@
184184
"df['accept'] = np.random.binomial(1, p)\n",
185185
"\n",
186186
"# Если у вас есть logged propensity, храните её в отдельной колонке\n",
187+
"# Важно: в реальных данных propensity_A должна логироваться исторической policy A,\n",
188+
"# а не придумываться вручную как в этом synthetic-демо.\n",
189+
"# Если истинная logged propensity недоступна, используйте propensity_source='estimated'\n",
190+
"# (или auto fallback) и интерпретируйте результат осторожнее.\n",
187191
"df['propensity_A'] = np.random.uniform(0.05, 0.95, size=n)\n",
188192
"\n",
189193
"# Шаг 1: формализуем контракт данных\n",
@@ -222,10 +226,10 @@
222226
"id": "2b792b2f",
223227
"metadata": {
224228
"execution": {
225-
"iopub.execute_input": "2026-04-15T11:48:51.534425Z",
226-
"iopub.status.busy": "2026-04-15T11:48:51.533667Z",
227-
"iopub.status.idle": "2026-04-15T11:49:06.388899Z",
228-
"shell.execute_reply": "2026-04-15T11:49:06.386732Z"
229+
"iopub.execute_input": "2026-04-15T12:51:33.789745Z",
230+
"iopub.status.busy": "2026-04-15T12:51:33.789542Z",
231+
"iopub.status.idle": "2026-04-15T12:51:38.519607Z",
232+
"shell.execute_reply": "2026-04-15T12:51:38.518761Z"
229233
}
230234
},
231235
"outputs": [
@@ -254,11 +258,15 @@
254258
"\n",
255259
" def action_probs(self, x: pd.DataFrame) -> np.ndarray:\n",
256260
" a = x[self.action_col].to_numpy()\n",
261+
" unknown = sorted({act for act in np.unique(a) if act not in self._idx})\n",
262+
" if unknown:\n",
263+
" raise ValueError(\n",
264+
" f\"Unknown actions in column '{self.action_col}': {unknown}. \"\n",
265+
" f\"Known action_space: {self.action_space}\"\n",
266+
" )\n",
257267
" probs = np.zeros((len(x), len(self.action_space)), dtype=float)\n",
258268
" for i, act in enumerate(a):\n",
259-
" j = self._idx.get(act)\n",
260-
" if j is not None:\n",
261-
" probs[i, j] = 1.0\n",
269+
" probs[i, self._idx[act]] = 1.0\n",
262270
" return probs\n",
263271
"\n",
264272
"# Мини-демо: эмулируем колонку action_B и сравнение через compare_policies\n",
@@ -313,10 +321,10 @@
313321
"id": "540f2f9b",
314322
"metadata": {
315323
"execution": {
316-
"iopub.execute_input": "2026-04-15T11:49:06.400372Z",
317-
"iopub.status.busy": "2026-04-15T11:49:06.399109Z",
318-
"iopub.status.idle": "2026-04-15T11:49:06.412147Z",
319-
"shell.execute_reply": "2026-04-15T11:49:06.409880Z"
324+
"iopub.execute_input": "2026-04-15T12:51:38.526806Z",
325+
"iopub.status.busy": "2026-04-15T12:51:38.526452Z",
326+
"iopub.status.idle": "2026-04-15T12:51:38.534354Z",
327+
"shell.execute_reply": "2026-04-15T12:51:38.532784Z"
320328
}
321329
},
322330
"outputs": [],
@@ -351,10 +359,10 @@
351359
"id": "7c240d61",
352360
"metadata": {
353361
"execution": {
354-
"iopub.execute_input": "2026-04-15T11:49:06.417844Z",
355-
"iopub.status.busy": "2026-04-15T11:49:06.417305Z",
356-
"iopub.status.idle": "2026-04-15T11:49:36.897842Z",
357-
"shell.execute_reply": "2026-04-15T11:49:36.893050Z"
362+
"iopub.execute_input": "2026-04-15T12:51:38.536240Z",
363+
"iopub.status.busy": "2026-04-15T12:51:38.536072Z",
364+
"iopub.status.idle": "2026-04-15T12:51:48.413851Z",
365+
"shell.execute_reply": "2026-04-15T12:51:48.411129Z"
358366
}
359367
},
360368
"outputs": [
@@ -421,10 +429,10 @@
421429
"id": "1fd6d1d4",
422430
"metadata": {
423431
"execution": {
424-
"iopub.execute_input": "2026-04-15T11:49:36.904965Z",
425-
"iopub.status.busy": "2026-04-15T11:49:36.904343Z",
426-
"iopub.status.idle": "2026-04-15T11:50:20.869170Z",
427-
"shell.execute_reply": "2026-04-15T11:50:20.865727Z"
432+
"iopub.execute_input": "2026-04-15T12:51:48.416283Z",
433+
"iopub.status.busy": "2026-04-15T12:51:48.415590Z",
434+
"iopub.status.idle": "2026-04-15T12:52:02.311901Z",
435+
"shell.execute_reply": "2026-04-15T12:52:02.309828Z"
428436
}
429437
},
430438
"outputs": [

0 commit comments

Comments
 (0)