Skip to content

Commit

Permalink
Merge pull request #10 from kashefy/pca
Browse files Browse the repository at this point in the history
PCA, Online-PCA
  • Loading branch information
kashefy authored Apr 13, 2020
2 parents 9bf8922 + d712ce0 commit a7708b3
Show file tree
Hide file tree
Showing 64 changed files with 1,738 additions and 381 deletions.
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
sudo: required
dist: trusty
#dist: trusty
#language: r
before_install:
- sudo apt-get -qq update && sudo apt-get install -qq -y --no-install-recommends texlive-fonts-recommended
texlive-latex-extra texlive-fonts-extra dvipng texlive-latex-recommended latex-beamer
texlive-science
- sudo apt-get -qq update && sudo apt-get install -qq -y --no-install-recommends texlive-fonts-recommended texlive-latex-extra texlive-fonts-extra dvipng texlive-latex-recommended latex-beamer texlive-science
#- tlmgr install index
#- sudo tlmgr init-usertree
#- tlmgr install --reinstall --repository https://www.komascript.de/repository/texlive/2020 koma-script\
install: skip
script:
- bash .ci/travis/make_all.sh
after_success:
Expand Down
10 changes: 8 additions & 2 deletions latex/headerMIslides.tex
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
\setbeamertemplate{navigation symbols}{}
\usefonttheme[onlymath]{serif}

\title[MI 1 Tutorial]{Machine Intelligence 2 Tutorial}
\title[MI 2 Tutorial]{Machine Intelligence 2 Tutorial}
\institute[www.ni.tu-berlin.de]{Fachgebiet Neuronale Informationsverarbeitung (NI)}
\author[Kashef]{Youssef Kashef}
\date{SoSe 20}
Expand All @@ -93,7 +93,10 @@

\newcommand{\question}[2]{%
\vspace{4mm}%
{Q\thesheetno.\arabic{question}: ~ \textit{#1}%
{Q:~\textit{#1}
%Omit question number from slides because pause and similar will increment anyway
% makes more sense to keep the numbering in the notes version but not so much for the slides
%\thesheetno.\arabic{question}: ~ \textit{#1}%
}\\[5mm]%
\addtocounter{question}{1}%
}
Expand All @@ -103,3 +106,6 @@
\newcommand{\notesonly}[1]{}

\newcommand{\inparaenum}{\enumerate}

% vertical space for slides only
\newcommand{\svspace}[1]{\slidesonly{\vspace{#1}}}
60 changes: 37 additions & 23 deletions latex/minotes.cls
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
\ProvidesClass{minotes}[2019/02/09 0.1]

% packages and classes, scrartcle is an extended article
\LoadClass[a4paper]{scrartcl}
%\LoadClass[a4paper]{scrbook} % has chapters but needs formatting
\LoadClass[a4paper]{scrartcl} % doesn't have chapters - see workaround
\usepackage{etex}
\RequirePackage{scrlayer-scrpage, times, amsmath, amssymb, bm}
\RequirePackage{etoolbox, comment} % not ifthen, xstring,
\RequirePackage[latin9]{inputenc}
\RequirePackage[T1]{fontenc}
\usepackage{hyperref}
\hypersetup{
colorlinks = true, %Colours links instead of ugly boxes
}
\usepackage{titlesec}
\usepackage[overlay,absolute]{textpos}
\usepackage{enumerate}
\RequirePackage{graphics,graphicx}
Expand All @@ -25,7 +30,7 @@
\usepackage{xcolor,cancel}
\usepackage{soul} % for strikethrough


% Margins - BEGIN
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.9 in}
Expand All @@ -34,24 +39,21 @@
\setlength{\headsep}{0.35 in}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
% Margins - END

% TOC - BEGIN
% Requires KOMA-Script version > 3.15
\RedeclareSectionCommand[tocnumwidth=3.0em]{section}
\RedeclareSectionCommand[tocnumwidth=3.5em]{subsection}
\RedeclareSectionCommand[tocnumwidth=4.0em]{subsubsection}
% TOC - END

% Update the following presets
% presets - BEGIN
\newcommand{\coursetitle}{Machine Intelligence 2}
\newcommand{\authorname}{Kashef}
% presets - END

% Custom referencing - BEGIN
% Use custom text for sections, figures and equations
\let\oldeqref\eqref
\renewcommand{\eqref}[1]{Eq. \hspace{-1.0mm}\oldeqref{#1}}

\newcommand{\figref}[1]{Fig. \hspace{-0.5mm}\ref{#1}}
\newcommand{\figureref}[1]{Figure \hspace{-0.5mm}\ref{#1}}

\newcommand{\sectionref}[1]{Section \hspace{-1.0mm}\ref{#1}}
% Custom referencing - END

% The sheet number has to be set before \maketitle
% access it via \thesheetno throughout the document
\newcounter{sheetno}
Expand All @@ -64,6 +66,24 @@
\rule{\textwidth}{1pt}%
\vspace{0.5cm}
}
%\newcommand{\sectionprefix}{T} % check width in toc
\renewcommand*{\thesection}{
%\sectionprefix
\thesheetno.\arabic{section}}
\titleformat{\section}
{}{T\thesection~T}
{0em}{}

% Custom referencing - BEGIN
% Use custom text for sections, figures and equations
\let\oldeqref\eqref
\renewcommand{\eqref}[1]{Eq. \hspace{-1.0mm}\oldeqref{#1}}

\newcommand{\figref}[1]{Fig. \hspace{-0.5mm}\ref{#1}}
\newcommand{\figureref}[1]{Figure \hspace{-0.5mm}\ref{#1}}

\newcommand{\sectionref}[1]{Section \hspace{-1.0mm}\ref{#1}}
% Custom referencing - END

% first page
\deftriplepagestyle{plain}[0pt]
Expand All @@ -77,30 +97,24 @@

\pagestyle{miheadings}

%\setcounter{section}{-1}

% Questions - BEGIN
% a \section like command for questions
\newcounter{question}[section]
\newcommand{\question}[2]{%
\addtocounter{question}{1}% otherwise counter starts at zero
\vspace{4mm}%
{Q\thesheetno.\thesection.\arabic{question}: ~ \textit{#1}%
%{Q\ReplaceStr{\thesection}.\arabic{question}: ~ \textit{#1}%
{Q\thesection.\arabic{question}: ~ \textit{#1}%
}\\
\vspace{5mm}%
}
% Questions - END

% -----------------------------------------------------------------------------

% Hints - BEGIN
% making hints
\newcommand{\hint}[1]{%
\begin{description} \item[Hint:] #1 \end{description}
}
% Hints - END

% Include in slides but exclude from notes
% see corresponding \notesonly for what to include in notes but not in slides mode
\newcommand{\slidesonly}[1]{}

% vertical space for slides only
\newcommand{\svspace}[1]{}
179 changes: 179 additions & 0 deletions notes/00_lagrange/0_intro.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
\section{Introduction}

\definecolor{darkgreen}{rgb}{0,0.6,0}

\mode<presentation>{
\begin{frame}
\only<1,2>{
\frametitle{What \underline{not} to expect from this course}}
\only<3->{\frametitle{Then what \underline{can} we expect from this course?}}
%\vspace{10mm}
\only<2>{
\begin{center}
%Not your typical data science course
\includegraphics[width=5cm]{img/meme_mi2}
\end{center}
}
\only<3->{
\begin{center}
breadth of topics, not necessarily state of the art\\
theoretical aspects of the learning algorithms
\end{center}
}
\only<4->{
\begin{center}
implementing the algorithms - programming exercises.
\end{center}
}
\only<5>{
\begin{center}
%Not your typical data science course
\includegraphics[width=5.5cm]{img/meme_programming}
\end{center}
}

\end{frame}
}

\subsection{Learning Paradigms}

\subsubsection{Supervised learning}

\begin{frame}{\subsecname:~\subsubsecname}

We are given data that is made up of tuples.

Supervised methods try to fit a function that maps $\vec x$ to some attribute $\vec y$ (labels/ground truth).

\begin{center}
\includegraphics[height=3cm]{img/tigerente}
\captionof*{figure}{example image recognition}
\end{center}

Supervised learning would fit a function that maps image pixels to recognizing the object in the image\\
from a set of possible objects (e.g. cat, dog, tiger, duck, frog, bird).

\end{frame}

\subsubsection{Unsupervised learning}

\begin{frame}{\subsecname: \subsubsecname}

We are given data that is made up of observations\pause~\textbf{only}. No other information.

\mode<presentation>{
\begin{center}
\includegraphics[width=4cm]{img/meme_nolabels}
\end{center}
}

\end{frame}

\begin{frame}{\subsubsecname}

\svspace{-5mm}

\question{What can we do when we only have observations?}

\pause

\mode<presentation>{
\only<2>{
\vspace{-5mm}
\begin{center}
\includegraphics[width=5cm]{img/meme_ai}
\end{center}
}
}

\pause

\mode<article>
Unsupervised learning tries to
\mode<all>
find interesting directions and/or structure in the data using only observations $\vec x \in \R^N$.

\begin{center}
\includegraphics[width=9cm]{img/mi2}
\end{center}

``interesting'' and ``structure'' is expressed through the objective model.

\end{frame}

\begin{frame}{\subsubsecname}

\underline{Data}:

A dataset of observations:
\begin{equation}
\label{eq:observations}
\vec X =
\left(
\begin{array}{cccccc}
\Big| & \Big| & & \Big| & & \Big| \\[3mm]
\vec x^{(1)} & \vec x^{(2)} & \cdots & \vec x^{(\alpha)} & \cdots & \vec x^{(p)}\\[2mm]
\Big| & \Big| & & \Big| & & \Big|
\end{array}
\right) \in \R^{N \times p}
\end{equation}
\notesonly{
where $p$ denotes the number of observations (i.e. size of the dataset) and $N$ denotes the number of dimensions.}
\slidesonly{
where
\begin{itemize}
\item[] $p$ \corresponds\, no. of observations (often \iid)
\item[] $N$ \corresponds\, no. of dimensions
\end{itemize}
}
\notesonly{
The samples are often assumed to be \iid, but algorithms for handling sequential data also exist.

Example: $\vec x$ could represent user ratings, pixel values in images.
}
\end{frame}

\begin{frame}{Objective model}

%\svspace{-5mm}
\mode<article>{
\underline{Objective model}:
An unsupervised learning algorithm is used to capture structure or directions in the data. This can be achieved by finding:
}
\begin{itemize}
\item the underlying distribution $P(\vec x)$ that generated this data (e.g. density estimation),
\item $\vec u := \vec f(\vec x)$, where $\vec u$ is a measure of
\begin{itemize}
\item possible structure such as clustering or grouping in the data ($\vec u \in {0,\ldots,K-1}$), \\

\svspace{-5mm}

\begin{center}
\includegraphics[trim=260 0 140 0,clip, width=2cm]{img/mi2}
\notesonly{\captionof{figure}{grouping of data}
}
\end{center}

\svspace{-15mm}

and/or\\

\vspace{7mm}

\item possible directions in the data, by finding another continuous space for describing this data. \\

Example: dimensionality reduction or an embedding space, $\vec u \in \R^M$ with $M < N$.


\svspace{-5mm}

\begin{center}
\includegraphics[trim=0 0 400 0,clip, width=2cm]{img/mi2}
\notesonly{\captionof{figure}{dimensionality reduction}
}
\end{center}

\end{itemize}
\end{itemize}

\end{frame}
10 changes: 9 additions & 1 deletion notes/00_lagrange/1_lagrange.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ \section{Precursor: Method of Lagrange Multipliers}

\definecolor{darkgreen}{rgb}{0,0.6,0}

\begin{frame}\frametitle{\secname}
\begin{frame}
\slidesonly{
\begin{center}\Large
\secname
\end{center}
\pause
}
\begin{center}
\slidesonly{\huge}
Don't panic!
Expand Down Expand Up @@ -164,6 +170,8 @@ \subsection{Adding a single constraint}
}
\end{frame}

\newpage

\subsection{Multiple constraints}

\begin{frame}
Expand Down
4 changes: 2 additions & 2 deletions notes/00_lagrange/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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
# $(compile) --interaction=batchmode $(projname).slides.tex
mv $(projname).slides.pdf $(targetname).slides.pdf

Expand All @@ -23,7 +23,7 @@ handout: $(projname).handout.tex $(projname).tex
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
# $(compile) --interaction=batchmode $(projname).notes.tex
mv $(projname).notes.pdf $(targetname).notes.pdf

Expand Down
Binary file added notes/00_lagrange/img/meme_ai.jpg
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/00_lagrange/img/meme_mi2.jpg
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/00_lagrange/img/meme_nolabels.jpg
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/00_lagrange/img/meme_nolabels2.jpg
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/00_lagrange/img/meme_programming.jpg
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/00_lagrange/img/mi2.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/00_lagrange/img/tigerente.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a7708b3

Please sign in to comment.