added slides for week38
This commit is contained in:
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -176,7 +186,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week38-bs008.html">9</a></li>
|
||||
<li><a href="._week38-bs009.html">10</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -158,7 +168,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week38-bs009.html">10</a></li>
|
||||
<li><a href="._week38-bs010.html">11</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs002.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -166,7 +176,7 @@ simple recipe for fitting our data.
|
||||
<li><a href="._week38-bs010.html">11</a></li>
|
||||
<li><a href="._week38-bs011.html">12</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs003.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -172,7 +182,7 @@ failure etc.
|
||||
<li><a href="._week38-bs011.html">12</a></li>
|
||||
<li><a href="._week38-bs012.html">13</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs004.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -171,7 +181,7 @@ models, as we will see later.
|
||||
<li><a href="._week38-bs012.html">13</a></li>
|
||||
<li><a href="._week38-bs013.html">14</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs005.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -178,7 +188,7 @@ $$
|
||||
<li><a href="._week38-bs013.html">14</a></li>
|
||||
<li><a href="._week38-bs014.html">15</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs006.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -176,7 +186,7 @@ where \( \hat{y} \) is a vector representing the possible outcomes, \( \hat{X} \
|
||||
<li><a href="._week38-bs014.html">15</a></li>
|
||||
<li><a href="._week38-bs015.html">16</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs007.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -175,7 +185,7 @@ the probability of a given category. This leads us to the logistic function.
|
||||
<li><a href="._week38-bs015.html">16</a></li>
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs008.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -176,7 +186,7 @@ Note that \( 1-p(t)= p(-t) \).
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs009.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -220,6 +230,8 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs010.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -176,6 +186,9 @@ $$
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs011.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -176,6 +186,8 @@ $$
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs012.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -173,6 +183,8 @@ in practice we often supplement the cross-entropy with additional regularization
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs013.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -173,6 +183,8 @@ $$
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs014.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -173,6 +183,8 @@ $$
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs015.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -165,6 +175,8 @@ $$
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs016.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -176,6 +186,8 @@ and the model is specified in term of \( K-1 \) so-called log-odds or
|
||||
<li class="active"><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs017.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -187,6 +197,8 @@ methods</a>.
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li class="active"><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs018.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -183,7 +193,6 @@ MathJax.Hub.Config({
|
||||
main()
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -199,6 +208,9 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li class="active"><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs019.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
(https://github.com/hplgit/doconce/)
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="DocOnce: https://github.com/hplgit/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Data Analysis and Machine Learning: Logistic Regression">
|
||||
|
||||
<title>Data Analysis and Machine Learning: Logistic Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
content:"";
|
||||
display:block;
|
||||
height:50px; /* fixed header height for style bootstrap */
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
{'highest level': 2,
|
||||
'sections': [('To do for log reg', 2, None, '___sec0'),
|
||||
('Logistic Regression', 2, None, '___sec1'),
|
||||
('Classification problems', 2, None, '___sec2'),
|
||||
('Optimization and Deep learning', 2, None, '___sec3'),
|
||||
('Basics', 2, None, '___sec4'),
|
||||
('Linear classifier', 2, None, '___sec5'),
|
||||
('Some selected properties', 2, None, '___sec6'),
|
||||
('The logistic function', 2, None, '___sec7'),
|
||||
('Examples of likelihood functions used in logistic regression '
|
||||
'and nueral networks',
|
||||
2,
|
||||
None,
|
||||
'___sec8'),
|
||||
('Two parameters', 2, None, '___sec9'),
|
||||
('Maximum likelihood', 2, None, '___sec10'),
|
||||
('The cost function rewritten', 2, None, '___sec11'),
|
||||
('Minimizing the cross entropy', 2, None, '___sec12'),
|
||||
('A more compact expression', 2, None, '___sec13'),
|
||||
('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'),
|
||||
('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 -->
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
TeX: {
|
||||
equationNumbers: { autoNumber: "none" },
|
||||
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" async
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="week38-bs.html">Data Analysis and Machine Learning: Logistic Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contents <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs001.html#___sec0" style="font-size: 80%;">To do for log reg</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs002.html#___sec1" style="font-size: 80%;">Logistic Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs003.html#___sec2" style="font-size: 80%;">Classification problems</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs004.html#___sec3" style="font-size: 80%;">Optimization and Deep learning</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs005.html#___sec4" style="font-size: 80%;">Basics</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs006.html#___sec5" style="font-size: 80%;">Linear classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs007.html#___sec6" style="font-size: 80%;">Some selected properties</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs008.html#___sec7" style="font-size: 80%;">The logistic function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs009.html#___sec8" style="font-size: 80%;">Examples of likelihood functions used in logistic regression and nueral networks</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs010.html#___sec9" style="font-size: 80%;">Two parameters</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs011.html#___sec10" style="font-size: 80%;">Maximum likelihood</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs012.html#___sec11" style="font-size: 80%;">The cost function rewritten</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs013.html#___sec12" style="font-size: 80%;">Minimizing the cross entropy</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs014.html#___sec13" style="font-size: 80%;">A more compact expression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs015.html#___sec14" style="font-size: 80%;">Extending to more predictors</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0019"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec18" class="anchor">Cancer Data again now with Decision Trees and other Methods </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> load_breast_cancer
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LogisticRegression
|
||||
|
||||
<span style="color: #408080; font-style: italic"># Load the data</span>
|
||||
cancer <span style="color: #666666">=</span> load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test <span style="color: #666666">=</span> train_test_split(cancer<span style="color: #666666">.</span>data,cancer<span style="color: #666666">.</span>target,random_state<span style="color: #666666">=0</span>)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(X_train<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(X_test<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #408080; font-style: italic"># Logistic Regression</span>
|
||||
logreg <span style="color: #666666">=</span> LogisticRegression(solver<span style="color: #666666">=</span><span style="color: #BA2121">'lbfgs'</span>)
|
||||
logreg<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy with Logistic Regression: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test,y_test)))
|
||||
<span style="color: #408080; font-style: italic">#now scale the data</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> StandardScaler
|
||||
scaler <span style="color: #666666">=</span> StandardScaler()
|
||||
scaler<span style="color: #666666">.</span>fit(X_train)
|
||||
X_train_scaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X_train)
|
||||
X_test_scaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X_test)
|
||||
<span style="color: #408080; font-style: italic"># Logistic Regression</span>
|
||||
logreg<span style="color: #666666">.</span>fit(X_train_scaled, y_train)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy Logistic Regression with scaled data: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
</pre></div>
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
<li><a href="._week38-bs018.html">«</a></li>
|
||||
<li><a href="._week38-bs000.html">1</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs011.html">12</a></li>
|
||||
<li><a href="._week38-bs012.html">13</a></li>
|
||||
<li><a href="._week38-bs013.html">14</a></li>
|
||||
<li><a href="._week38-bs014.html">15</a></li>
|
||||
<li><a href="._week38-bs015.html">16</a></li>
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li class="active"><a href="._week38-bs019.html">20</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs020.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="http://..."><img width="250" align=right src="http://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
(https://github.com/hplgit/doconce/)
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="DocOnce: https://github.com/hplgit/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Data Analysis and Machine Learning: Logistic Regression">
|
||||
|
||||
<title>Data Analysis and Machine Learning: Logistic Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
content:"";
|
||||
display:block;
|
||||
height:50px; /* fixed header height for style bootstrap */
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
{'highest level': 2,
|
||||
'sections': [('To do for log reg', 2, None, '___sec0'),
|
||||
('Logistic Regression', 2, None, '___sec1'),
|
||||
('Classification problems', 2, None, '___sec2'),
|
||||
('Optimization and Deep learning', 2, None, '___sec3'),
|
||||
('Basics', 2, None, '___sec4'),
|
||||
('Linear classifier', 2, None, '___sec5'),
|
||||
('Some selected properties', 2, None, '___sec6'),
|
||||
('The logistic function', 2, None, '___sec7'),
|
||||
('Examples of likelihood functions used in logistic regression '
|
||||
'and nueral networks',
|
||||
2,
|
||||
None,
|
||||
'___sec8'),
|
||||
('Two parameters', 2, None, '___sec9'),
|
||||
('Maximum likelihood', 2, None, '___sec10'),
|
||||
('The cost function rewritten', 2, None, '___sec11'),
|
||||
('Minimizing the cross entropy', 2, None, '___sec12'),
|
||||
('A more compact expression', 2, None, '___sec13'),
|
||||
('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'),
|
||||
('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 -->
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
TeX: {
|
||||
equationNumbers: { autoNumber: "none" },
|
||||
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" async
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="week38-bs.html">Data Analysis and Machine Learning: Logistic Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contents <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs001.html#___sec0" style="font-size: 80%;">To do for log reg</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs002.html#___sec1" style="font-size: 80%;">Logistic Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs003.html#___sec2" style="font-size: 80%;">Classification problems</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs004.html#___sec3" style="font-size: 80%;">Optimization and Deep learning</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs005.html#___sec4" style="font-size: 80%;">Basics</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs006.html#___sec5" style="font-size: 80%;">Linear classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs007.html#___sec6" style="font-size: 80%;">Some selected properties</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs008.html#___sec7" style="font-size: 80%;">The logistic function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs009.html#___sec8" style="font-size: 80%;">Examples of likelihood functions used in logistic regression and nueral networks</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs010.html#___sec9" style="font-size: 80%;">Two parameters</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs011.html#___sec10" style="font-size: 80%;">Maximum likelihood</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs012.html#___sec11" style="font-size: 80%;">The cost function rewritten</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs013.html#___sec12" style="font-size: 80%;">Minimizing the cross entropy</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs014.html#___sec13" style="font-size: 80%;">A more compact expression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs015.html#___sec14" style="font-size: 80%;">Extending to more predictors</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0020"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec19" class="anchor">Other measures in classification studies: Cancer Data again </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> load_breast_cancer
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LogisticRegression
|
||||
|
||||
<span style="color: #408080; font-style: italic"># Load the data</span>
|
||||
cancer <span style="color: #666666">=</span> load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test <span style="color: #666666">=</span> train_test_split(cancer<span style="color: #666666">.</span>data,cancer<span style="color: #666666">.</span>target,random_state<span style="color: #666666">=0</span>)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(X_train<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(X_test<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #408080; font-style: italic"># Logistic Regression</span>
|
||||
logreg <span style="color: #666666">=</span> LogisticRegression(solver<span style="color: #666666">=</span><span style="color: #BA2121">'lbfgs'</span>)
|
||||
logreg<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy with Logistic Regression: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test,y_test)))
|
||||
<span style="color: #408080; font-style: italic">#now scale the data</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> StandardScaler
|
||||
scaler <span style="color: #666666">=</span> StandardScaler()
|
||||
scaler<span style="color: #666666">.</span>fit(X_train)
|
||||
X_train_scaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X_train)
|
||||
X_test_scaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X_test)
|
||||
<span style="color: #408080; font-style: italic"># Logistic Regression</span>
|
||||
logreg<span style="color: #666666">.</span>fit(X_train_scaled, y_train)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy Logistic Regression with scaled data: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #408080; font-style: italic">#Cross validation</span>
|
||||
accuracy <span style="color: #666666">=</span> cross_validate(logreg,X_test_scaled,y_test,cv<span style="color: #666666">=10</span>)[<span style="color: #BA2121">'test_score'</span>]
|
||||
<span style="color: #008000; font-weight: bold">print</span>(accuracy)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy with Logistic Regression and scaled data: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">scikitplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">skplt</span>
|
||||
y_pred <span style="color: #666666">=</span> logreg<span style="color: #666666">.</span>predict(X_test_scaled)
|
||||
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_confusion_matrix(y_test, y_pred, normalize<span style="color: #666666">=</span><span style="color: #008000">True</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
y_probas <span style="color: #666666">=</span> logreg<span style="color: #666666">.</span>predict_proba(X_test_scaled)
|
||||
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_roc(y_test, y_probas)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_cumulative_gain(y_test, y_probas)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
<li><a href="._week38-bs019.html">«</a></li>
|
||||
<li><a href="._week38-bs000.html">1</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs012.html">13</a></li>
|
||||
<li><a href="._week38-bs013.html">14</a></li>
|
||||
<li><a href="._week38-bs014.html">15</a></li>
|
||||
<li><a href="._week38-bs015.html">16</a></li>
|
||||
<li><a href="._week38-bs016.html">17</a></li>
|
||||
<li><a href="._week38-bs017.html">18</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs019.html">20</a></li>
|
||||
<li class="active"><a href="._week38-bs020.html">21</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="http://..."><img width="250" align=right src="http://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</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 -->
|
||||
|
||||
<body>
|
||||
@@ -118,6 +126,8 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs016.html#___sec15" style="font-size: 80%;">Including more classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs017.html#___sec16" style="font-size: 80%;">More classes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs018.html#___sec17" style="font-size: 80%;">A simple classification problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs019.html#___sec18" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week38-bs020.html#___sec19" style="font-size: 80%;">Other measures in classification studies: Cancer Data again</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -176,7 +186,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week38-bs008.html">9</a></li>
|
||||
<li><a href="._week38-bs009.html">10</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week38-bs018.html">19</a></li>
|
||||
<li><a href="._week38-bs020.html">21</a></li>
|
||||
<li><a href="._week38-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -682,6 +682,93 @@ methods</a>.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec18">Cancer Data again now with Decision Trees and other Methods </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> load_breast_cancer
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.linear_model</span> <span style="color: #8B008B; font-weight: bold">import</span> LogisticRegression
|
||||
|
||||
<span style="color: #228B22"># Load the data</span>
|
||||
cancer = load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=<span style="color: #B452CD">0</span>)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(X_train.shape)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(X_test.shape)
|
||||
<span style="color: #228B22"># Logistic Regression</span>
|
||||
logreg = LogisticRegression(solver=<span style="color: #CD5555">'lbfgs'</span>)
|
||||
logreg.fit(X_train, y_train)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy with Logistic Regression: {:.2f}"</span>.format(logreg.score(X_test,y_test)))
|
||||
<span style="color: #228B22">#now scale the data</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> StandardScaler
|
||||
scaler = StandardScaler()
|
||||
scaler.fit(X_train)
|
||||
X_train_scaled = scaler.transform(X_train)
|
||||
X_test_scaled = scaler.transform(X_test)
|
||||
<span style="color: #228B22"># Logistic Regression</span>
|
||||
logreg.fit(X_train_scaled, y_train)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy Logistic Regression with scaled data: {:.2f}"</span>.format(logreg.score(X_test_scaled,y_test)))
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec19">Other measures in classification studies: Cancer Data again </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> load_breast_cancer
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.linear_model</span> <span style="color: #8B008B; font-weight: bold">import</span> LogisticRegression
|
||||
|
||||
<span style="color: #228B22"># Load the data</span>
|
||||
cancer = load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=<span style="color: #B452CD">0</span>)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(X_train.shape)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(X_test.shape)
|
||||
<span style="color: #228B22"># Logistic Regression</span>
|
||||
logreg = LogisticRegression(solver=<span style="color: #CD5555">'lbfgs'</span>)
|
||||
logreg.fit(X_train, y_train)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy with Logistic Regression: {:.2f}"</span>.format(logreg.score(X_test,y_test)))
|
||||
<span style="color: #228B22">#now scale the data</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> StandardScaler
|
||||
scaler = StandardScaler()
|
||||
scaler.fit(X_train)
|
||||
X_train_scaled = scaler.transform(X_train)
|
||||
X_test_scaled = scaler.transform(X_test)
|
||||
<span style="color: #228B22"># Logistic Regression</span>
|
||||
logreg.fit(X_train_scaled, y_train)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy Logistic Regression with scaled data: {:.2f}"</span>.format(logreg.score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #228B22">#Cross validation</span>
|
||||
accuracy = cross_validate(logreg,X_test_scaled,y_test,cv=<span style="color: #B452CD">10</span>)[<span style="color: #CD5555">'test_score'</span>]
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(accuracy)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy with Logistic Regression and scaled data: {:.2f}"</span>.format(logreg.score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">scikitplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">skplt</span>
|
||||
y_pred = logreg.predict(X_test_scaled)
|
||||
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=<span style="color: #658b00">True</span>)
|
||||
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()
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
</div> <!-- class="slides" -->
|
||||
</div> <!-- class="reveal" -->
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -582,6 +590,91 @@ methods</a>.
|
||||
main()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec18">Cancer Data again now with Decision Trees and other Methods </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> load_breast_cancer
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.linear_model</span> <span style="color: #8B008B; font-weight: bold">import</span> LogisticRegression
|
||||
|
||||
<span style="color: #228B22"># Load the data</span>
|
||||
cancer = load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=<span style="color: #B452CD">0</span>)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(X_train.shape)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(X_test.shape)
|
||||
<span style="color: #228B22"># Logistic Regression</span>
|
||||
logreg = LogisticRegression(solver=<span style="color: #CD5555">'lbfgs'</span>)
|
||||
logreg.fit(X_train, y_train)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy with Logistic Regression: {:.2f}"</span>.format(logreg.score(X_test,y_test)))
|
||||
<span style="color: #228B22">#now scale the data</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> StandardScaler
|
||||
scaler = StandardScaler()
|
||||
scaler.fit(X_train)
|
||||
X_train_scaled = scaler.transform(X_train)
|
||||
X_test_scaled = scaler.transform(X_test)
|
||||
<span style="color: #228B22"># Logistic Regression</span>
|
||||
logreg.fit(X_train_scaled, y_train)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy Logistic Regression with scaled data: {:.2f}"</span>.format(logreg.score(X_test_scaled,y_test)))
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec19">Other measures in classification studies: Cancer Data again </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> load_breast_cancer
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.linear_model</span> <span style="color: #8B008B; font-weight: bold">import</span> LogisticRegression
|
||||
|
||||
<span style="color: #228B22"># Load the data</span>
|
||||
cancer = load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=<span style="color: #B452CD">0</span>)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(X_train.shape)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(X_test.shape)
|
||||
<span style="color: #228B22"># Logistic Regression</span>
|
||||
logreg = LogisticRegression(solver=<span style="color: #CD5555">'lbfgs'</span>)
|
||||
logreg.fit(X_train, y_train)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy with Logistic Regression: {:.2f}"</span>.format(logreg.score(X_test,y_test)))
|
||||
<span style="color: #228B22">#now scale the data</span>
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> StandardScaler
|
||||
scaler = StandardScaler()
|
||||
scaler.fit(X_train)
|
||||
X_train_scaled = scaler.transform(X_train)
|
||||
X_test_scaled = scaler.transform(X_test)
|
||||
<span style="color: #228B22"># Logistic Regression</span>
|
||||
logreg.fit(X_train_scaled, y_train)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy Logistic Regression with scaled data: {:.2f}"</span>.format(logreg.score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #228B22">#Cross validation</span>
|
||||
accuracy = cross_validate(logreg,X_test_scaled,y_test,cv=<span style="color: #B452CD">10</span>)[<span style="color: #CD5555">'test_score'</span>]
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(accuracy)
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(<span style="color: #CD5555">"Test set accuracy with Logistic Regression and scaled data: {:.2f}"</span>.format(logreg.score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">scikitplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">skplt</span>
|
||||
y_pred = logreg.predict(X_test_scaled)
|
||||
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=<span style="color: #658b00">True</span>)
|
||||
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()
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
<body>
|
||||
@@ -587,6 +595,91 @@ methods</a>.
|
||||
main()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec18">Cancer Data again now with Decision Trees and other Methods </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> load_breast_cancer
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LogisticRegression
|
||||
|
||||
<span style="color: #408080; font-style: italic"># Load the data</span>
|
||||
cancer <span style="color: #666666">=</span> load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test <span style="color: #666666">=</span> train_test_split(cancer<span style="color: #666666">.</span>data,cancer<span style="color: #666666">.</span>target,random_state<span style="color: #666666">=0</span>)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(X_train<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(X_test<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #408080; font-style: italic"># Logistic Regression</span>
|
||||
logreg <span style="color: #666666">=</span> LogisticRegression(solver<span style="color: #666666">=</span><span style="color: #BA2121">'lbfgs'</span>)
|
||||
logreg<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy with Logistic Regression: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test,y_test)))
|
||||
<span style="color: #408080; font-style: italic">#now scale the data</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> StandardScaler
|
||||
scaler <span style="color: #666666">=</span> StandardScaler()
|
||||
scaler<span style="color: #666666">.</span>fit(X_train)
|
||||
X_train_scaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X_train)
|
||||
X_test_scaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X_test)
|
||||
<span style="color: #408080; font-style: italic"># Logistic Regression</span>
|
||||
logreg<span style="color: #666666">.</span>fit(X_train_scaled, y_train)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy Logistic Regression with scaled data: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec19">Other measures in classification studies: Cancer Data again </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> load_breast_cancer
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LogisticRegression
|
||||
|
||||
<span style="color: #408080; font-style: italic"># Load the data</span>
|
||||
cancer <span style="color: #666666">=</span> load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test <span style="color: #666666">=</span> train_test_split(cancer<span style="color: #666666">.</span>data,cancer<span style="color: #666666">.</span>target,random_state<span style="color: #666666">=0</span>)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(X_train<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(X_test<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #408080; font-style: italic"># Logistic Regression</span>
|
||||
logreg <span style="color: #666666">=</span> LogisticRegression(solver<span style="color: #666666">=</span><span style="color: #BA2121">'lbfgs'</span>)
|
||||
logreg<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy with Logistic Regression: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test,y_test)))
|
||||
<span style="color: #408080; font-style: italic">#now scale the data</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> StandardScaler
|
||||
scaler <span style="color: #666666">=</span> StandardScaler()
|
||||
scaler<span style="color: #666666">.</span>fit(X_train)
|
||||
X_train_scaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X_train)
|
||||
X_test_scaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X_test)
|
||||
<span style="color: #408080; font-style: italic"># Logistic Regression</span>
|
||||
logreg<span style="color: #666666">.</span>fit(X_train_scaled, y_train)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy Logistic Regression with scaled data: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #408080; font-style: italic">#Cross validation</span>
|
||||
accuracy <span style="color: #666666">=</span> cross_validate(logreg,X_test_scaled,y_test,cv<span style="color: #666666">=10</span>)[<span style="color: #BA2121">'test_score'</span>]
|
||||
<span style="color: #008000; font-weight: bold">print</span>(accuracy)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Test set accuracy with Logistic Regression and scaled data: {:.2f}"</span><span style="color: #666666">.</span>format(logreg<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">scikitplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">skplt</span>
|
||||
y_pred <span style="color: #666666">=</span> logreg<span style="color: #666666">.</span>predict(X_test_scaled)
|
||||
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_confusion_matrix(y_test, y_pred, normalize<span style="color: #666666">=</span><span style="color: #008000">True</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
y_probas <span style="color: #666666">=</span> logreg<span style="color: #666666">.</span>predict_proba(X_test_scaled)
|
||||
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_roc(y_test, y_probas)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_cumulative_gain(y_test, y_probas)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
Binary file not shown.
@@ -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": {},
|
||||
|
||||
Reference in New Issue
Block a user