Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
moocrr-reproducibility-study
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
moocrr-session1
moocrr-reproducibility-study
Commits
b558b4a1
Commit
b558b4a1
authored
Nov 12, 2018
by
Marie-Gabrielle Dondon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace challenger_Python_org.org
parent
3f341f28
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
challenger_Python_org.org
src/Python3/challenger_Python_org.org
+29
-1
No files found.
src/Python3/challenger_Python_org.org
View file @
b558b4a1
...
...
@@ -90,7 +90,7 @@ logmodel=sm.GLM(data['Frequency'], data[['Intercept','Temperature']],
print(logmodel.summary())
#+end_src
The maximum likelyhood estimator of the intercept and of Temperature
The maximum likelyhood estimator of the intercept and of Temperature
are thus *$\hat{\alpha}$ = 5.0850* and *$\hat{\beta}$ = -0.1156*. This *corresponds*
to the values from the article of Dalal /et al./ The standard errors are
/$s_{\hat{\alpha}}$ = 7.477/ and /$s_{\hat{\beta}}$ = 0.115/, which is *different* from
...
...
@@ -128,6 +128,7 @@ print(logmodel.summary())
%matplotlib inline
data_pred = pd.DataFrame({'Temperature': np.linspace(start=30, stop=90, num=121), 'Intercept': 1})
data_pred['Frequency'] = logmodel.predict(data_pred)
data_pred.plot(x="Temperature",y="Frequency",kind="line",ylim=[0,1])
plt.scatter(x=data["Temperature"],y=data["Frequency"])
plt.grid(True)
...
...
@@ -136,6 +137,33 @@ plt.savefig(matplot_lib_filename)
matplot_lib_filename
#+end_src
#+begin_src python :results output :session :exports both
print(data_pred.head())
#+end_src
La fonction logmodel.predict(=data_pred=) ne fonctionne pas correctement (Frequency = 1 pour toutes les
températures).
On peut alors utiliser le code suivant pour calculer les prédictions
et tracer la courbe :
#+begin_src python :results file :session :var matplot_lib_filename=(org-babel-temp-file "figure" ".png") :exports both
# Inspiring from http://blog.yhat.com/posts/logistic-regression-and-python.html
%matplotlib inline
def logit_inv(x):
return(np.exp(x)/(np.exp(x)+1))
data_pred['Prob']=logit_inv(data_pred['Temperature'] * logmodel.params['Temperature'] + logmodel.params['Intercept'])
print(data_pred.head())
data_pred.plot(x="Temperature",y="Prob",kind="line",ylim=[0,1])
plt.scatter(x=data["Temperature"],y=data["Frequency"])
plt.grid(True)
plt.savefig(matplot_lib_filename)
matplot_lib_filename
#+end_src
This figure is very similar to the Figure 4 of Dalal /et al./ *I have
managed to replicate the Figure 4 of the Dalal /et al./ article.*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment