Commit b7d24697 authored by escuiller's avatar escuiller

export code+results ok

parent e9dbda51
This diff is collapsed.
......@@ -35,7 +35,7 @@ possibly in a nicer looking way.
We will be using the python3 language using the pandas, statsmodels,
numpy, matplotlib and seaborn libraries.
#+BEGIN_SRC python :session :export both :results output
#+BEGIN_SRC python :session :exports both :results output
def print_imported_modules():
import sys
for name, val in sorted(sys.modules.items()):
......@@ -61,7 +61,7 @@ print_imported_modules()
#+RESULTS:
#+begin_example
3.8.2 | packaged by conda-forge | (default, Apr 16 2020, 18:04:51)
3.8.1 (default, Jan 8 2020, 22:29:32)
[GCC 7.3.0]
uname_result(system='Linux', node='hpisor', release='4.9.0-12-amd64', version='#1 SMP Debian 4.9.210-1 (2020-01-20)', machine='x86_64', processor='')
_csv 1.0
......@@ -73,9 +73,9 @@ ctypes 1.1.0
cycler 0.10.0
dateutil 2.8.1
decimal 1.70
distutils 3.8.2
distutils 3.8.1
json 2.0.9
kiwisolver 1.0.1
kiwisolver 1.2.0
logging 0.5.1.2
matplotlib 3.1.3
matplotlib.backends.backend_agg 3.1.3
......@@ -92,8 +92,8 @@ pandas 1.0.3
patsy 0.5.1
patsy.version 0.5.1
platform 1.0.8
pyparsing 2.4.6
pytz 2019.3
pyparsing 2.4.7
pytz 2020.1
re 2.2.1
scipy 1.4.1
scipy._lib._uarray 0.5.1+5.ga864a57.scipy
......@@ -144,7 +144,7 @@ Let's start by reading data.
Note: url corrected based on forum post at https://www.fun-mooc.fr/courses/course-v1:inria+41016+self-paced/courseware/7bf2267c336246f9b6518db624692e14/96b7ce47bd11466a9a2e63d8e8a93d99/
#+BEGIN_SRC python :session :export both :results value
#+BEGIN_SRC python :session :exports both :results value
data = pd.read_csv("https://app-learninglab.inria.fr/moocrr/gitlab/moocrr-session3/moocrr-reproducibility-study/raw/master/data/shuttle.csv")
data
#+END_SRC
......@@ -181,7 +181,7 @@ data
We know from our previous experience on this data set that filtering
data is a really bad idea. We will therefore process it as such.
#+BEGIN_SRC python :session :export both :results output
#+BEGIN_SRC python :session :exports both :results output
#%matplotlib inline
pd.set_option('mode.chained_assignment',None) # this removes a useless warning from pandas
import matplotlib.pyplot as plt
......@@ -206,7 +206,7 @@ Let's assume O-rings independently fail with the same probability which
solely depends on temperature. A logistic regression should allow us to
estimate the influence of temperature.
#+BEGIN_SRC python :session :export both :results value
#+BEGIN_SRC python :session :exports both :results value
import statsmodels.api as sm
data["Success"]=data.Count-data.Malfunction
......@@ -228,7 +228,7 @@ Model Family: Binomial Df Model: 1
Link Function: logit Scale: 1.0000
Method: IRLS Log-Likelihood: -3.9210
Date: mar., 05 mai 2020 Deviance: 3.0144
Time: 19:13:17 Pearson chi2: 5.00
Time: 22:25:31 Pearson chi2: 5.00
No. Iterations: 6
Covariance Type: nonrobust
===============================================================================
......@@ -252,7 +252,7 @@ for each rocket launch. Let's indicate these weights (since the weights
are always the same throughout all experiments, it does not change the
estimates of the fit but it does influence the variance estimates).
#+BEGIN_SRC python :session :export both :results value
#+BEGIN_SRC python :session :exports both :results value
logmodel=sm.GLM(data['Frequency'], data[['Intercept','Temperature']],
family=sm.families.Binomial(sm.families.links.logit),
var_weights=data['Count']).fit()
......@@ -270,7 +270,7 @@ Model Family: Binomial Df Model: 1
Link Function: logit Scale: 1.0000
Method: IRLS Log-Likelihood: -23.526
Date: mar., 05 mai 2020 Deviance: 18.086
Time: 19:13:17 Pearson chi2: 30.0
Time: 22:25:31 Pearson chi2: 30.0
No. Iterations: 6
Covariance Type: nonrobust
===============================================================================
......@@ -297,7 +297,7 @@ of freedom (Df Residuals).
The temperature when launching the shuttle was 31°F. Let's try to
estimate the failure probability for such temperature using our model.:
#+BEGIN_SRC python :session :results output :export both
#+BEGIN_SRC python :session :results output :exports both
#%matplotlib inline
data_pred = pd.DataFrame({'Temperature': np.linspace(start=30, stop=90, num=121), 'Intercept': 1})
data_pred['Frequency'] = logmodel.predict(data_pred)
......@@ -323,7 +323,7 @@ Following the documentation of
[[https://seaborn.pydata.org/generated/seaborn.regplot.html][Seaborn]],
I use regplot.
#+BEGIN_SRC python :session :results output :export both
#+BEGIN_SRC python :session :results output :exports both
sns.set(color_codes=True)
plt.xlim(30,90)
plt.ylim(0,1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment