Skip to content

Commit 681d2f4

Browse files
committed
add SVM related stuff
1 parent 57b633d commit 681d2f4

File tree

10 files changed

+38
-0
lines changed

10 files changed

+38
-0
lines changed
199 KB
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import numpy as np
2+
3+
4+
def gen_synthetic(n,p,sigma):
5+
6+
#Generate X0
7+
X=np.random.normal(size=(n,p))
8+
print ("X0 generated")
9+
10+
w=np.random.uniform(size=(p,1))-0.5
11+
print ("w generated")
12+
13+
14+
Y0 = np.dot(X,w)
15+
Y0 = Y0+np.random.normal(loc=0,scale=sigma,size=(n,1))
16+
17+
Y = np.ones((n,1))
18+
Y[Y0<0]=-1
19+
Y[Y0>=0]=1
20+
21+
return X,Y
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
generate_synthetic_data <- function(n,p,sigma){
2+
X <-matrix(rnorm(n*p),n)
3+
w <- matrix(rnorm(p),p)-0.5
4+
Y0 <- X %*% w
5+
temp <- matrix(rnorm(n,mean=0,sd=sigma))
6+
Y0 <- Y0 + temp
7+
8+
Y <- matrix(rep(1,n),n)
9+
Y[Y0<0] = -1
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function [Y,X] = gen_synthetic_data(n,p,sigma)
2+
X = randn(n,p);
3+
w = rand(p,1) -0.5;
4+
Y0 = X * w + normrnd(0,sigma,n,1);
5+
Y = ones(n,1);
6+
Y(Y0<0) = -1;
7+
end
2.67 MB
Binary file not shown.

CMU-ML/10701/lec/log.Reg.pdf

17.3 MB
Binary file not shown.

CMU-ML/10701/paper/smo-book.pdf

290 KB
Binary file not shown.

CMU-ML/10701/paper/svmtutorial.pdf

641 KB
Binary file not shown.
165 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)