|
1 | | - "iopub.execute_input": "2025-09-15T15:34:19.318842Z", |
2 | | - "iopub.status.busy": "2025-09-15T15:34:19.318637Z", |
3 | | - "iopub.status.idle": "2025-09-15T15:34:20.745837Z", |
4 | | - "shell.execute_reply": "2025-09-15T15:34:20.745084Z" |
5 | | - "iopub.execute_input": "2025-09-15T15:34:20.749128Z", |
6 | | - "iopub.status.busy": "2025-09-15T15:34:20.748707Z", |
7 | | - "iopub.status.idle": "2025-09-15T15:34:20.982195Z", |
8 | | - "shell.execute_reply": "2025-09-15T15:34:20.981189Z" |
9 | | - "iopub.execute_input": "2025-09-15T15:34:20.984884Z", |
10 | | - "iopub.status.busy": "2025-09-15T15:34:20.984640Z", |
11 | | - "iopub.status.idle": "2025-09-15T15:34:20.994766Z", |
12 | | - "shell.execute_reply": "2025-09-15T15:34:20.994037Z" |
13 | | - "iopub.execute_input": "2025-09-15T15:34:20.997373Z", |
14 | | - "iopub.status.busy": "2025-09-15T15:34:20.997126Z", |
15 | | - "iopub.status.idle": "2025-09-15T15:34:21.261677Z", |
16 | | - "shell.execute_reply": "2025-09-15T15:34:21.260846Z" |
17 | | - "iopub.execute_input": "2025-09-15T15:34:21.264084Z", |
18 | | - "iopub.status.busy": "2025-09-15T15:34:21.263863Z", |
19 | | - "iopub.status.idle": "2025-09-15T15:35:02.849906Z", |
20 | | - "shell.execute_reply": "2025-09-15T15:35:02.849416Z" |
21 | | - "iopub.execute_input": "2025-09-15T15:35:02.853195Z", |
22 | | - "iopub.status.busy": "2025-09-15T15:35:02.852378Z", |
23 | | - "iopub.status.idle": "2025-09-15T15:36:10.481869Z", |
24 | | - "shell.execute_reply": "2025-09-15T15:36:10.480550Z" |
25 | | - "iopub.execute_input": "2025-09-15T15:36:10.485881Z", |
26 | | - "iopub.status.busy": "2025-09-15T15:36:10.485630Z", |
27 | | - "iopub.status.idle": "2025-09-15T15:36:10.534428Z", |
28 | | - "shell.execute_reply": "2025-09-15T15:36:10.532343Z" |
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "b5bb919e", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Бутстрэп без лишних логов\n", |
| 9 | + "Пример оценивания среднего значения." |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "code", |
| 14 | + "execution_count": 1, |
| 15 | + "id": "3ed86886", |
| 16 | + "metadata": { |
| 17 | + "execution": { |
| 18 | + "iopub.execute_input": "2025-09-15T15:48:24.527193Z", |
| 19 | + "iopub.status.busy": "2025-09-15T15:48:24.526756Z", |
| 20 | + "iopub.status.idle": "2025-09-15T15:48:25.373375Z", |
| 21 | + "shell.execute_reply": "2025-09-15T15:48:25.371988Z" |
| 22 | + } |
| 23 | + }, |
| 24 | + "outputs": [ |
| 25 | + { |
| 26 | + "name": "stdout", |
| 27 | + "output_type": "stream", |
| 28 | + "text": [ |
| 29 | + "0.37 0.30306451612903224 0.4595161290322579\n" |
| 30 | + ] |
| 31 | + } |
| 32 | + ], |
| 33 | + "source": [ |
| 34 | + "import numpy as np\n", |
| 35 | + "import pandas as pd\n", |
| 36 | + "from policyscope.bootstrap import cluster_bootstrap_ci\n", |
| 37 | + "\n", |
| 38 | + "rng = np.random.default_rng(0)\n", |
| 39 | + "df = pd.DataFrame({\n", |
| 40 | + " 'user_id': np.arange(100),\n", |
| 41 | + " 'accept': rng.binomial(1, 0.3, size=100),\n", |
| 42 | + "})\n", |
| 43 | + "\n", |
| 44 | + "def estimator(sub):\n", |
| 45 | + " return sub['accept'].mean()\n", |
| 46 | + "\n", |
| 47 | + "theta, low, high = cluster_bootstrap_ci(df, estimator, cluster_col='user_id', n_boot=100, alpha=0.05, rng_seed=1)\n", |
| 48 | + "print(theta, low, high)\n" |
| 49 | + ] |
| 50 | + } |
| 51 | + ], |
| 52 | + "metadata": { |
| 53 | + "language_info": { |
| 54 | + "codemirror_mode": { |
| 55 | + "name": "ipython", |
| 56 | + "version": 3 |
| 57 | + }, |
| 58 | + "file_extension": ".py", |
| 59 | + "mimetype": "text/x-python", |
| 60 | + "name": "python", |
| 61 | + "nbconvert_exporter": "python", |
| 62 | + "pygments_lexer": "ipython3", |
| 63 | + "version": "3.12.10" |
| 64 | + } |
| 65 | + }, |
| 66 | + "nbformat": 4, |
| 67 | + "nbformat_minor": 5 |
| 68 | +} |
0 commit comments