updating documentation format for pdf

This commit is contained in:
rasbt
2016-07-04 11:10:49 -04:00
parent 64dd0a5c5b
commit 2ab93ce987
64 changed files with 930 additions and 437 deletions
+1
View File
@@ -1,5 +1,6 @@
# Documentation builds
docs/site/
docs/mlxtend.pdf
# Temporary documentation files
docs/sources/user_guide/*.md
+13 -2
View File
@@ -15,7 +15,7 @@
**A library consisting of useful tools and extensions for the day-to-day data science tasks.**
**Mlxtend is a library consisting of useful tools and extensions for the day-to-day data science tasks.**
- This open source project is released under a permissive new BSD open source [license](./license) and commercially usable
@@ -28,7 +28,7 @@ Sebastian Raschka 2014-2016
## Links
- **Documentation:** [http://rasbt.github.io/mlxtend/](http://rasbt.github.io/mlxtend/)
- **Documentation:** [[html](http://rasbt.github.io/mlxtend/)] [[pdf](sebastianraschka.com/pdf/software/mlxtend.pdf)]
- Source code repository: [https://github.com/rasbt/mlxtend](https://github.com/rasbt/mlxtend)
- PyPI: [https://pypi.python.org/pypi/mlxtend](https://pypi.python.org/pypi/mlxtend)
- Changelog: [http://rasbt.github.io/mlxtend/changelog](http://rasbt.github.io/mlxtend/changelog)
@@ -139,6 +139,17 @@ If you use mlxtend as part of your workflow in a scientific publication, please
[![](https://zenodo.org/badge/doi/10.5281/zenodo.49235.svg)](https://zenodo.org/record/49235#.VwWISmNh23c)
```
@misc{raschkas_2016_49235,
author = {Raschka, Sebastian},
title = {Mlxtend},
month = apr,
year = 2016,
doi = {10.5281/zenodo.49235},
url = {http://dx.doi.org/10.5281/zenodo.49235}
}
```
---
## Contact
+3
View File
@@ -4,6 +4,9 @@
<li class="main {% if toc_item.active %}active{% endif %}"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% for toc_item in toc_item.children %}
<li><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% for toc_item_2 in toc_item.children %}
<li><a href="{{ toc_item_2.url }}">{{ toc_item_2.title }}</a></li>
{% endfor %}
{% endfor %}
{% endfor %}
</ul>
+1 -1
View File
@@ -45,7 +45,7 @@ def ipynb_to_md(ipynb_path):
new_s.append(line)
break
for line in f:
if line.startswith('# API'):
if line.startswith('## API'):
new_s.append(line)
new_s.append('\n')
break
+10 -11
View File
@@ -40,7 +40,7 @@ def docstring_to_markdown(docstring):
for idx, line in enumerate(docstring.split('\n')):
line = line.strip()
if set(line) in ({'-'}, {'='}):
new_docstring_lst[idx-1] = '**%s**' % new_docstring_lst[idx-1]
new_docstring_lst[idx - 1] = '**%s**' % new_docstring_lst[idx - 1]
elif line.startswith('>>>'):
line = ' %s' % line
new_docstring_lst.append(line)
@@ -48,15 +48,15 @@ def docstring_to_markdown(docstring):
for idx, line in enumerate(new_docstring_lst[1:]):
if line:
if line.startswith('Description : '):
new_docstring_lst[idx+1] = (new_docstring_lst[idx+1]
.replace('Description : ', ''))
new_docstring_lst[idx + 1] = (new_docstring_lst[idx + 1]
.replace('Description : ', ''))
elif ' : ' in line:
line = line.replace(' : ', '` : ')
new_docstring_lst[idx+1] = '\n- `%s\n' % line
elif '**' in new_docstring_lst[idx-1] and '**' not in line:
new_docstring_lst[idx+1] = '\n%s' % line.lstrip()
new_docstring_lst[idx + 1] = '\n- `%s\n' % line
elif '**' in new_docstring_lst[idx - 1] and '**' not in line:
new_docstring_lst[idx + 1] = '\n%s' % line.lstrip()
elif '**' not in line:
new_docstring_lst[idx+1] = ' %s' % line.lstrip()
new_docstring_lst[idx + 1] = ' %s' % line.lstrip()
clean_lst = []
for line in new_docstring_lst:
@@ -232,8 +232,7 @@ def generate_api_docs(package, api_dir, clean=False, printlog=True):
# get subpackages
api_docs = {}
for importer, pkg_name, is_pkg in pkgutil.iter_modules(
package.__path__,
prefix):
package.__path__, prefix):
if is_pkg:
subpackage = __import__(pkg_name, fromlist="dummy")
prefix = subpackage.__name__ + "."
@@ -365,8 +364,8 @@ if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(
description='Convert docstring into a markdown API documentation.',
formatter_class=argparse.RawTextHelpFormatter)
description='Convert docstring into a markdown API documentation.',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-n', '--package_name',
default='mlxtend',
+101
View File
@@ -0,0 +1,101 @@
# API generator script
#
# Sebastian Raschka 2014-2016
# mlxtend Machine Learning Library Extensions
#
# Author: Sebastian Raschka <sebastianraschka.com>
#
# License: BSD 3 clause
import yaml
import os
import subprocess
yaml_path = "./mkdocs.yml"
source_path = os.path.join(os.path.dirname(yaml_path), 'sources')
md_out_path = "./temp.md"
with open(yaml_path, 'r') as f:
content = f.read()
tree = yaml.load(content)
mkdocs = []
def get_leaf_nodes(tree):
if isinstance(tree, dict):
for v in tree.values():
get_leaf_nodes(v)
elif isinstance(tree, list) or isinstance(tree, tuple):
for ele in tree:
get_leaf_nodes(ele)
else:
mkdocs.append(tree)
get_leaf_nodes(tree['pages'])
mkdocs = [s for s in mkdocs if 'api_subpackages' not in s and
'USER_GUIDE_INDEX.md' not in s]
def abs_imagepath(line, md_path):
elements = line.split('](')
rel_path = elements[1].strip().rstrip(')')
img_path = os.path.join(md_path, rel_path)
img_link = '%s](%s)\n' % (elements[0], img_path)
img_link = img_link.replace('/./', '/')
return img_link
def gen_title(fname):
stem, title = os.path.split(fname)
title = title.rstrip('.md')
s = '# `%s.%s`' % (os.path.split(stem)[1], title)
return s
with open(md_out_path, 'w') as f_out:
meta = r"""---
title: Mlxtend v0.4.1
subtitle: Library Documentation
author: Sebastian Raschka
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[LO,LE]{\thepage}
- \fancyfoot[CE,CO]{}
---
"""
f_out.write(meta)
for md in mkdocs:
md_path = os.path.join(source_path, md)
img_path = os.path.dirname(md_path)
with open(md_path, 'r') as f_in:
content = f_in.readlines()
if md.startswith('user_guide'):
title = gen_title(md)
f_out.write(title + '\n')
if content[0].startswith('# '):
content = content[1:]
for line in content:
if '![png]' in line:
line = line.replace('![png]', '![]')
if '.svg' in line:
continue
if line.startswith('!['):
line = abs_imagepath(line, img_path)
f_out.write(line)
f_out.write('\n\n')
subprocess.check_call(['pandoc', '-N', 'temp.md', '--output=mlxtend.pdf', '--toc',
'--normalize', '--smart', '--latex-engine=xelatex',
'--toc-depth=4', '--highlight-style=pygments',
'--template=pdftemplate.tex'])
os.remove(md_out_path)
+1 -3
View File
@@ -30,7 +30,7 @@ google_analytics: ['UA-38457794-2', 'rasbt.github.io/mlxtend/']
pages:
- Home: index.md
- User Guide:
- ./USER_GUIDE_INDEX.md
- USER_GUIDE_INDEX.md
- classifier:
- user_guide/classifier/EnsembleVoteClassifier.md
- user_guide/classifier/StackingClassifier.md
@@ -100,8 +100,6 @@ pages:
- user_guide/general_concepts/gradient-optimization.md
- user_guide/general_concepts/linear-gradient-derivative.md
- user_guide/general_concepts/regularization-linear.md
- API:
- api_subpackages/mlxtend.classifier.md
- api_subpackages/mlxtend.tf_classifier.md
+256
View File
@@ -0,0 +1,256 @@
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
$if(fontfamily)$
\usepackage{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
$if(linestretch)$
\urlstyle{same} % don't use monospace font for urls
% Overwrite \begin{figure}[htbp] with \begin{figure}[H]
\usepackage{float}
\let\origfigure=\figure
\let\endorigfigure=\endfigure
\renewenvironment{figure}[1][]{%
\origfigure[H]
}{%
\endorigfigure
}
% Suppress Figure Captions
\usepackage{caption}
\DeclareCaptionLabelFormat{nolabel}{}
\captionsetup{labelformat=nolabel}
\usepackage{setspace}
\setstretch{$linestretch$}
$endif$
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
$if(euro)$
\usepackage{eurosym}
$endif$
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\usepackage{xltxtra,xunicode}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\newcommand{\euro}{}
$if(mainfont)$
\setmainfont{$mainfont$}
$endif$
$if(sansfont)$
\setsansfont{$sansfont$}
$endif$
$if(monofont)$
\setmonofont[Mapping=tex-ansi]{$monofont$}
$endif$
$if(mathfont)$
\setmathfont(Digits,Latin,Greek){$mathfont$}
$endif$
$if(CJKmainfont)$
\usepackage{xeCJK}
\setCJKmainfont[$CJKoptions$]{$CJKmainfont$}
$endif$
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
$if(geometry)$
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
$endif$
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex]{hyperref}
\else
\usepackage[unicode=true]{hyperref}
\fi
\usepackage[usenames,dvipsnames]{color}
\hypersetup{breaklinks=true,
bookmarks=true,
pdfauthor={$author-meta$},
pdftitle={$title-meta$},
colorlinks=true,
citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,
urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
pdfborder={0 0 0}}
\urlstyle{same} % don't use monospace font for urls
$if(lang)$
\ifxetex
\usepackage{polyglossia}
\setmainlanguage{$mainlang$}
\setotherlanguages{$for(otherlang)$$otherlang$$sep$,$endfor$}
\else
\usepackage[shorthands=off,$lang$]{babel}
\fi
$endif$
$if(natbib)$
\usepackage{natbib}
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
$endif$
$if(biblatex)$
\usepackage{biblatex}
$for(bibliography)$
\addbibresource{$bibliography$}
$endfor$
$endif$
$if(listings)$
\usepackage{listings}
$endif$
$if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
\VerbatimFootnotes
$endif$
$if(tables)$
\usepackage{longtable,booktabs}
$endif$
$if(graphics)$
\usepackage{graphicx}
% We will generate all images so they have a width \maxwidth. This means
% that they will get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
$endif$
\usepackage{caption}
\DeclareCaptionLabelFormat{nolabel}{}
\captionsetup{labelformat=nolabel}
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
$endif$
$if(strikeout)$
\usepackage[normalem]{ulem}
% avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
$if(numbersections)$
\setcounter{secnumdepth}{5}
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(verbatim-in-note)$
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
$endif$
$if(subtitle)$
\providecommand{\subtitle}[1]{}
\subtitle{$subtitle$}
$endif$
$if(author)$
\author{$for(author)$$author$$sep$ \and $endfor$}
$endif$
$if(institute)$
\institute{$for(institute)$$institute$$sep$ \and $endfor$}
$endif$
\date{$date$}
$for(header-includes)$
$header-includes$
$endfor$
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\begin{document}
\begin{figure}
\centering
\includegraphics{sources/img/logo.pdf}
\label{}
\end{figure}
\maketitle
$if(abstract)$
\begin{abstract}
$abstract$
\end{abstract}
$endif$
$for(include-before)$
$include-before$
$endfor$
\newpage
$if(toc)$
{
\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$black$endif$}
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
}
$endif$
$if(lot)$
\listoftables
$endif$
$if(lof)$
\listoffigures
$endif$
$body$
$if(natbib)$
$if(bibliography)$
$if(biblio-title)$
$if(book-class)$
\renewcommand\bibname{$biblio-title$}
$else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
$endif$
$endif$
$if(biblatex)$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$
$for(include-after)$
$include-after$
$endfor$
\end{document}
+11 -3
View File
@@ -37,11 +37,11 @@ and checking off items as you go.
- If you don't have a [GitHub](https://github.com) account, yet, please create one to contribute to this project.
- Please submit a ticket for your issue to discuss the fix or new feature before too much time and effort is spent for the implementation.
![](img/contributing/new_issue.png)
![](./img/contributing/new_issue.png)
- Fork the `mlxtend` repository from the GitHub web interface.
![](img/contributing/fork.png)
![](./img/contributing/fork.png)
- Clone the `mlxtend` repository to your local machine by executing
```git clone https://github.com/<your_username>/mlxtend.git```
@@ -259,7 +259,7 @@ $ git push origin <feature_branch>
Go to your GitHub repository online, select the new feature branch, and submit a new pull request:
![](img/contributing/pull_request.png)
![](./img/contributing/pull_request.png)
<hr>
@@ -329,6 +329,14 @@ To deploy the documentation, execute
~/github/mlxtend/docs$ mkdocs gh-deploy --clean
```
### 4. Generate a PDF of the documentation
To generate a PDF version of the documentation, simply `cd` into the `mlxtend/docs` directory and execute:
```bash
python md2pdf.py
```
## Uploading a new version to PyPI
### 1. Creating a new testing environment
+11
View File
@@ -3,3 +3,14 @@
If you use mlxtend as part of your workflow in a scientific publication, please consider citing the mlxtend repository with the following DOI:
[![](https://zenodo.org/badge/doi/10.5281/zenodo.49235.svg)](https://zenodo.org/record/49235#.VwWISmNh23c)
```
@misc{raschkas_2016_49235,
author = {Raschka, Sebastian},
title = {Mlxtend},
month = apr,
year = 2016,
doi = {10.5281/zenodo.49235},
url = {http://dx.doi.org/10.5281/zenodo.49235}
}
```
Binary file not shown.
+27 -5
View File
@@ -18,7 +18,8 @@
<hr>
## Links
- Documentation: [http://rasbt.github.io/mlxtend/](http://rasbt.github.io/mlxtend/)
- Documentation: [[html](http://rasbt.github.io/mlxtend/)] [[pdf](sebastianraschka.com/pdf/software/mlxtend.pdf)]
- Source code repository: [https://github.com/rasbt/mlxtend](https://github.com/rasbt/mlxtend)
- PyPI: [https://pypi.python.org/pypi/mlxtend](https://pypi.python.org/pypi/mlxtend)
- Questions? Check out the [Google Groups mailing list](https://groups.google.com/forum/#!forum/mlxtend)
@@ -45,23 +46,33 @@ from mlxtend.evaluate import plot_decision_regions
clf1 = LogisticRegression(random_state=0)
clf2 = RandomForestClassifier(random_state=0)
clf3 = SVC(random_state=0, probability=True)
eclf = EnsembleVoteClassifier(clfs=[clf1, clf2, clf3], weights=[2, 1, 1], voting='soft')
eclf = EnsembleVoteClassifier(clfs=[clf1, clf2, clf3],
weights=[2, 1, 1], voting='soft')
# Loading some example data
X, y = iris_data()
X = X[:,[0, 2]]
# Plotting Decision Regions
gs = gridspec.GridSpec(2, 2)
fig = plt.figure(figsize=(10, 8))
labels = ['Logistic Regression',
'Random Forest',
'RBF kernel SVM',
'Ensemble']
for clf, lab, grd in zip([clf1, clf2, clf3, eclf],
['Logistic Regression', 'Random Forest', 'RBF kernel SVM', 'Ensemble'],
itertools.product([0, 1], repeat=2)):
labels,
itertools.product([0, 1],
repeat=2)):
clf.fit(X, y)
ax = plt.subplot(gs[grd[0], grd[1]])
fig = plot_decision_regions(X=X, y=y, clf=clf, legend=2)
fig = plot_decision_regions(X=X, y=y,
clf=clf, legend=2)
plt.title(lab)
plt.show()
```
@@ -73,6 +84,17 @@ If you use mlxtend as part of your workflow in a scientific publication, please
[![](https://zenodo.org/badge/doi/10.5281/zenodo.49235.svg)](https://zenodo.org/record/49235#.VwWISmNh23c)
```
@misc{raschkas_2016_49235,
author = {Raschka, Sebastian},
title = {Mlxtend},
month = apr,
year = 2016,
doi = {10.5281/zenodo.49235},
url = {http://dx.doi.org/10.5281/zenodo.49235}
}
```
## Contact
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -103,13 +103,12 @@
"\n",
"[`LinearRegression`](../regressor/LinearRegression.md) implements a linear regression model for performing ordinary least squares regression, and in Adaline, we add a threshold function $g(\\cdot)$ to convert the continuous outcome to a categorical class label:\n",
"\n",
"$$y = g({z}) = \\left\\{\n",
" \\begin{array}{l}\n",
" 1 & \\text{if z $\\ge$ 0}\\\\\n",
" -1 & \\text{otherwise}.\n",
" \\end{array}\n",
" \\\\ \n",
" \\right.$$"
"$$y = g({z}) =\n",
"\\begin{cases}\n",
"1 & \\text{if z $\\ge$ 0}\\\\\n",
"-1 & \\text{otherwise}.\n",
"\\end{cases}\n",
"$$"
]
},
{
@@ -188,14 +187,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Closed Form Solution"
"### Example 1 - Closed Form Solution"
]
},
{
@@ -249,7 +248,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Gradient Descent"
"### Example 2 - Gradient Descent"
]
},
{
@@ -335,7 +334,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Stochastic Gradient Descent"
"### Example 3 - Stochastic Gradient Descent"
]
},
{
@@ -412,7 +411,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Stochastic Gradient Descent with Minibatches"
"### Example 4 - Stochastic Gradient Descent with Minibatches"
]
},
{
@@ -489,12 +488,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 1,
"metadata": {
"collapsed": false
},
File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 35 KiB

@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -122,24 +122,22 @@
"source": [
"After model fitting, the conditional probability $p(y=1 \\mid \\mathbf{x})$ is converted to a binary class label via a threshold function $g(\\cdot)$:\n",
"\n",
"$$y = g({z}) = \\left\\{\n",
" \\begin{array}{l}\n",
" 1 & \\text{if $\\phi(z) \\ge 0.5$}\\\\\n",
" 0 & \\text{otherwise.}\n",
" \\end{array}\n",
" \\\\\n",
" \\right.$$\n",
"$$y = g({z}) = \n",
" \\begin{cases}\n",
" 1 & \\text{if $\\phi(z) \\ge 0.5$}\\\\\n",
" 0 & \\text{otherwise.}\n",
" \\end{cases}\n",
"$$\n",
"\n",
"or eqivalently:\n",
"or equivalently:\n",
"\n",
"\n",
"$$y = g({z}) = \\left\\{\n",
" \\begin{array}{l}\n",
" 1 & \\text{if z $\\ge$ 0}\\\\\n",
" 0 & \\text{otherwise}.\n",
" \\end{array}\n",
" \\\\ \n",
" \\right.$$"
"$$y = g({z}) = \n",
"\\begin{cases}\n",
"1 & \\text{if z $\\ge$ 0}\\\\\n",
"0 & \\text{otherwise}.\n",
"\\end{cases}\n",
"$$"
]
},
{
@@ -447,14 +445,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Gradient Descent"
"### Example 1 - Gradient Descent"
]
},
{
@@ -533,7 +531,7 @@
"collapsed": true
},
"source": [
"### Predicting Class Labels"
"#### Predicting Class Labels"
]
},
{
@@ -556,6 +554,13 @@
"print('Last 3 Class Labels: %s' % y_pred[-3:])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Predicting Class Probabilities"
]
},
{
"cell_type": "code",
"execution_count": 5,
@@ -580,14 +585,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Predicting Class Probabilities"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Stochastic Gradient Descent"
"### Example 2 - Stochastic Gradient Descent"
]
},
{
@@ -664,7 +662,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Stochastic Gradient Descent w. Minibatches"
"### Example 3 - Stochastic Gradient Descent w. Minibatches"
]
},
{
@@ -748,12 +746,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 1,
"metadata": {
"collapsed": false
},
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -92,7 +92,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basic Architecture"
"### Basic Architecture"
]
},
{
@@ -137,7 +137,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Activation"
"### Activation"
]
},
{
@@ -183,14 +183,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Classifying Iris Flowers"
"### Example 1 - Classifying Iris Flowers"
]
},
{
@@ -227,7 +227,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Gradient Descent"
"#### Gradient Descent"
]
},
{
@@ -345,7 +345,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Stochastic Gradient Descent"
"#### Stochastic Gradient Descent"
]
},
{
@@ -456,7 +456,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Classifying Handwritten Digits from a 10% MNIST Subset"
"### Example 2 - Classifying Handwritten Digits from a 10% MNIST Subset"
]
},
{
@@ -649,12 +649,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 1,
"metadata": {
"collapsed": false
},
@@ -830,6 +830,15 @@
"with open('../../api_modules/mlxtend.classifier/NeuralNetMLP.md', 'r') as f:\n",
" print(f.read())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
@@ -77,7 +77,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -100,7 +100,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Basic Notation"
"#### Basic Notation"
]
},
{
@@ -158,12 +158,12 @@
"\n",
"so that \n",
"\n",
"$$\\begin{equation}\n",
"$$\n",
" g({z}) =\\begin{cases}\n",
" 1 & \\text{if $z \\ge 0$}\\\\\n",
" -1 & \\text{otherwise}.\n",
" \\end{cases}\n",
"\\end{equation}$$\n",
"$$\n",
"\n",
"and\n",
"\n",
@@ -171,6 +171,7 @@
"$$z = w_0x_{0} + w_1x_{1} + \\dots + w_mx_{m} = \\sum_{j=0}^{m} x_{j}w_{j} \\\\ = \\mathbf{w}^T\\mathbf{x}.$$\n",
"\n",
"\n",
"\n",
"\n"
]
},
@@ -178,7 +179,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Perceptron Rule"
"#### Perceptron Rule"
]
},
{
@@ -259,14 +260,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Classification of Iris Flowers"
"### Example 1 - Classification of Iris Flowers"
]
},
{
@@ -354,12 +355,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"metadata": {
"collapsed": false
},
@@ -495,6 +496,15 @@
"with open('../../api_modules/mlxtend.classifier/Perceptron.md', 'r') as f:\n",
" print(f.read())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -507,14 +507,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Gradient Descent"
"### Example 1 - Gradient Descent"
]
},
{
@@ -590,7 +590,7 @@
"collapsed": true
},
"source": [
"### Predicting Class Labels"
"#### Predicting Class Labels"
]
},
{
@@ -617,7 +617,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Predicting Class Probabilities"
"#### Predicting Class Probabilities"
]
},
{
@@ -647,7 +647,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Stochastic Gradient Descent"
"### Example 2 - Stochastic Gradient Descent"
]
},
{
@@ -710,12 +710,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 1,
"metadata": {
"collapsed": false
},
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -124,14 +124,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Simple Stacked Classification"
"### Example 1 - Simple Stacked Classification"
]
},
{
@@ -192,8 +192,10 @@
" 'Naive Bayes',\n",
" 'StackingClassifier']):\n",
"\n",
" scores = cross_validation.cross_val_score(clf, X, y, cv=3, scoring='accuracy')\n",
" print(\"Accuracy: %0.2f (+/- %0.2f) [%s]\" % (scores.mean(), scores.std(), label))"
" scores = cross_validation.cross_val_score(clf, X, y, \n",
" cv=3, scoring='accuracy')\n",
" print(\"Accuracy: %0.2f (+/- %0.2f) [%s]\" \n",
" % (scores.mean(), scores.std(), label))"
]
},
{
@@ -241,7 +243,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Stacked Classification and GridSearch"
"### Example 2 - Stacked Classification and GridSearch"
]
},
{
@@ -374,12 +376,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 1,
"metadata": {
"collapsed": false
},
+14 -5
View File
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -113,14 +113,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Three Blobs"
"### Example 1 - Three Blobs"
]
},
{
@@ -271,12 +271,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {
"collapsed": false
},
@@ -393,6 +393,15 @@
"with open('../../api_modules/mlxtend.cluster/Kmeans.md', 'r') as f:\n",
" print(f.read())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
@@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -106,14 +106,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example - Dataset overview"
"### Example - Dataset overview"
]
},
{
@@ -184,7 +184,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -113,14 +113,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example - Dataset overview"
"### Example - Dataset overview"
]
},
{
@@ -154,7 +154,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
+4 -4
View File
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -103,14 +103,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example - Dataset overview"
"### Example - Dataset overview"
]
},
{
@@ -169,7 +169,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
+10 -8
View File
@@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -109,14 +109,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Downloading the MNIST dataset"
"### Downloading the MNIST dataset"
]
},
{
@@ -145,7 +145,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example - Loading MNIST into NumPy Arrays"
"### Example 1 - Loading MNIST into NumPy Arrays"
]
},
{
@@ -265,7 +265,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Examples - Store as CSV Files"
"#### Store as CSV Files"
]
},
{
@@ -276,15 +276,17 @@
},
"outputs": [],
"source": [
"np.savetxt(fname='/Users/Sebastian/Desktop/images.csv', X=X, delimiter=',', fmt='%d')\n",
"np.savetxt(fname='/Users/Sebastian/Desktop/labels.csv', X=y, delimiter=',', fmt='%d')"
"np.savetxt(fname='/Users/Sebastian/Desktop/images.csv', \n",
" X=X, delimiter=',', fmt='%d')\n",
"np.savetxt(fname='/Users/Sebastian/Desktop/labels.csv', \n",
" X=y, delimiter=',', fmt='%d')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -102,14 +102,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example - Dataset overview"
"### Example - Dataset overview"
]
},
{
@@ -207,7 +207,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example - Visualize MNIST"
"### Example - Visualize MNIST"
]
},
{
@@ -243,7 +243,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -77,7 +77,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -103,14 +103,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example - Dataset overview"
"### Example - Dataset overview"
]
},
{
@@ -242,7 +242,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
+4 -4
View File
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -128,14 +128,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example - Dataset overview"
"### Example - Dataset overview"
]
},
{
@@ -195,7 +195,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,14 +78,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Confusion Matrix"
"### Confusion Matrix"
]
},
{
@@ -118,14 +118,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Binary classification"
"### Example 1 - Binary classification"
]
},
{
@@ -153,7 +153,8 @@
"y_target = [0, 0, 1, 0, 0, 1, 1, 1]\n",
"y_predicted = [1, 0, 1, 0, 0, 0, 0, 1]\n",
"\n",
"cm = confusion_matrix(y_target=y_target, y_predicted=y_predicted)\n",
"cm = confusion_matrix(y_target=y_target, \n",
" y_predicted=y_predicted)\n",
"cm"
]
},
@@ -187,7 +188,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Multi-class classification"
"### Example 2 - Multi-class classification"
]
},
{
@@ -217,7 +218,9 @@
"y_target = [1, 1, 1, 0, 0, 2, 0, 3]\n",
"y_predicted = [1, 0, 1, 0, 0, 2, 1, 3]\n",
"\n",
"cm = confusion_matrix(y_target=y_target, y_predicted=y_predicted, binary=False)\n",
"cm = confusion_matrix(y_target=y_target, \n",
" y_predicted=y_predicted, \n",
" binary=False)\n",
"cm"
]
},
@@ -251,7 +254,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Multi-class to binary"
"### Example 3 - Multi-class to binary"
]
},
{
@@ -287,7 +290,10 @@
"y_target = [1, 1, 1, 0, 0, 2, 0, 3]\n",
"y_predicted = [1, 0, 1, 0, 0, 2, 1, 3]\n",
"\n",
"cm = confusion_matrix(y_target=y_target, y_predicted=y_predicted, binary=True, positive_label=1)\n",
"cm = confusion_matrix(y_target=y_target, \n",
" y_predicted=y_predicted, \n",
" binary=True, \n",
" positive_label=1)\n",
"cm"
]
},
@@ -320,7 +326,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -86,14 +86,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Decision regions in 2D"
"### Example 1 - Decision regions in 2D"
]
},
{
@@ -120,7 +120,8 @@
"\n",
"\n",
"# Plotting decision regions\n",
"plot_decision_regions(X, y, clf=svm, res=0.0002, legend=2)\n",
"plot_decision_regions(X, y, clf=svm, \n",
" res=0.0002, legend=2)\n",
"\n",
"# Adding axes annotations\n",
"plt.xlabel('sepal length [cm]')\n",
@@ -133,7 +134,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Decision regions in 1D"
"### Example 2 - Decision regions in 1D"
]
},
{
@@ -171,7 +172,8 @@
"svm.fit(X,y)\n",
"\n",
"# Plotting decision regions\n",
"plot_decision_regions(X, y, clf=svm, res=0.02, legend=2)\n",
"plot_decision_regions(X, y, clf=svm, \n",
" res=0.02, legend=2)\n",
"\n",
"# Adding axes annotations\n",
"plt.xlabel('sepal length [cm]')\n",
@@ -184,7 +186,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Decision Region Grids"
"### Example 3 - Decision Region Grids"
]
},
{
@@ -241,9 +243,9 @@
"\n",
"fig = plt.figure(figsize=(10,8))\n",
"\n",
"\n",
"labels = ['Logistic Regression', 'Random Forest', 'Naive Bayes', 'SVM']\n",
"for clf, lab, grd in zip([clf1, clf2, clf3, clf4],\n",
" ['Logistic Regression', 'Random Forest', 'Naive Bayes', 'SVM'],\n",
" labels,\n",
" itertools.product([0, 1], repeat=2)):\n",
"\n",
" clf.fit(X, y)\n",
@@ -258,7 +260,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 4 - Highlighting Test Data Points"
"### Example 4 - Highlighting Test Data Points"
]
},
{
@@ -300,7 +302,8 @@
"svm.fit(X_train, y_train)\n",
"\n",
"# Plotting decision regions\n",
"plot_decision_regions(X, y, clf=svm, res=0.02, legend=2, X_highlight=X_test)\n",
"plot_decision_regions(X, y, clf=svm, res=0.02, \n",
" legend=2, X_highlight=X_test)\n",
"\n",
"# Adding axes annotations\n",
"plt.xlabel('sepal length [cm]')\n",
@@ -313,7 +316,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 5 - Evaluating Classifier Behavior on Non-Linear Problems"
"### Example 5 - Evaluating Classifier Behavior on Non-Linear Problems"
]
},
{
@@ -331,7 +334,8 @@
"\n",
"# Initializing Classifiers\n",
"clf1 = LogisticRegression(random_state=1)\n",
"clf2 = RandomForestClassifier(n_estimators=100, random_state=1)\n",
"clf2 = RandomForestClassifier(n_estimators=100, \n",
" random_state=1)\n",
"clf3 = GaussianNB()\n",
"clf4 = SVC()"
]
@@ -356,7 +360,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### XOR"
"#### XOR"
]
},
{
@@ -371,7 +375,8 @@
" np.linspace(-3, 3, 50))\n",
"rng = np.random.RandomState(0)\n",
"X = rng.randn(300, 2)\n",
"y = np.array(np.logical_xor(X[:, 0] > 0, X[:, 1] > 0), dtype=int)"
"y = np.array(np.logical_xor(X[:, 0] > 0, X[:, 1] > 0), \n",
" dtype=int)"
]
},
{
@@ -397,8 +402,9 @@
"\n",
"fig = plt.figure(figsize=(10,8))\n",
"\n",
"labels = ['Logistic Regression', 'Random Forest', 'Naive Bayes', 'SVM']\n",
"for clf, lab, grd in zip([clf1, clf2, clf3, clf4],\n",
" ['Logistic Regression', 'Random Forest', 'Naive Bayes', 'SVM'],\n",
" labels,\n",
" itertools.product([0, 1], repeat=2)):\n",
"\n",
" clf.fit(X, y)\n",
@@ -413,7 +419,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Half-Moons"
"#### Half-Moons"
]
},
{
@@ -442,8 +448,9 @@
"\n",
"fig = plt.figure(figsize=(10,8))\n",
"\n",
"labels = ['Logistic Regression', 'Random Forest', 'Naive Bayes', 'SVM']\n",
"for clf, lab, grd in zip([clf1, clf2, clf3, clf4],\n",
" ['Logistic Regression', 'Random Forest', 'Naive Bayes', 'SVM'],\n",
" labels,\n",
" itertools.product([0, 1], repeat=2)):\n",
"\n",
" clf.fit(X, y)\n",
@@ -458,7 +465,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Concentric Circles"
"#### Concentric Circles"
]
},
{
@@ -487,8 +494,9 @@
"\n",
"fig = plt.figure(figsize=(10,8))\n",
"\n",
"labels = ['Logistic Regression', 'Random Forest', 'Naive Bayes', 'SVM']\n",
"for clf, lab, grd in zip([clf1, clf2, clf3, clf4],\n",
" ['Logistic Regression', 'Random Forest', 'Naive Bayes', 'SVM'],\n",
" labels,\n",
" itertools.product([0, 1], repeat=2)):\n",
"\n",
" clf.fit(X, y)\n",
@@ -503,7 +511,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -87,14 +87,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1"
"### Example 1"
]
},
{
@@ -140,7 +140,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
+11 -11
View File
@@ -77,14 +77,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Confusion Matrix"
"### Confusion Matrix"
]
},
{
@@ -108,7 +108,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Error and Accuracy"
"### Error and Accuracy"
]
},
{
@@ -126,7 +126,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## True and False Positive Rates"
"### True and False Positive Rates"
]
},
{
@@ -144,7 +144,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Precision, Recall, and the F1-Score"
"### Precision, Recall, and the F1-Score"
]
},
{
@@ -169,7 +169,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sensitivity and Specificity"
"### Sensitivity and Specificity"
]
},
{
@@ -187,7 +187,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Matthews Correlation Coefficient"
"### Matthews Correlation Coefficient"
]
},
{
@@ -204,7 +204,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Average Per-Class Accuracy"
"### Average Per-Class Accuracy"
]
},
{
@@ -270,14 +270,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Classification Error"
"### Example 1 - Classification Error"
]
},
{
@@ -309,7 +309,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -105,7 +105,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Summarizing the LDA approach in 5 steps\n",
"#### Summarizing the LDA approach in 5 steps\n",
"\n",
"\n",
"Listed below are the 5 general steps for performing a linear discriminant analysis.\n",
@@ -131,14 +131,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - LDA on Iris"
"### Example 1 - LDA on Iris"
]
},
{
@@ -201,7 +201,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Plotting the Between-Class Variance Explained Ratio"
"### Example 2 - Plotting the Between-Class Variance Explained Ratio"
]
},
{
@@ -276,7 +276,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -125,14 +125,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - PCA on Iris"
"### Example 1 - PCA on Iris"
]
},
{
@@ -195,7 +195,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Plotting the Variance Explained Ratio"
"### Example 2 - Plotting the Variance Explained Ratio"
]
},
{
@@ -269,7 +269,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - PCA via SVD"
"### Example 3 - PCA via SVD"
]
},
{
@@ -357,7 +357,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -57,7 +57,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# RBF Kernel Principal Component Analysis"
"## RBF Kernel Principal Component Analysis"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -126,9 +126,7 @@
"\n",
"Now, the term \"kernel\" describes a function that calculates the dot product of the images of the samples $\\mathbf{x}$ under $\\phi$.\n",
"\n",
"$$\n",
"\\begin{equation}\\kappa(\\mathbf{x_i, x_j}) = \\phi (\\mathbf{x_i}) \\phi (\\mathbf{x_j})^T \\end{equation}\n",
"$$\n",
"$$\\kappa(\\mathbf{x_i, x_j}) = \\phi (\\mathbf{x_i}) \\phi (\\mathbf{x_j})^T$$\n",
"\n",
"More details about the derivation of this equation are provided in this excellent review article by Quan Wang: [Kernel Principal Component Analysis and its Applications in Face Recognition and Active Shape Models](http://arxiv.org/abs/1207.3538).[[1](#References)]\n",
"\n",
@@ -150,7 +148,7 @@
"Often, the mathematical definition of the RBF kernel is written and implemented as\n",
"\n",
"$$\n",
"\\begin{equation} \\kappa(\\mathbf{x_i, x_j}) = exp\\bigg(- \\gamma \\; \\lVert\\mathbf{x_i - x_j }\\rVert^{2}_{2} \\bigg)\\end{equation}\n",
"\\kappa(\\mathbf{x_i, x_j}) = exp\\bigg(- \\gamma \\; \\lVert\\mathbf{x_i - x_j }\\rVert^{2}_{2} \\bigg)\n",
"$$\n",
"\n",
"where $\\textstyle\\gamma = \\tfrac{1}{2\\sigma^2}$ is a free parameter that is to be optimized.\n"
@@ -166,11 +164,11 @@
"\n",
"In the linear PCA approach, we are interested in the principal components that maximize the variance in the dataset. This is done by extracting the eigenvectors (principle components) that correspond to the largest eigenvalues based on the covariance matrix:\n",
"\n",
"$$\\begin{equation}\\text{Cov} = \\frac{1}{N} \\sum_{i=1}^{N} \\mathbf{x_i} \\mathbf{x_i}^T \\end{equation}$$\n",
"$$\\text{Cov} = \\frac{1}{N} \\sum_{i=1}^{N} \\mathbf{x_i} \\mathbf{x_i}^T$$\n",
"\n",
"Bernhard Scholkopf ([Kernel Principal Component Analysis](http://dl.acm.org/citation.cfm?id=299113) [[2](#References)]) generalized this approach for data that was mapped onto the higher dimensional space via a kernel function:\n",
"\n",
"$$\\begin{equation}\\text{Cov} = \\frac{1}{N} \\sum_{i=1}^{N} \\phi(\\mathbf{x_i}) \\phi(\\mathbf{x_i})^T \\end{equation}$$\n",
"$$\\text{Cov} = \\frac{1}{N} \\sum_{i=1}^{N} \\phi(\\mathbf{x_i}) \\phi(\\mathbf{x_i})^T$$\n",
"\n",
"However, in practice the the covariance matrix in the higher dimensional space is not calculated explicitly (kernel trick). Therefore, the implementation of RBF kernel PCA does not yield the principal component axes (in contrast to the standard PCA), but the obtained eigenvectors can be understood as projections of the data onto the principal components.\n"
]
@@ -186,7 +184,7 @@
"\n",
"In this first step, we need to calculate\n",
"\n",
"$$\\begin{equation} \\kappa(\\mathbf{x_i, x_j}) = exp\\bigg(- \\gamma \\; \\lVert\\mathbf{x_i - x_j }\\rVert^{2}_{2} \\bigg)\\end{equation}$$\n",
"$$\\kappa(\\mathbf{x_i, x_j}) = exp\\bigg(- \\gamma \\; \\lVert\\mathbf{x_i - x_j }\\rVert^{2}_{2} \\bigg)$$\n",
"\n",
"for every pair of points. E.g., if we have a dataset of 100 samples, this step would result in a symmetric 100x100 kernel matrix.\n",
"\n",
@@ -194,7 +192,7 @@
"\n",
"Since it is not guaranteed that the kernel matrix is centered, we can apply the following equation to do so:\n",
"\n",
"$$\\begin{equation} K' = K - \\mathbf{1_N} K - K \\mathbf{1_N} + \\mathbf{1_N} K \\mathbf{1_N} \\end{equation}$$\n",
"$$K' = K - \\mathbf{1_N} K - K \\mathbf{1_N} + \\mathbf{1_N} K \\mathbf{1_N}$$\n",
"\n",
"where $\\mathbf{1_N}$ is (like the kernel matrix) a $N\\times N$ matrix with all values equal to $\\frac{1}{N}$. [[3](#References)]\n",
"\n",
@@ -243,14 +241,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Half-moon shapes"
"### Example 1 - Half-moon shapes"
]
},
{
@@ -454,7 +452,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Projecting new data"
"#### Projecting new data"
]
},
{
@@ -509,7 +507,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Concentric circles"
"### Example 2 - Concentric circles"
]
},
{
@@ -634,7 +632,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -110,7 +110,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sequential Forward Selection (SFS)\n",
"### Sequential Forward Selection (SFS)\n",
"\n",
"\n",
"**Input:** $Y = \\{y_1, y_2, ..., y_d\\}$ \n",
@@ -146,7 +146,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sequential Floating Backward (SBS)\n",
"### Sequential Floating Backward (SBS)\n",
"\n",
"**Input:** the set of all features, $Y = \\{y_1, y_2, ..., y_d\\}$ \n",
"\n",
@@ -183,7 +183,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sequential Floating Backward Selection (SFBS)\n",
"### Sequential Floating Backward Selection (SFBS)\n",
"\n",
"**Input:** the set of all features, $Y = \\{y_1, y_2, ..., y_d\\}$ \n",
"\n",
@@ -228,7 +228,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sequential Floating Forward Selection (SFFS)\n",
"### Sequential Floating Forward Selection (SFFS)\n",
"\n",
"**Input:** the set of all features, $Y = \\{y_1, y_2, ..., y_d\\}$ \n",
"\n",
@@ -281,14 +281,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - A simple Sequential Forward Selection example"
"### Example 1 - A simple Sequential Forward Selection example"
]
},
{
@@ -447,7 +447,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Toggling between SFS, SBS, SFFS, and SFBS"
"### Example 2 - Toggling between SFS, SBS, SFFS, and SFBS"
]
},
{
@@ -574,7 +574,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Visualizing the results in DataFrames"
"### Example 3 - Visualizing the results in DataFrames"
]
},
{
@@ -824,7 +824,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 4 - Plotting the results"
"### Example 4 - Plotting the results"
]
},
{
@@ -884,7 +884,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 5 - Sequential Feature Selection for Regression"
"### Example 5 - Sequential Feature Selection for Regression"
]
},
{
@@ -950,7 +950,7 @@
"collapsed": true
},
"source": [
"## Example 6 -- Using the Selected Feature Subset For Making New Predictions"
"### Example 6 -- Using the Selected Feature Subset For Making New Predictions"
]
},
{
@@ -1061,7 +1061,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 7 -- Sequential Feature Selection and GridSearch"
"### Example 7 -- Sequential Feature Selection and GridSearch"
]
},
{
@@ -1180,7 +1180,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Obtaining the best *k* feature indices after GridSearch"
"#### Obtaining the best *k* feature indices after GridSearch"
]
},
{
@@ -1368,7 +1368,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -102,14 +102,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Grouping related files in a dictionary"
"### Example 1 - Grouping related files in a dictionary"
]
},
{
@@ -173,7 +173,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -89,14 +89,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Grouping related files in a dictionary"
"### Example 1 - Grouping related files in a dictionary"
]
},
{
@@ -151,7 +151,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -53,7 +53,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Gradient Descent (GD) Optimization"
"### Gradient Descent (GD) Optimization"
]
},
{
@@ -102,7 +102,7 @@
"collapsed": true
},
"source": [
"## Stochastic Gradient Descent (SGD) "
"### Stochastic Gradient Descent (SGD) "
]
},
{
@@ -146,7 +146,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Stochastic Gradient Descent Shuffling"
"#### Stochastic Gradient Descent Shuffling"
]
},
{
@@ -195,7 +195,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mini-Batch Gradient Descent (MB-GD)"
"### Mini-Batch Gradient Descent (MB-GD)"
]
},
{
@@ -211,7 +211,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Learning Rates\n",
"### Learning Rates\n",
"\n",
"- An adaptive learning rate $\\eta$: Choosing a decrease constant *d* that shrinks the learning rate over time: $\\eta(t+1) := \\eta(t) / (1 + t \\times d)$\n",
"\n",
@@ -182,7 +182,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.5.1"
}
},
"nbformat": 4,
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -82,14 +82,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Category Scatter from Pandas DataFrames"
"### Example 1 - Category Scatter from Pandas DataFrames"
]
},
{
@@ -214,14 +214,15 @@
"import matplotlib.pyplot as plt\n",
"from mlxtend.general_plotting import category_scatter\n",
"\n",
"fig = category_scatter(x='x', y='y', label_col='label', data=df, legend_loc='upper left')"
"fig = category_scatter(x='x', y='y', label_col='label', \n",
" data=df, legend_loc='upper left')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Category Scatter from NumPy Arrays"
"### Example 2 - Category Scatter from NumPy Arrays"
]
},
{
@@ -292,14 +293,15 @@
"import matplotlib.pyplot as plt\n",
"from mlxtend.general_plotting import category_scatter\n",
"\n",
"fix = category_scatter(x=1, y=2, label_col=0, data=ary, legend_loc='upper left')"
"fix = category_scatter(x=1, y=2, label_col=0, \n",
" data=ary, legend_loc='upper left')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -69,7 +69,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -92,14 +92,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Enrichment Plots from Pandas DataFrames"
"### Example 1 - Enrichment Plots from Pandas DataFrames"
]
},
{
@@ -207,7 +207,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -77,7 +77,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -100,14 +100,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Stacked Barplot from Pandas DataFrames"
"### Example 1 - Stacked Barplot from Pandas DataFrames"
]
},
{
@@ -228,7 +228,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -98,10 +98,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\\\\[ \\begin{pmatrix} \n",
"$$\n",
"\\begin{pmatrix} \n",
"n \\\\\n",
"k \n",
"\\end{pmatrix} = \\frac{n(n-1)\\ldots(n-k+1)}{k(k-1)\\dots1} = \\frac{n!}{k!(n-k)!} \\\\]"
"\\end{pmatrix} = \\frac{n(n-1)\\ldots(n-k+1)}{k(k-1)\\dots1} = \\frac{n!}{k!(n-k)!}\n",
"$$"
]
},
{
@@ -116,13 +118,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\\\\[ \\bigg(\\begin{pmatrix} \n",
"$$\\begin{pmatrix} \n",
"n \\\\\n",
"k \n",
"\\end{pmatrix}\\bigg) = \\begin{pmatrix} \n",
"\\end{pmatrix} = \\begin{pmatrix} \n",
"n + k -1 \\\\\n",
"k \n",
"\\end{pmatrix} \\\\]"
"\\end{pmatrix}$$"
]
},
{
@@ -138,14 +140,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Compute the number of combinations"
"### Example 1 - Compute the number of combinations"
]
},
{
@@ -167,7 +169,8 @@
"from mlxtend.math import num_combinations\n",
"\n",
"c = num_combinations(n=20, k=8, with_replacement=False)\n",
"print('Number of ways to combine 20 elements into 8 subelements: %d' % c)"
"print('Number of ways to combine 20 elements'\n",
" ' into 8 subelements: %d' % c)"
]
},
{
@@ -189,14 +192,15 @@
"from mlxtend.math import num_combinations\n",
"\n",
"c = num_combinations(n=20, k=8, with_replacement=True)\n",
"print('Number of ways to combine 20 elements into 8 subelements (with replacement): %d' % c)"
"print('Number of ways to combine 20 elements'\n",
" ' into 8 subelements (with replacement): %d' % c)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - A progress tracking use-case"
"### Example 2 - A progress tracking use-case"
]
},
{
@@ -242,7 +246,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -98,10 +98,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\\\\[ k!\\begin{pmatrix} \n",
"$$\n",
"k!\\begin{pmatrix} \n",
"n \\\\\n",
"k \n",
"\\end{pmatrix} = k! \\cdot \\frac{n!}{k!(n-k)!} = \\frac{n!}{(n-k)!} \\\\]"
"\\end{pmatrix} = k! \\cdot \\frac{n!}{k!(n-k)!} = \\frac{n!}{(n-k)!}\n",
"$$"
]
},
{
@@ -124,14 +126,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Compute the number of permutations"
"### Example 1 - Compute the number of permutations"
]
},
{
@@ -153,7 +155,8 @@
"from mlxtend.math import num_permutations\n",
"\n",
"c = num_permutations(n=20, k=8, with_replacement=False)\n",
"print('Number of ways to permute 20 elements into 8 subelements: %d' % c)"
"print('Number of ways to permute 20 elements'\n",
" ' into 8 subelements: %d' % c)"
]
},
{
@@ -175,14 +178,15 @@
"from mlxtend.math import num_permutations\n",
"\n",
"c = num_permutations(n=20, k=8, with_replacement=True)\n",
"print('Number of ways to combine 20 elements into 8 subelements (with replacement): %d' % c)"
"print('Number of ways to combine 20 elements'\n",
" ' into 8 subelements (with replacement): %d' % c)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - A progress tracking use-case"
"### Example 2 - A progress tracking use-case"
]
},
{
@@ -228,7 +232,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -67,14 +67,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1"
"### Example 1"
]
},
{
@@ -152,7 +152,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -67,14 +67,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Centering a NumPy Array"
"### Example 1 - Centering a NumPy Array"
]
},
{
@@ -119,7 +119,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -106,14 +106,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Scaling a Pandas DataFrame"
"### Example 1 - Scaling a Pandas DataFrame"
]
},
{
@@ -266,6 +266,7 @@
],
"source": [
"from mlxtend.preprocessing import minmax_scaling\n",
"\n",
"minmax_scaling(df, columns=['s1', 's2'])"
]
},
@@ -273,7 +274,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Scaling a NumPy Array"
"### Example 2 - Scaling a NumPy Array"
]
},
{
@@ -302,7 +303,8 @@
"source": [
"import numpy as np\n",
"\n",
"X = np.array([[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5]])\n",
"X = np.array([[1, 10], [2, 9], [3, 8], \n",
" [4, 7], [5, 6], [6, 5]])\n",
"X"
]
},
@@ -331,6 +333,7 @@
],
"source": [
"from mlxtend.preprocessing import minmax_scaling\n",
"\n",
"minmax_scaling(X, columns=[0, 1])"
]
},
@@ -338,7 +341,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -44,7 +44,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# One-Hot Encoding"
"## One-Hot Encoding"
]
},
{
@@ -65,7 +65,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -98,14 +98,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Defaults"
"### Example 1 - Defaults"
]
},
{
@@ -142,7 +142,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Python Lists"
"### Example 2 - Python Lists"
]
},
{
@@ -178,7 +178,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Integer Arrays"
"### Example 3 - Integer Arrays"
]
},
{
@@ -214,7 +214,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 4 - Arbitrary Numbers of Class Labels"
"### Example 4 - Arbitrary Numbers of Class Labels"
]
},
{
@@ -250,7 +250,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -65,14 +65,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Scaling a Pandas DataFrame"
"### Example 1 - Scaling a Pandas DataFrame"
]
},
{
@@ -134,7 +134,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -65,7 +65,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -113,14 +113,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Standardize a Pandas DataFrame"
"### Example 1 - Standardize a Pandas DataFrame"
]
},
{
@@ -280,7 +280,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Standardize a NumPy Array"
"### Example 2 - Standardize a NumPy Array"
]
},
{
@@ -345,7 +345,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Re-using parameters"
"### Example 3 - Re-using parameters"
]
},
{
@@ -382,7 +382,9 @@
"X_train = np.array([[1, 10], [4, 7], [3, 8]])\n",
"X_test = np.array([[1, 2], [3, 4], [5, 6]])\n",
"\n",
"X_train_std, params = standardize(X_train, columns=[0, 1], return_params=True)\n",
"X_train_std, params = standardize(X_train, \n",
" columns=[0, 1], \n",
" return_params=True)\n",
"X_train_std"
]
},
@@ -430,7 +432,9 @@
}
],
"source": [
"X_test_std = standardize(X_test, columns=[0, 1], params=params)\n",
"X_test_std = standardize(X_test, \n",
" columns=[0, 1], \n",
" params=params)\n",
"X_test_std"
]
},
@@ -438,7 +442,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -101,14 +101,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Ordinary Least Squares Simple Linear Regression"
"### Example 1 - Ordinary Least Squares Simple Linear Regression"
]
},
{
@@ -148,7 +148,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -173,14 +173,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Closed Form Solution"
"### Example 1 - Closed Form Solution"
]
},
{
@@ -236,7 +236,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Gradient Descent"
"### Example 2 - Gradient Descent"
]
},
{
@@ -332,7 +332,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Stochastic Gradient Descent"
"### Example 3 - Stochastic Gradient Descent"
]
},
{
@@ -418,7 +418,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - Stochastic Gradient Descent with Minibatches"
"### Example 3 - Stochastic Gradient Descent with Minibatches"
]
},
{
@@ -504,7 +504,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -113,14 +113,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Simple Stacked Regression"
"### Example 1 - Simple Stacked Regression"
]
},
{
@@ -232,7 +232,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Stacked Regression and GridSearch"
"### Example 2 - Stacked Regression and GridSearch"
]
},
{
@@ -273,7 +273,8 @@
"ridge = Ridge(random_state=1)\n",
"lasso = Lasso(random_state=1)\n",
"svr_rbf = SVR(kernel='rbf')\n",
"stregr = StackingRegressor(regressors=[svr_lin, lr, ridge, lasso], \n",
"regressors = [svr_lin, lr, ridge, lasso]\n",
"stregr = StackingRegressor(regressors=regressors, \n",
" meta_regressor=svr_rbf)\n",
"\n",
"params = {'lasso__alpha': [0.1, 1.0, 10.0],\n",
@@ -346,7 +347,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -90,14 +90,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Defaults"
"### Example 1 - Defaults"
]
},
{
@@ -181,7 +181,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Optional Parameters"
"### Example 2 - Optional Parameters"
]
},
{
@@ -265,7 +265,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -66,7 +66,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -96,14 +96,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Defaults"
"### Example 1 - Defaults"
]
},
{
@@ -253,7 +253,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
+5 -5
View File
@@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -90,14 +90,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Extract Emoticons"
"### Example 1 - Extract Emoticons"
]
},
{
@@ -137,7 +137,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Extract Words and Emoticons"
"### Example 2 - Extract Words and Emoticons"
]
},
{
@@ -177,7 +177,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -79,7 +79,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -123,14 +123,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Gradient Descent"
"### Example 1 - Gradient Descent"
]
},
{
@@ -267,7 +267,7 @@
"collapsed": true
},
"source": [
"### Predicting Class Labels"
"#### Predicting Class Labels"
]
},
{
@@ -293,7 +293,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Predicting Class Probabilities"
"#### Predicting Class Probabilities"
]
},
{
@@ -322,7 +322,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Stochastic Gradient Descent"
"### Example 2 - Stochastic Gradient Descent"
]
},
{
@@ -407,7 +407,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - MNIST"
"### Example 3 - MNIST"
]
},
{
@@ -545,7 +545,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -57,7 +57,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# TensorFlow Softmax Regression"
"## TensorFlow Softmax Regression"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -99,14 +99,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Gradient Descent"
"### Example 1 - Gradient Descent"
]
},
{
@@ -240,7 +240,7 @@
"collapsed": true
},
"source": [
"### Predicting Class Labels"
"#### Predicting Class Labels"
]
},
{
@@ -266,7 +266,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Predicting Class Probabilities"
"#### Predicting Class Probabilities"
]
},
{
@@ -295,7 +295,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Stochastic Gradient Descent"
"### Example 2 - Stochastic Gradient Descent"
]
},
{
@@ -376,7 +376,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 3 - MNIST"
"### Example 3 - MNIST"
]
},
{
@@ -502,7 +502,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -113,14 +113,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Three Blobs"
"### Example 1 - Three Blobs"
]
},
{
@@ -271,7 +271,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
@@ -78,7 +78,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -112,21 +112,21 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Simple Linear Regression"
"### Example 1 - Simple Linear Regression"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Generate some sample data"
"#### Generate some sample data"
]
},
{
@@ -164,7 +164,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Fit regressor and check MSE cost"
"#### Fit regressor and check MSE cost"
]
},
{
@@ -222,7 +222,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Continue training for another 50 epochs"
"#### Continue training for another 50 epochs"
]
},
{
@@ -275,7 +275,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Visualize the regression fit"
"#### Visualize the regression fit"
]
},
{
@@ -382,14 +382,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2 - Multiple Linear Regression"
"### Example 2 - Multiple Linear Regression"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Loading the Boston Housing Data"
"#### Loading the Boston Housing Data"
]
},
{
@@ -421,7 +421,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Fit the regression model"
"#### Fit the regression model"
]
},
{
@@ -468,7 +468,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Evaluate the results"
"#### Evaluate the results"
]
},
{
@@ -506,7 +506,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{
+4 -4
View File
@@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Overview"
"## Overview"
]
},
{
@@ -90,14 +90,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples"
"## Examples"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1 - Counting the iterations in a for-loop"
"### Example 1 - Counting the iterations in a for-loop"
]
},
{
@@ -148,7 +148,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# API"
"## API"
]
},
{