human
I am working on the file "Linear_SVM.ipynb".
The first task is:
You will use here Linear SVM with huberized hinge loss, trained using your gradient descent algorithm. Write a function my-svm for Linear SVM, that can used for training (by calling my-gradient-descent) and testing.
Can you write Python program for it?
 Can you provide a the Python program you requested?
assistant
#Here is the Python program you requested.

class my_svm(object):
    def __init__(self):
        self.learnt_w = None
        
    def fit(self, x_train, y_train, eta=0.01, max_iter=1000):
        x_copy = add_bias_column(x_train)
        self.learnt_w = my_gradient_descent(x_copy, y_train, compute_obj, compute_grad, eta, max_iter)
        
    def predict(self, x_test):
        x_copy = add_bias_column(x_test)
        y = np.dot(x_copy, self.learnt_w)
        y[y<0] = -1
        y[y>0] = 1
        return y
    
    def score(self, x_test, y_test):
        y_predict = self.predict(x_test)
        bools = y_predict == y_test
        accuracy = bools[bools == True].shape[0]/float(bools.shape[0])
        return accuracy