Question: This question is related to machine learning. Any help with generating the training set will be greatly appreciated. Please provide the a python function to

 This question is related to machine learning. Any help with generating

This question is related to machine learning. Any help with generating the training set will be greatly appreciated. Please provide the a python function to generate the training set of size m i.e.

def generate_date(m):

returns the true w as well as X, Y data

1. In this problem, we will compare the performance of three different types of algorithms on a synthetic training set. First, to generate the training set, pick a weight vector w e R10 of dimension 10 at random (normalize it so that its Euclidean norm || 0 || = E: w is equal to 1, i.e., pick w at random (e.g. each entry from N (0,1)) and then take w/ | ||). Then generate a training set of size m of the form {(r+ y),...,1", y)} where each ri e R10 is a random vector of dimension 10 and each entry of r' is chosen from a Gaussian N (0,1) (you may use built-in methods for this). The label ye is 0 or +1 and should be randomly chosen such that y = +1 with probability exactly a(w-r'), where o is the sigmoid function, aka the standard logistic function, and y = 0 otherwise. The goal is to learn w. Algorithm 1 is logistic regression (you may use built-in methods for this). Algorithm 2 is gradient descent where you train a model of the form ow'. I) (with parameter w') with respect to square loss, i.e. the loss function is low. I) y)?, averaged over the points in the training set (code this up yourself, including calculating the gradient). Algorithm 3 is stochastic gradient descent again with respect to square loss, where during each iteration we use the gradient at one random point from the training set. You should measure success as follows: compute ||0 V'| where w' is the weight vector output by your algorithm. For each value of m, do the following several times (say 10 times) and take the average: (a) Generate a fresh w and fresh training data (b) Train your algorithm and obtain v' (c) Calculate || W - '|| Plot the results for all three algorithms for m = 50, 100, 150, 200, 250. For each algorithm, also record the time taken for the entire experiment

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!