Skip to content

Commit

Permalink
density est
Browse files Browse the repository at this point in the history
  • Loading branch information
kashefy committed Mar 3, 2020
1 parent b5d0d6d commit a2d14d3
Show file tree
Hide file tree
Showing 25 changed files with 333 additions and 0 deletions.
72 changes: 72 additions & 0 deletions notes/11_density-est/1_kde.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
\begin{frame}
\end{frame}

\begin{frame}

\section{Density Estimation: What and Why?}
\notesonly{
We observe data.
This data is generated by some unknown probability distribution. Each observation is a sample from this distrubtion.
When we talk about density estimation, we are talking about recovering the underlying probability density function that produced te observed samples.
}

\question{Why do we care about estimating densities? What can we do with an estimated density?}

\begin{itemize}
\item data exploration
\item visualization (for 1D and 2D data)
\item deduce moments (mean, variance, \ldots)
\item describe the data in compact form (e.g. this data follows a Gaussian with mean $\mu$ and covariance $\vec \Sigma$)
\item generate new data
\item unsupervised anomaly detection
\end{itemize}

\end{frame}

\begin{frame}

\underline{Density Estimation: How?}

2 strategies:

\begin{enumerate}[(A)]
\item \textbf{parametric} methods:
\\ We assume that the data follows some class of distribution and we estimate its paramters (e.g. fit a Gaussian around this data)
\item \textbf{non-parametric}\footnote{non-parametric does not means it is void of paramters.
It is just that the parameters do not directly correspond to the classical parameters of densities such as mean and variance.} methods:
data-driven. Estimate the density with as few assumptions as possible (e.g. Kernel\footnote{Not tied to Mercer Kernels like in Kernel PCA. A kernel is just some non-negative function.} density estimation)
\end{enumerate}

\end{frame}

Many people habe already encountered density estimation in the form of histograms.

\begin{frame}
\end{frame}

\begin{frame}

\begin{figure}[ht]
\centering
\savebox{\imagebox}{\includegraphics[width=0.4\textwidth]{img/spiral_data.png}}%
\begin{subfigure}[t]{0.4\textwidth}
\centering
\usebox{\imagebox}% Place largest image
\caption{original observations $\vec x$}
\label{fig:spiral_data}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.35\textwidth}
\centering
\raisebox{\dimexpr.5\ht\imagebox-.5\height}{% Raise smaller image into place
\includegraphics[width=\textwidth]{img/spiral_pca.png}
}
\caption{projection onto the first 2 PCs}
\label{fig:spiral_pca}
\end{subfigure}
\caption{Dimensionality reduction of ``spiral data''. Points are colored according to their index in the dataset.}
\label{fig:spiral}
\end{figure}

\end{frame}

40 changes: 40 additions & 0 deletions notes/11_density-est/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
all: slides notes clean
#all: handout

projname = tutorial
targetname = $(projname)_$(shell basename $(CURDIR))
compile = pdflatex
projnameS = $(projname).slides
projnameH = $(projname).handout
projnameA = $(projname).notes

slides: $(projname).slides.tex $(projname).tex
$(compile) $(projname).slides.tex
# bibtex $(projname).slides
# $(compile) --interaction=batchmode $(projname).slides.tex
# $(compile) --interaction=batchmode $(projname).slides.tex
mv $(projname).slides.pdf $(targetname).slides.pdf

handout: $(projname).handout.tex $(projname).tex
$(compile) $(projname).handout.tex
mv $(projname).handout.pdf $(targetname).handout.pdf

# Repeat compilation for the references to show up correctly
notes: $(projname).notes.tex $(projname).tex
$(compile) $(projname).notes.tex
# bibtex $(projname).notes
# $(compile) --interaction=batchmode $(projname).notes.tex
$(compile) --interaction=batchmode $(projname).notes.tex
mv $(projname).notes.pdf $(targetname).notes.pdf

clean: cleans cleanh cleana

cleans:
rm -f $(projnameS).aux $(projnameS).bbl $(projnameS).log $(projnameS).out $(projnameS).toc $(projnameS).lof $(projnameS).glo $(projnameS).glsdefs $(projnameS).idx $(projnameS).ilg $(projnameS).ind $(projnameS).loa $(projnameS).lot $(projnameS).loe $(projnameS).snm $(projnameS).nav

cleanh:
rm -f $(projnameH).aux $(projnameH).bbl $(projnameH).log $(projnameH).out $(projnameH).toc $(projnameH).lof $(projnameH).glo $(projnameH).glsdefs $(projnameH).idx $(projnameH).ilg $(projnameH).ind $(projnameH).loa $(projnameH).lot $(projnameH).loe $(projnameH).snm $(projnameH).nav

cleana:
rm -f $(projnameA).aux $(projnameA).bbl $(projnameA).log $(projnameA).out $(projnameA).toc $(projnameA).lof $(projnameA).glo $(projnameA).glsdefs $(projnameA).idx $(projnameA).ilg $(projnameA).ind $(projnameA).loa $(projnameA).lot $(projnameA).loe $(projnameA).snm $(projnameA).nav

48 changes: 48 additions & 0 deletions notes/11_density-est/beamercolorthemetub.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
% Copyright 2004 by Madhusudan Singh <[email protected]>
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/licenses/LICENSE for more details.

%\ProvidesPackageRCS $Header: beamercolorthemetub.sty, v a01 2011/11/18 09:11:41 tujl $

\mode<presentation>

\definecolor{darkred}{rgb}{0.8,0,0}

\setbeamercolor{section in toc}{fg=black,bg=white}
\setbeamercolor{alerted text}{fg=darkred!80!gray}

\setbeamercolor*{palette primary}{fg=darkred!60!black,bg=gray!30!white}
\setbeamercolor*{palette secondary}{fg=darkred!70!black,bg=gray!15!white}
\setbeamercolor*{palette tertiary}{bg=darkred!80!black,fg=gray!10!white}
\setbeamercolor*{palette quaternary}{fg=darkred,bg=gray!5!white}

\setbeamercolor*{sidebar}{fg=darkred,bg=gray!15!white}

\setbeamercolor*{palette sidebar primary}{fg=darkred!15!black}
\setbeamercolor*{palette sidebar secondary}{fg=white}
\setbeamercolor*{palette sidebar tertiary}{fg=darkred!50!black}
\setbeamercolor*{palette sidebar quaternary}{fg=gray!15!white}

%\setbeamercolor*{titlelike}{parent=palette primary}
\setbeamercolor{titlelike}{parent=palette primary,fg=darkred}
\setbeamercolor{frametitle}{bg=gray!15!white}
\setbeamercolor{frametitle right}{bg=gray!60!white}

%\setbeamercolor{Beispiel title}{bg=white,fg=black}

\setbeamercolor*{separation line}{}
\setbeamercolor*{fine separation line}{}

%\setbeamercolor{itemize item}{fg=darkred,bg=white}
%\setbeamercolor{itemize subitem}{fg=darkred!60!white,bg=white}
%\setbeamercolor{local structure}{fg=darkred,bg=white}
\setbeamercolor{local structure}{fg=gray,bg=white}
\setbeamercolor{structure}{fg=darkred!80!black,bg=white}
\setbeamercolor{block title}{bg=gray!10!white}
\mode
<all>
22 changes: 22 additions & 0 deletions notes/11_density-est/beamerthemeTUBerlin.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
% Copyright 2004 by Madhusudan Singh <[email protected]>
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/licenses/LICENSE for more details.

%\ProvidesPackageRCS $Header: beamerthemeTUBerlin.sty, v a01 2011/11/18 09:11:41 tujl $
\mode<presentation>

\useinnertheme[shadow=true]{rounded}
\useoutertheme{infolines}
\usecolortheme{tub}

\setbeamerfont{frametitle}{size=\normalsize}
\setbeamerfont{block title}{size={}}
%\setbeamerfont{structure}{series=\bfseries}
\setbeamercolor{titlelike}{parent=structure,bg=white}
\mode
<all>
29 changes: 29 additions & 0 deletions notes/11_density-est/bibliography.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@book{sutton1998introduction,
title={Introduction to reinforcement learning},
author={Sutton, Richard S and Barto, Andrew G and others},
volume={135},
year={1998},
publisher={MIT press Cambridge}
}
@Book{Bertsekas07,
author = {D. P. Bertsekas},
title = {Dynamic Programming and Optimal Control},
publisher ={Athena Scientific},
year = {2007},
volume = {2},
edition = {3rd},
url = {http://www.control.ece.ntua.gr/UndergraduateCourses/ProxTexnSAE/Bertsekas.pdf}
}
@Article{Watkins92,
author = {C. Watkins and P. Dayan},
title = {Q-learning},
journal = {Machine Learning},
year = {1992},
OPTkey = {},
volume = {8},
OPTnumber = {},
pages = {279--292},
OPTmonth = {},
OPTnote = {},
OPTannote = {}
}
Binary file added notes/11_density-est/img/clustering.pdf
Binary file not shown.
Binary file added notes/11_density-est/img/clustering_soft.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notes/11_density-est/img/s_data_pca.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notes/11_density-est/img/s_data_proj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notes/11_density-est/img/section4_fig11.pdf
Binary file not shown.
Binary file added notes/11_density-est/img/section4_fig11_K2.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added notes/11_density-est/img/section4_fig4.pdf
Binary file not shown.
Binary file added notes/11_density-est/img/spiral_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added notes/11_density-est/img/spiral_pca.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions notes/11_density-est/tutorial.handout.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\documentclass[handout,ignorenonframetext]{beamer}
\newcounter{baslide}
\setcounter{baslide}{1}

\let\oldframe
\frame
\let\oldendframe
\endframe

\def\frame{\oldframe \label{baslide\roman{baslide}}%
\addtocounter{baslide}{1}}
\def\endframe{\oldendframe}

\input{tutorial}
17 changes: 17 additions & 0 deletions notes/11_density-est/tutorial.notes.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\documentclass{../../latex/minotes}
\input{../../latex/customcommands}

\numberwithin{equation}{section}
\numberwithin{figure}{section}

\let\oldframe\frame
\let\oldendframe\endframe

\newcommand{\notesonly}[1]{#1}

\newcommand{\mystackrel}[2]{\stackrel{\mathmakebox[\widthof{#1}]{#2}}{=}}

% frame titles only effective in presentation mode
\renewcommand{\frametitle}[1]{}

\input{tutorial}
11 changes: 11 additions & 0 deletions notes/11_density-est/tutorial.slides.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\input{../../latex/headerMIslides}
\input{../../latex/customcommands}

\subtitle{1.1 Intro \& 1.2 Connectionist Neuron}
\mathtoolsset{showonlyrefs}

\newcommand{\slidesonly}[1]{#1}

\newcommand{\mystackrel}[2]{\stackrel{\mathmakebox[\widthof{#1}]{#2}}{=}}

\input{tutorial}
80 changes: 80 additions & 0 deletions notes/11_density-est/tutorial.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
\usepackage[authoryear,round]{natbib}
\usepackage{multirow}

\newcommand{\sheetnum}{%
11
}
%\setcounter{section}{\sheetnum-3}
\newcommand{\tutorialtitle}{%
Density Estimation and Estimation bias
}
\newcommand{\tutorialtitleshort}{%
Density Estimation
}
% for slides
\subtitle{\sheetnum \tutorialtitle}

%\maxdeadcycles=1000 % Workaround for ! Output loop---100 consecutive dead cycles because of too many figures

% The following use of algroithms does not work well with the notes:
%
%
%
%
% instead use the following for your algorithms:
%
%\begin{figure}[!t]
%\removelatexerror
%\begin{algorithm}[H]
% your algo here
%\label{alg:algolabel}
%\caption{algocaption}
%\end{algorithm}
%\end{figure}
%\begin{algorithm}
% Below is the definition for the command \removelatexerror:
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother

\begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\sheet{\sheetnum}{\tutorialtitleshort}

\ttopic{\tutorialtitle}

\columnratio{0.2,0.8}\textbf{}
\begin{paracol}{2}
%\setlength{\columnseprule}{0.1pt}
%\setlength{\columnsep}{5em}

\begin{rightcolumn}

% notes version will ignore it
\begin{frame}
\titlepage
\end{frame}

\begin{frame}
\tableofcontents
\end{frame}

\newpage

\mode<all>
\input{./1_kde}
\mode*

\clearpage

%\section{References}
%\begin{frame}[allowframebreaks] \frametitle{References}
%\scriptsize
%\bibliographystyle{plainnat}
%\bibliography{bibliography}
%\end{frame}

\end{rightcolumn}
\end{paracol}

\end{document}

0 comments on commit a2d14d3

Please sign in to comment.