diff --git a/doc/pub/week38/html/._week38-bs000.html b/doc/pub/week38/html/._week38-bs000.html
index 6d00cb4a2..5a7692ec7 100644
--- a/doc/pub/week38/html/._week38-bs000.html
+++ b/doc/pub/week38/html/._week38-bs000.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -176,7 +186,7 @@ MathJax.Hub.Config({
9
10
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs001.html b/doc/pub/week38/html/._week38-bs001.html
index 11627073b..f9048fb47 100644
--- a/doc/pub/week38/html/._week38-bs001.html
+++ b/doc/pub/week38/html/._week38-bs001.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -158,7 +168,7 @@ MathJax.Hub.Config({
10
11
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs002.html b/doc/pub/week38/html/._week38-bs002.html
index 2a7360d9c..263695cc0 100644
--- a/doc/pub/week38/html/._week38-bs002.html
+++ b/doc/pub/week38/html/._week38-bs002.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -166,7 +176,7 @@ simple recipe for fitting our data.
11
12
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs003.html b/doc/pub/week38/html/._week38-bs003.html
index 7a20afd9e..1d6f601ad 100644
--- a/doc/pub/week38/html/._week38-bs003.html
+++ b/doc/pub/week38/html/._week38-bs003.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -172,7 +182,7 @@ failure etc.
12
13
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs004.html b/doc/pub/week38/html/._week38-bs004.html
index 298c19e6e..cb70b668a 100644
--- a/doc/pub/week38/html/._week38-bs004.html
+++ b/doc/pub/week38/html/._week38-bs004.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -171,7 +181,7 @@ models, as we will see later.
13
14
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs005.html b/doc/pub/week38/html/._week38-bs005.html
index 0625d52da..5987788c5 100644
--- a/doc/pub/week38/html/._week38-bs005.html
+++ b/doc/pub/week38/html/._week38-bs005.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -178,7 +188,7 @@ $$
14
15
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs006.html b/doc/pub/week38/html/._week38-bs006.html
index c3742d046..ceaa89664 100644
--- a/doc/pub/week38/html/._week38-bs006.html
+++ b/doc/pub/week38/html/._week38-bs006.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -176,7 +186,7 @@ where \( \hat{y} \) is a vector representing the possible outcomes, \( \hat{X} \
15
16
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs007.html b/doc/pub/week38/html/._week38-bs007.html
index 5c4d49656..c6414f52b 100644
--- a/doc/pub/week38/html/._week38-bs007.html
+++ b/doc/pub/week38/html/._week38-bs007.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -175,7 +185,7 @@ the probability of a given category. This leads us to the logistic function.
16
17
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs008.html b/doc/pub/week38/html/._week38-bs008.html
index 35d593d40..514250305 100644
--- a/doc/pub/week38/html/._week38-bs008.html
+++ b/doc/pub/week38/html/._week38-bs008.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -176,7 +186,7 @@ Note that \( 1-p(t)= p(-t) \).
17
18
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs009.html b/doc/pub/week38/html/._week38-bs009.html
index fbb3a245b..5a99f8674 100644
--- a/doc/pub/week38/html/._week38-bs009.html
+++ b/doc/pub/week38/html/._week38-bs009.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -220,6 +230,8 @@ plt.show()
17
18
19
+ ...
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs010.html b/doc/pub/week38/html/._week38-bs010.html
index 37598fe3a..23eee0202 100644
--- a/doc/pub/week38/html/._week38-bs010.html
+++ b/doc/pub/week38/html/._week38-bs010.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -176,6 +186,9 @@ $$
17
18
19
+ 20
+ ...
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs011.html b/doc/pub/week38/html/._week38-bs011.html
index 16b319b9a..9b25ba49a 100644
--- a/doc/pub/week38/html/._week38-bs011.html
+++ b/doc/pub/week38/html/._week38-bs011.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -176,6 +186,8 @@ $$
17
18
19
+ 20
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs012.html b/doc/pub/week38/html/._week38-bs012.html
index cadf8fee8..e29e39927 100644
--- a/doc/pub/week38/html/._week38-bs012.html
+++ b/doc/pub/week38/html/._week38-bs012.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -173,6 +183,8 @@ in practice we often supplement the cross-entropy with additional regularization
17
18
19
+ 20
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs013.html b/doc/pub/week38/html/._week38-bs013.html
index abe1ad6a1..5bea6dae7 100644
--- a/doc/pub/week38/html/._week38-bs013.html
+++ b/doc/pub/week38/html/._week38-bs013.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -173,6 +183,8 @@ $$
17
18
19
+ 20
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs014.html b/doc/pub/week38/html/._week38-bs014.html
index eb7603a2b..21ebd89b7 100644
--- a/doc/pub/week38/html/._week38-bs014.html
+++ b/doc/pub/week38/html/._week38-bs014.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -173,6 +183,8 @@ $$
17
18
19
+ 20
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs015.html b/doc/pub/week38/html/._week38-bs015.html
index 89c9ea022..90ac81e95 100644
--- a/doc/pub/week38/html/._week38-bs015.html
+++ b/doc/pub/week38/html/._week38-bs015.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -165,6 +175,8 @@ $$
17
18
19
+ 20
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs016.html b/doc/pub/week38/html/._week38-bs016.html
index 9b51accbd..5885f44ce 100644
--- a/doc/pub/week38/html/._week38-bs016.html
+++ b/doc/pub/week38/html/._week38-bs016.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -176,6 +186,8 @@ and the model is specified in term of \( K-1 \) so-called log-odds or
17
18
19
+ 20
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs017.html b/doc/pub/week38/html/._week38-bs017.html
index c025008c3..36787b4f4 100644
--- a/doc/pub/week38/html/._week38-bs017.html
+++ b/doc/pub/week38/html/._week38-bs017.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -187,6 +197,8 @@ methods.
17
18
19
+ 20
+ 21
»
diff --git a/doc/pub/week38/html/._week38-bs018.html b/doc/pub/week38/html/._week38-bs018.html
index 955b2c7e7..3cf117d6f 100644
--- a/doc/pub/week38/html/._week38-bs018.html
+++ b/doc/pub/week38/html/._week38-bs018.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -183,7 +193,6 @@ MathJax.Hub.Config({
main()
-
diff --git a/doc/pub/week38/html/._week38-bs019.html b/doc/pub/week38/html/._week38-bs019.html
new file mode 100644
index 000000000..20f4767f5
--- /dev/null
+++ b/doc/pub/week38/html/._week38-bs019.html
@@ -0,0 +1,217 @@
+
+
+
+
+
+
+
+
+Data Analysis and Machine Learning: Logistic Regression
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Cancer Data again now with Decision Trees and other Methods
+
+
+
+
import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import load_breast_cancer
+from sklearn.linear_model import LogisticRegression
+
+# Load the data
+cancer = load_breast_cancer()
+
+X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
+print(X_train.shape)
+print(X_test.shape)
+# Logistic Regression
+logreg = LogisticRegression(solver='lbfgs')
+logreg.fit(X_train, y_train)
+print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
+#now scale the data
+from sklearn.preprocessing import StandardScaler
+scaler = StandardScaler()
+scaler.fit(X_train)
+X_train_scaled = scaler.transform(X_train)
+X_test_scaled = scaler.transform(X_test)
+# Logistic Regression
+logreg.fit(X_train_scaled, y_train)
+print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/pub/week38/html/._week38-bs020.html b/doc/pub/week38/html/._week38-bs020.html
new file mode 100644
index 000000000..5df1745ca
--- /dev/null
+++ b/doc/pub/week38/html/._week38-bs020.html
@@ -0,0 +1,235 @@
+
+
+
+
+
+
+
+
+Data Analysis and Machine Learning: Logistic Regression
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Other measures in classification studies: Cancer Data again
+
+
+
+
import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import load_breast_cancer
+from sklearn.linear_model import LogisticRegression
+
+# Load the data
+cancer = load_breast_cancer()
+
+X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
+print(X_train.shape)
+print(X_test.shape)
+# Logistic Regression
+logreg = LogisticRegression(solver='lbfgs')
+logreg.fit(X_train, y_train)
+print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
+#now scale the data
+from sklearn.preprocessing import StandardScaler
+scaler = StandardScaler()
+scaler.fit(X_train)
+X_train_scaled = scaler.transform(X_train)
+X_test_scaled = scaler.transform(X_test)
+# Logistic Regression
+logreg.fit(X_train_scaled, y_train)
+print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+from sklearn.preprocessing import LabelEncoder
+from sklearn.model_selection import cross_validate
+#Cross validation
+accuracy = cross_validate(logreg,X_test_scaled,y_test,cv=10)['test_score']
+print(accuracy)
+print("Test set accuracy with Logistic Regression and scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+import scikitplot as skplt
+y_pred = logreg.predict(X_test_scaled)
+skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
+plt.show()
+y_probas = logreg.predict_proba(X_test_scaled)
+skplt.metrics.plot_roc(y_test, y_probas)
+plt.show()
+skplt.metrics.plot_cumulative_gain(y_test, y_probas)
+plt.show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/pub/week38/html/week38-bs.html b/doc/pub/week38/html/week38-bs.html
index 6d00cb4a2..5a7692ec7 100644
--- a/doc/pub/week38/html/week38-bs.html
+++ b/doc/pub/week38/html/week38-bs.html
@@ -62,7 +62,15 @@ Automatically generated HTML file from DocOnce source
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
Including more classes
More classes
A simple classification problem
+ Cancer Data again now with Decision Trees and other Methods
+ Other measures in classification studies: Cancer Data again
@@ -176,7 +186,7 @@ MathJax.Hub.Config({
9
10
...
- 19
+ 21
»
diff --git a/doc/pub/week38/html/week38-reveal.html b/doc/pub/week38/html/week38-reveal.html
index cc3db2e84..04a81430a 100644
--- a/doc/pub/week38/html/week38-reveal.html
+++ b/doc/pub/week38/html/week38-reveal.html
@@ -682,6 +682,93 @@ methods.
+
+Cancer Data again now with Decision Trees and other Methods
+
+
+
+
import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import load_breast_cancer
+from sklearn.linear_model import LogisticRegression
+
+# Load the data
+cancer = load_breast_cancer()
+
+X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
+print(X_train.shape)
+print(X_test.shape)
+# Logistic Regression
+logreg = LogisticRegression(solver='lbfgs')
+logreg.fit(X_train, y_train)
+print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
+#now scale the data
+from sklearn.preprocessing import StandardScaler
+scaler = StandardScaler()
+scaler.fit(X_train)
+X_train_scaled = scaler.transform(X_train)
+X_test_scaled = scaler.transform(X_test)
+# Logistic Regression
+logreg.fit(X_train_scaled, y_train)
+print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+
+
+
+Other measures in classification studies: Cancer Data again
+
+
+
+
import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import load_breast_cancer
+from sklearn.linear_model import LogisticRegression
+
+# Load the data
+cancer = load_breast_cancer()
+
+X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
+print(X_train.shape)
+print(X_test.shape)
+# Logistic Regression
+logreg = LogisticRegression(solver='lbfgs')
+logreg.fit(X_train, y_train)
+print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
+#now scale the data
+from sklearn.preprocessing import StandardScaler
+scaler = StandardScaler()
+scaler.fit(X_train)
+X_train_scaled = scaler.transform(X_train)
+X_test_scaled = scaler.transform(X_test)
+# Logistic Regression
+logreg.fit(X_train_scaled, y_train)
+print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+from sklearn.preprocessing import LabelEncoder
+from sklearn.model_selection import cross_validate
+#Cross validation
+accuracy = cross_validate(logreg,X_test_scaled,y_test,cv=10)['test_score']
+print(accuracy)
+print("Test set accuracy with Logistic Regression and scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+import scikitplot as skplt
+y_pred = logreg.predict(X_test_scaled)
+skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
+plt.show()
+y_probas = logreg.predict_proba(X_test_scaled)
+skplt.metrics.plot_roc(y_test, y_probas)
+plt.show()
+skplt.metrics.plot_cumulative_gain(y_test, y_probas)
+plt.show()
+
+
+
+
diff --git a/doc/pub/week38/html/week38-solarized.html b/doc/pub/week38/html/week38-solarized.html
index b0cebc0bb..a21c3811f 100644
--- a/doc/pub/week38/html/week38-solarized.html
+++ b/doc/pub/week38/html/week38-solarized.html
@@ -56,7 +56,15 @@ div { text-align: justify; text-justify: inter-word; }
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -582,6 +590,91 @@ methods.
main()
+
+
+
Cancer Data again now with Decision Trees and other Methods
+
+
+
+
import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import load_breast_cancer
+from sklearn.linear_model import LogisticRegression
+
+# Load the data
+cancer = load_breast_cancer()
+
+X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
+print(X_train.shape)
+print(X_test.shape)
+# Logistic Regression
+logreg = LogisticRegression(solver='lbfgs')
+logreg.fit(X_train, y_train)
+print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
+#now scale the data
+from sklearn.preprocessing import StandardScaler
+scaler = StandardScaler()
+scaler.fit(X_train)
+X_train_scaled = scaler.transform(X_train)
+X_test_scaled = scaler.transform(X_test)
+# Logistic Regression
+logreg.fit(X_train_scaled, y_train)
+print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+
+
+
Other measures in classification studies: Cancer Data again
+
+
+
+
import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import load_breast_cancer
+from sklearn.linear_model import LogisticRegression
+
+# Load the data
+cancer = load_breast_cancer()
+
+X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
+print(X_train.shape)
+print(X_test.shape)
+# Logistic Regression
+logreg = LogisticRegression(solver='lbfgs')
+logreg.fit(X_train, y_train)
+print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
+#now scale the data
+from sklearn.preprocessing import StandardScaler
+scaler = StandardScaler()
+scaler.fit(X_train)
+X_train_scaled = scaler.transform(X_train)
+X_test_scaled = scaler.transform(X_test)
+# Logistic Regression
+logreg.fit(X_train_scaled, y_train)
+print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+from sklearn.preprocessing import LabelEncoder
+from sklearn.model_selection import cross_validate
+#Cross validation
+accuracy = cross_validate(logreg,X_test_scaled,y_test,cv=10)['test_score']
+print(accuracy)
+print("Test set accuracy with Logistic Regression and scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+import scikitplot as skplt
+y_pred = logreg.predict(X_test_scaled)
+skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
+plt.show()
+y_probas = logreg.predict_proba(X_test_scaled)
+skplt.metrics.plot_roc(y_test, y_probas)
+plt.show()
+skplt.metrics.plot_cumulative_gain(y_test, y_probas)
+plt.show()
+
+
diff --git a/doc/pub/week38/html/week38.html b/doc/pub/week38/html/week38.html
index faa233a10..0ae1d126a 100644
--- a/doc/pub/week38/html/week38.html
+++ b/doc/pub/week38/html/week38.html
@@ -61,7 +61,15 @@ div { text-align: justify; text-justify: inter-word; }
('Extending to more predictors', 2, None, '___sec14'),
('Including more classes', 2, None, '___sec15'),
('More classes', 2, None, '___sec16'),
- ('A simple classification problem', 2, None, '___sec17')]}
+ ('A simple classification problem', 2, None, '___sec17'),
+ ('Cancer Data again now with Decision Trees and other Methods',
+ 2,
+ None,
+ '___sec18'),
+ ('Other measures in classification studies: Cancer Data again',
+ 2,
+ None,
+ '___sec19')]}
end of tocinfo -->
@@ -587,6 +595,91 @@ methods.
main()
+
+
+
Cancer Data again now with Decision Trees and other Methods
+
+
+
+
import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import load_breast_cancer
+from sklearn.linear_model import LogisticRegression
+
+# Load the data
+cancer = load_breast_cancer()
+
+X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
+print(X_train.shape)
+print(X_test.shape)
+# Logistic Regression
+logreg = LogisticRegression(solver='lbfgs')
+logreg.fit(X_train, y_train)
+print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
+#now scale the data
+from sklearn.preprocessing import StandardScaler
+scaler = StandardScaler()
+scaler.fit(X_train)
+X_train_scaled = scaler.transform(X_train)
+X_test_scaled = scaler.transform(X_test)
+# Logistic Regression
+logreg.fit(X_train_scaled, y_train)
+print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+
+
+
Other measures in classification studies: Cancer Data again
+
+
+
+
import matplotlib.pyplot as plt
+import numpy as np
+from sklearn.model_selection import train_test_split
+from sklearn.datasets import load_breast_cancer
+from sklearn.linear_model import LogisticRegression
+
+# Load the data
+cancer = load_breast_cancer()
+
+X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
+print(X_train.shape)
+print(X_test.shape)
+# Logistic Regression
+logreg = LogisticRegression(solver='lbfgs')
+logreg.fit(X_train, y_train)
+print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
+#now scale the data
+from sklearn.preprocessing import StandardScaler
+scaler = StandardScaler()
+scaler.fit(X_train)
+X_train_scaled = scaler.transform(X_train)
+X_test_scaled = scaler.transform(X_test)
+# Logistic Regression
+logreg.fit(X_train_scaled, y_train)
+print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+from sklearn.preprocessing import LabelEncoder
+from sklearn.model_selection import cross_validate
+#Cross validation
+accuracy = cross_validate(logreg,X_test_scaled,y_test,cv=10)['test_score']
+print(accuracy)
+print("Test set accuracy with Logistic Regression and scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
+
+
+import scikitplot as skplt
+y_pred = logreg.predict(X_test_scaled)
+skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
+plt.show()
+y_probas = logreg.predict_proba(X_test_scaled)
+skplt.metrics.plot_roc(y_test, y_probas)
+plt.show()
+skplt.metrics.plot_cumulative_gain(y_test, y_probas)
+plt.show()
+
+
diff --git a/doc/pub/week38/ipynb/ipynb-week38-src.tar.gz b/doc/pub/week38/ipynb/ipynb-week38-src.tar.gz
index b704baad8..8f0c907b2 100644
Binary files a/doc/pub/week38/ipynb/ipynb-week38-src.tar.gz and b/doc/pub/week38/ipynb/ipynb-week38-src.tar.gz differ
diff --git a/doc/pub/week38/ipynb/week38.ipynb b/doc/pub/week38/ipynb/week38.ipynb
index 624f17304..a45db93d6 100644
--- a/doc/pub/week38/ipynb/week38.ipynb
+++ b/doc/pub/week38/ipynb/week38.ipynb
@@ -675,6 +675,109 @@
"if __name__ == \"__main__\":\n",
" main()"
]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Cancer Data again now with Decision Trees and other Methods"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "import matplotlib.pyplot as plt\n",
+ "import numpy as np\n",
+ "from sklearn.model_selection import train_test_split \n",
+ "from sklearn.datasets import load_breast_cancer\n",
+ "from sklearn.linear_model import LogisticRegression\n",
+ "\n",
+ "# Load the data\n",
+ "cancer = load_breast_cancer()\n",
+ "\n",
+ "X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)\n",
+ "print(X_train.shape)\n",
+ "print(X_test.shape)\n",
+ "# Logistic Regression\n",
+ "logreg = LogisticRegression(solver='lbfgs')\n",
+ "logreg.fit(X_train, y_train)\n",
+ "print(\"Test set accuracy with Logistic Regression: {:.2f}\".format(logreg.score(X_test,y_test)))\n",
+ "#now scale the data\n",
+ "from sklearn.preprocessing import StandardScaler\n",
+ "scaler = StandardScaler()\n",
+ "scaler.fit(X_train)\n",
+ "X_train_scaled = scaler.transform(X_train)\n",
+ "X_test_scaled = scaler.transform(X_test)\n",
+ "# Logistic Regression\n",
+ "logreg.fit(X_train_scaled, y_train)\n",
+ "print(\"Test set accuracy Logistic Regression with scaled data: {:.2f}\".format(logreg.score(X_test_scaled,y_test)))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Other measures in classification studies: Cancer Data again"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "import matplotlib.pyplot as plt\n",
+ "import numpy as np\n",
+ "from sklearn.model_selection import train_test_split \n",
+ "from sklearn.datasets import load_breast_cancer\n",
+ "from sklearn.linear_model import LogisticRegression\n",
+ "\n",
+ "# Load the data\n",
+ "cancer = load_breast_cancer()\n",
+ "\n",
+ "X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)\n",
+ "print(X_train.shape)\n",
+ "print(X_test.shape)\n",
+ "# Logistic Regression\n",
+ "logreg = LogisticRegression(solver='lbfgs')\n",
+ "logreg.fit(X_train, y_train)\n",
+ "print(\"Test set accuracy with Logistic Regression: {:.2f}\".format(logreg.score(X_test,y_test)))\n",
+ "#now scale the data\n",
+ "from sklearn.preprocessing import StandardScaler\n",
+ "scaler = StandardScaler()\n",
+ "scaler.fit(X_train)\n",
+ "X_train_scaled = scaler.transform(X_train)\n",
+ "X_test_scaled = scaler.transform(X_test)\n",
+ "# Logistic Regression\n",
+ "logreg.fit(X_train_scaled, y_train)\n",
+ "print(\"Test set accuracy Logistic Regression with scaled data: {:.2f}\".format(logreg.score(X_test_scaled,y_test)))\n",
+ "\n",
+ "\n",
+ "from sklearn.preprocessing import LabelEncoder\n",
+ "from sklearn.model_selection import cross_validate\n",
+ "#Cross validation\n",
+ "accuracy = cross_validate(logreg,X_test_scaled,y_test,cv=10)['test_score']\n",
+ "print(accuracy)\n",
+ "print(\"Test set accuracy with Logistic Regression and scaled data: {:.2f}\".format(logreg.score(X_test_scaled,y_test)))\n",
+ "\n",
+ "\n",
+ "import scikitplot as skplt\n",
+ "y_pred = logreg.predict(X_test_scaled)\n",
+ "skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)\n",
+ "plt.show()\n",
+ "y_probas = logreg.predict_proba(X_test_scaled)\n",
+ "skplt.metrics.plot_roc(y_test, y_probas)\n",
+ "plt.show()\n",
+ "skplt.metrics.plot_cumulative_gain(y_test, y_probas)\n",
+ "plt.show()"
+ ]
}
],
"metadata": {},