Question: Need help in AI/machine learning assignment 2- In this problem, we will build a binary linear classifier that reads physician notes and guesses whether the

 Need help in AI/machine learning assignment 2- In this problem, weNeed help in AI/machine learning assignment

2- In this problem, we will build a binary linear classifier that reads physician notes and guesses whether the patients are having heart problems (+1) or not (-1). In this problem, you will use the test and train files provided for you (train.csv and test.csv). Also, you must implement the functions without using libraries like Scikit-learn. a) Suppose that we will use a predictor that takes note x and returns sign(w d(x)). Suppose that we wish to use the hinge loss, write out the expression for Losshinge (x, y, w) b) Compute the gradient of the loss. c) Assuming y = 1, what is the largest magnitude that the gradient can take? That is, find a way to set w to make II Loss (x, y, w)l as big as possible. Leave your answer in terms of ll (x)l d) Implement the function extractWordFeatures, which takes a note (string) as input and returns a feature vector (x) (represent the vector (x) as a dictionary in Python). e) Implement the function learnPredictor using stochastic gradient descent and minimize the hinge loss. Print the training error and test error after each iteration to make sure your code is working f) Create an artificial dataset for your learnPredictor function by writing the generateExample function (nested in the generateDataset function). Use this to double check that your learnPredictor works 2- In this problem, we will build a binary linear classifier that reads physician notes and guesses whether the patients are having heart problems (+1) or not (-1). In this problem, you will use the test and train files provided for you (train.csv and test.csv). Also, you must implement the functions without using libraries like Scikit-learn. a) Suppose that we will use a predictor that takes note x and returns sign(w d(x)). Suppose that we wish to use the hinge loss, write out the expression for Losshinge (x, y, w) b) Compute the gradient of the loss. c) Assuming y = 1, what is the largest magnitude that the gradient can take? That is, find a way to set w to make II Loss (x, y, w)l as big as possible. Leave your answer in terms of ll (x)l d) Implement the function extractWordFeatures, which takes a note (string) as input and returns a feature vector (x) (represent the vector (x) as a dictionary in Python). e) Implement the function learnPredictor using stochastic gradient descent and minimize the hinge loss. Print the training error and test error after each iteration to make sure your code is working f) Create an artificial dataset for your learnPredictor function by writing the generateExample function (nested in the generateDataset function). Use this to double check that your learnPredictor works

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!