using PyPlot using NtToolBox fs = 10 Xm = X -> X-repeat(mean(X,1), outer=(size(X,1),1)) Cov = X -> Xm(X)'*Xm(X); A = readdlm("NtToolBox/src/data/quantum.csv", ',') A = A[randperm(size(A,1)),:] X = A[:,1:end-1] y = A[:,end]; y = rescale(y,-1,1); I = find(mean(abs(X),1).>1e-1); X = X[:,I] X = X-repeat(mean(X,1), outer=(size(X,1),1)) X = X ./ repeat( sqrt(sum(X.^2,1)/size(X,1)), outer=(size(X,1),1)); n,p = size(X); I = randperm(n); I = I[1:500] plot_multiclasses(X[I,:],y[I],disp_dim=3,ms=5); L = (s,y) -> 1/n * sum( log( 1 + exp(-s.*y) ) ) E = (w,X,y) -> L(X*w,y) theta = v -> 1 ./ (1+exp(-v)) nablaL = (s,r) -> - 1/n * y.* theta(-s.*y) nablaE = (w,X,y) -> X'*nablaL(X*w,y); include("NtSolutions/ml_4_sgd/exo1.jl"); # Insert your code here. nablaEi = (w,i) -> -y[i] .* X[i,:] * theta( -y[i] * (X[i,:]'*w) ); l0 = 100 tau0 = .05; include("NtSolutions/ml_4_sgd/exo2.jl"); # Insert your code here. include("NtSolutions/ml_4_sgd/exo3.jl"); # Insert your code here. include("NtSolutions/ml_4_sgd/exo4.jl"); # Insert your code here.