Switch to unified view

a b/examples/CVTMLE_example.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": 3,
6
   "metadata": {},
7
   "outputs": [],
8
   "source": [
9
    "import sys\n",
10
    "import os\n",
11
    "sys.path.insert(0, '/home/rnshishir/deepmed/TBEHRT_pl/')\n",
12
    "\n",
13
    "import scipy\n",
14
    "import pandas as pd\n",
15
    "import numpy as np\n",
16
    "from src.CV_TMLE import *"
17
   ]
18
  },
19
  {
20
   "cell_type": "markdown",
21
   "metadata": {},
22
   "source": [
23
    "# CV TMLE tutorial"
24
   ]
25
  },
26
  {
27
   "cell_type": "code",
28
   "execution_count": 4,
29
   "metadata": {},
30
   "outputs": [
31
    {
32
     "name": "stdout",
33
     "output_type": "stream",
34
     "text": [
35
      "running CV-TMLE for binary outcomes...\n"
36
     ]
37
    }
38
   ],
39
   "source": [
40
    "# folds in the npz format\n",
41
    "foldNPZ = ['TBEHRT_Test__CUT0.npz', 'TBEHRT_Test__CUT1.npz', 'TBEHRT_Test__CUT2.npz', 'TBEHRT_Test__CUT3.npz', 'TBEHRT_Test__CUT4.npz' ]\n",
42
    "\n",
43
    "# cvtmle runner \n",
44
    "TMLErun = CVTMLE(fromFolds=foldNPZ,truncate_level=0.03 )\n",
45
    "\n",
46
    "# estiamte the risk ratio for binary outcome\n",
47
    "est = TMLErun.run_tmle_binary()"
48
   ]
49
  },
50
  {
51
   "cell_type": "code",
52
   "execution_count": 5,
53
   "metadata": {},
54
   "outputs": [
55
    {
56
     "data": {
57
      "text/plain": [
58
       "[0.10878099048487283, 5.2854239704810925e-08, 223885.61366048577]"
59
      ]
60
     },
61
     "execution_count": 5,
62
     "metadata": {},
63
     "output_type": "execute_result"
64
    }
65
   ],
66
   "source": [
67
    "est\n",
68
    "# prints estimate and lower and upper conf interval bounds"
69
   ]
70
  },
71
  {
72
   "cell_type": "code",
73
   "execution_count": 7,
74
   "metadata": {},
75
   "outputs": [],
76
   "source": [
77
    "data = pd.read_parquet('test.parquet')"
78
   ]
79
  },
80
  {
81
   "cell_type": "code",
82
   "execution_count": 11,
83
   "metadata": {},
84
   "outputs": [],
85
   "source": [
86
    "# raw\n",
87
    "# data[data.explabel ==1].label.mean()/data[data.explabel ==0].label.mean()"
88
   ]
89
  },
90
  {
91
   "cell_type": "code",
92
   "execution_count": null,
93
   "metadata": {},
94
   "outputs": [],
95
   "source": []
96
  }
97
 ],
98
 "metadata": {
99
  "kernelspec": {
100
   "display_name": "real3",
101
   "language": "python",
102
   "name": "py3"
103
  },
104
  "language_info": {
105
   "codemirror_mode": {
106
    "name": "ipython",
107
    "version": 3
108
   },
109
   "file_extension": ".py",
110
   "mimetype": "text/x-python",
111
   "name": "python",
112
   "nbconvert_exporter": "python",
113
   "pygments_lexer": "ipython3",
114
   "version": "3.6.8"
115
  }
116
 },
117
 "nbformat": 4,
118
 "nbformat_minor": 4
119
}