Skip to content

Commit 152afa3

Browse files
committed
update
1 parent acdc7f8 commit 152afa3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2218
-0
lines changed

CMU-ML/10701/HW1_Tex_v3.zip

212 KB
Binary file not shown.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
% Alex' default definitions and packages. Saves time
2+
3+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4+
% ams tools
5+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6+
\usepackage{amsmath}
7+
\usepackage{amssymb}
8+
%\usepackage{amsthm}
9+
10+
\usepackage{mdwlist}
11+
12+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13+
% theorem and friends
14+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15+
\usepackage{theorem}
16+
\newcommand{\BlackBox}{\rule{1.5ex}{1.5ex}} % end of proof
17+
\newtheorem{example}{Example}
18+
\newtheorem{theorem}{Theorem}
19+
\newtheorem{lemma}[theorem]{Lemma}
20+
\newtheorem{assumption}[theorem]{Assumption}
21+
\newtheorem{proposition}[theorem]{Proposition}
22+
\newtheorem{remark}[theorem]{Remark}
23+
\newtheorem{corollary}[theorem]{Corollary}
24+
\newtheorem{definition}[theorem]{Definition}
25+
\newtheorem{conjecture}[theorem]{Conjecture}
26+
\newtheorem{axiom}[theorem]{Axiom}
27+
28+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29+
% fancy fonts
30+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31+
%\usepackage{eucal}
32+
33+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34+
% graph drawing
35+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36+
\usepackage[all]{xy}
37+
\CompileMatrices
38+
39+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40+
% math symbols and commands
41+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42+
\newcommand{\eq}[1]{(\ref{#1})}
43+
\newcommand{\mymatrix}[2]{\left[\begin{array}{#1} #2 \end{array}\right]}
44+
45+
%brackets
46+
\newcommand{\inner}[2]{\left\langle #1,#2 \right\rangle}
47+
\newcommand{\rbr}[1]{\left(#1\right)}
48+
\newcommand{\sbr}[1]{\left[#1\right]}
49+
\newcommand{\cbr}[1]{\left\{#1\right\}}
50+
\newcommand{\nbr}[1]{\left\|#1\right\|}
51+
\newcommand{\abr}[1]{\left|#1\right|}
52+
53+
%sets
54+
\newcommand{\RR}{\mathbb{R}}
55+
\newcommand{\NN}{\mathbb{N}}
56+
\newcommand{\ZZ}{\mathbb{Z}}
57+
58+
%matrix stuff
59+
\newcommand{\one}{\mathbf{1}}
60+
61+
%domains
62+
\newcommand{\Bcal}{\mathcal{B}}
63+
\newcommand{\Mcal}{\mathcal{M}}
64+
\newcommand{\Dcal}{\mathcal{D}}
65+
\newcommand{\Qcal}{\mathcal{Q}}
66+
\newcommand{\Tcal}{\mathcal{T}}
67+
\newcommand{\Fcal}{\mathcal{F}}
68+
\newcommand{\Pcal}{\mathcal{P}}
69+
\newcommand{\Ccal}{\mathcal{C}}
70+
\newcommand{\Ocal}{\mathcal{O}}
71+
\newcommand{\Xcal}{\mathcal{X}}
72+
\newcommand{\Ical}{\mathcal{I}}
73+
\newcommand{\Jcal}{\mathcal{J}}
74+
\newcommand{\Ycal}{\mathcal{Y}}
75+
\newcommand{\Gcal}{\mathcal{G}}
76+
\newcommand{\Zcal}{\mathcal{Z}}
77+
\newcommand{\Ncal}{\mathcal{N}}
78+
\newcommand{\Ucal}{\mathcal{U}}
79+
\newcommand{\Ecal}{\mathcal{E}}
80+
\newcommand{\Hcal}{\mathcal{H}}
81+
\newcommand{\tildi}{\tilde{\imath}}
82+
\newcommand{\tildj}{\tilde{\jmath}}
83+
\newcommand{\bari}{\bar{\imath}}
84+
\newcommand{\barj}{\bar{\jmath}}
85+
86+
%boldface
87+
\newcommand{\Eb}{\mathbf{E}}
88+
89+
%more operators
90+
\DeclareMathOperator*{\argmax}{\mathrm{argmax}}
91+
\DeclareMathOperator*{\argmin}{\mathrm{argmin}}
92+
\DeclareMathOperator*{\sgn}{\mathrm{sgn}}
93+
\DeclareMathOperator*{\tr}{\mathrm{tr}}
94+
\DeclareMathOperator*{\cov}{\mathrm{Cov}}
95+
\DeclareMathOperator*{\var}{\mathrm{Var}}
96+
\DeclareMathOperator*{\mini}{\mathrm{minimize}}
97+
\DeclareMathOperator*{\maxi}{\mathrm{maximize}}
98+
\DeclareMathOperator*{\E}{\mathbb{E}}
99+
100+
101+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102+
% comment tools
103+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104+
\newcommand{\intset}[1]{\cbr{1..n}}
105+
\newcommand{\flexset}[2]{\cbr{{#1}_1, \ldots, {#1}_{#2}}}
199 KB
Binary file not shown.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
\documentclass{article}
2+
3+
\usepackage[usenames,dvipsnames]{color}
4+
\usepackage{hw}
5+
\usepackage{bm}
6+
\usepackage{amsmath}
7+
\usepackage{graphicx}
8+
\usepackage[colorlinks=true,urlcolor=blue]{hyperref}
9+
\usepackage{geometry}
10+
\geometry{margin=1in}
11+
\usepackage{float}
12+
\setlength{\marginparwidth}{2.15cm}
13+
\usepackage{booktabs}
14+
\usepackage{enumitem}
15+
\usepackage{epsfig}
16+
\usepackage{setspace}
17+
\usepackage{parskip}
18+
\usepackage[]{algorithm2e}
19+
\usepackage{comment}
20+
21+
%\newcommand{\comment}[1]{\textcolor{blue}{\textsc{\textbf{[#1]}}}}
22+
23+
% Some commands to allow solutions to be embedded in the assignment file.
24+
\ifcsname issoln\endcsname \else \def\issoln{1} \fi
25+
\newcommand{\soln}[1]
26+
{
27+
\if\issoln 1
28+
{\color{red}
29+
\textbf{Solution:}
30+
#1
31+
}
32+
\fi
33+
}
34+
35+
% SOLUTIONS ENVIRONMENT DEFAULT.
36+
\newenvironment{soln2}{\begin{comment}}{\end{comment}}
37+
% TO SHOW SOLUTIONS, include following (else comment out):
38+
%\renewenvironment{soln2}{
39+
% \leavevmode\color{red}\ignorespaces
40+
% \textbf{Solution:}
41+
%}{}
42+
43+
44+
\newcommand{\norm}[1]{\lVert #1 \rVert}
45+
\newcommand{\st}{\mathrm{s.t.}}
46+
47+
\makeatletter
48+
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
49+
\makeatother
50+
51+
\begin{document}
52+
53+
\section*{}
54+
\begin{center}
55+
\centerline{\textsc{\LARGE Homework 1{\if\issoln 1 Solutions \else \fi}}}
56+
\vspace{0.5em}
57+
\centerline{\textsc{\Large Probability, Maximum Likelihood Estimation (MLE), Bayes Rule, kNN}}
58+
\vspace{1em}
59+
\textsc{\large CMU 10-701: Machine Learning (Fall 2016)} \\
60+
\url{https://piazza.com/class/is95mzbrvpn63d}
61+
\centerline{OUT: September 13th}
62+
\centerline{DUE: September 26th, 11:59 PM}
63+
\end{center}
64+
65+
66+
\section*{START HERE: Instructions}
67+
68+
69+
\begin{itemize*}
70+
71+
\item \textbf{Collaboration policy:} Collaboration on solving the homework is allowed, after you have thought about the problems on your own. It is also OK to get clarification (but not solutions) from books or online resources, again after you have thought about the problems on your own. There are two requirements: first, cite your collaborators fully and completely (e.g., ``Jane explained to me what is asked in Question 3.4''). Second, write your solution {\em independently}: close the book and all of your notes, and send collaborators out of the room, so that the solution comes from you only.
72+
73+
\item\textbf{Late Submission Policy:} You will be allowed 2 total late days without penalty for the entire semester. You may be late by 1 day on two different homeworks or late by 2 days on one homework. Weekends and holidays are also counted as late days. Late submissions are automatically considered as using late days.
74+
\\Once those days are used, you will be penalized according to the following policy:
75+
\begin{itemize}
76+
\item Homework is worth full credit before the deadline.
77+
\item It is worth half credit for the next 24 hours.
78+
\item It is worth zero credit after that.
79+
\end{itemize}
80+
You must turn in at least $n-1$ of the $n$ homeworks, even if for zero credit, in order to pass the course.
81+
82+
83+
\item\textbf{Submitting your work:} Assignments should be submitted as PDFs using Gradescope unless explicitly stated otherwise. Each derivation/proof should be completed on a separate page. Submissions can be handwritten, but should be labeled and clearly legible. Else, submissions can be written in LaTeX. Upon submission, label each question using the template provided by Gradescope.
84+
85+
\item \textbf{Programming}: All programming portions of the assignments should be submitted to Autolab. We will not be using this for autograding, but rather for plagiarism detection, meaning you may use any language which you like to submit.
86+
\end{itemize*}
87+
88+
\newpage
89+
90+
\input{problem1}
91+
\input{problem2}
92+
\input{problem3}
93+
\input{problem4}
94+
\input{problem5}
95+
96+
97+
\end{document}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
\section*{Problem 1: Background Material [20pts] (Devendra \& Hyun-Ah)}
3+
4+
\subsection*{1.1 Probability review (Devendra)}
5+
6+
Consider a naive classifier which stochastically assigns labels to data points; specifically, for each label $l$, it assigns that label with probability proportional to the number of times that label appears in the training dataset. Let the size of training set be $N$, total number of classes be $C$ and $n_i$ be number of datapoints of class $i$ ($\sum_i^C{n_i} = N$), then the probability of labelling a datapoint with class $i$ is $n_i/N$.
7+
8+
1) Consider a training set with $N=100$, $C=2$, $n_1 = 50$, $n_2=50$ and a test set with, $N=100$, $C= 2$, $n_1 = 30$, $n_2 = 70$.\\
9+
a) What is the expected accuracy of the classifier on the training set?\\
10+
b) What is the expected accuracy of the classifier on the test set?\\
11+
12+
2) Now consider a training set with $N=100$, $C=3$, $n_1 = 50$, $n_2=20$, $n_3=30$ and a test set with, $N=100$, $C= 3$, $n_1 = 20$, $n_2 = 20$, $n_3 = 60$.\\
13+
a) What is the expected accuracy of the classifier on the training set?\\
14+
b) What is the expected accuracy of the classifier on the test set?\\
15+
16+
This kind of analysis can be used to calculate a baseline accuracy for various Machine Learning algorithms.
17+
18+
\subsection* {Problem 1.2: Bayes Rule [10 pts] (Hyun-Ah) }
19+
20+
Smith owns a retail store for selling phones. The phones are manufactured at three different factories: $A, B, C$. Factory A, B, and C produces $20\%, 30\%,$ and $50\%$ of the phone being sold at Smith's store. The probabilities of the defective phones from stores $A, B,$ and $C$ are $2\%, 1\%,$ and $0.05\%$, respectively. The total number of phones being sold at Smith's store is $10000$.
21+
One day, a customer walks up to Smith's store, and ask for a refund for a defective phone.
22+
23+
a) What is the probability of a phone being defective?
24+
25+
b) What is the probability that this defective phone is manufactured at factory $A$?
26+
27+
c) What is the probability that this defective phone is manufactured at factory $B$?
28+
29+
d) What is the probability that this defective phone is manufactured at factory $C$?
30+
31+
\newpage
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
\section*{Problem 2: kNN [30 pts] (Hemank)}
2+
3+
In this problem, you will implement K-Nearest Neighbor approach on a synthetic dataset and on the provided dataset\footnote{\url{http://archive.ics.uci.edu/ml/datasets/Iris}}. We will figure out how does various parameters affect the performance of K-NN.
4+
5+
\subsection*{$k$-Nearest Neighbor}
6+
Implement the $k$-nn algorithm and answer the following questions. We will use Euclidean distance for our implementation. For validation, we use $N$-fold cross validation($N=10$).
7+
8+
\textbf{Input Data}: We will generate synthetic input data. The input data will be generated using the code provided in the folder. The code is provided in R, Matlab and Python syntax. The code takes as input the following:
9+
10+
$n$ is the number of samples, $p$ is the dimensionality of the data and $sigma$ determines the amount of noise.
11+
12+
\begin{enumerate}
13+
\item{Why is it suitable to choose odd-$k$?}
14+
15+
\item{Generate $n=1000$ points with $p=10$ and $sigma=0.001$. For different values of $k$, ranging from 1 to 50 (in increments of 5), plot the cross-validation train-error and test-error. What can you say about the effect of $k$? What is the optimal value of $k$, which you can infer from the plot? How does performance changes when you move from smaller values of $k$ to larger values?}
16+
17+
\item{Generate $n=400$ points with $sigma=0.001$. Vary $p$ in range of $2$ to $50$. Run $k$-NN with $k=9$. Plot the cross-validation test-error and comment about effect of dimensionality on the algorithm.}
18+
19+
\item{Generate $n=1000$ points with $sigma=0.001$ and $p=10$. Run $k$-NN with $k=9$. Vary the $N$ for $N$-fold validation from $2$ to $10$ and plot the cross-validation test error. What do you observe from the plot?}
20+
21+
\item{On the given iris dataset, plot with varying $K=1,3,5,7$, the $N$-fold cross-validation test-error.}
22+
23+
\end{enumerate}
24+
\newpage

0 commit comments

Comments
 (0)