The following code shows an incorrect implementation of Adaboost training algorithm. Please point out all the mistakes you can find and what should be the input variables and output variables of weak_classifier_train. def Adaboost_train(train_data, train_label, T): # train_data: N x d matrix # train_label: N x 1 vector # T: the number of weak classifiers in the ensemble ensemble_models = [] for t in range(0,T): model_param_t = weak_classifier_train(train_data, train_label) # model_param_t returns the model parameters of the learned weak classifier # definition of model ensemble_models.append(model_param_t) return ensemble_models
Added by Juan Luis S.
Close
Step 1
The Adaboost algorithm should initialize a weight distribution over the training examples. This is missing in the provided code. We should initialize a weight vector D of size N (number of training examples) with each value as 1/N. Show moreā¦
Show all steps
Your feedback will help us improve your experience
Akash M and 59 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Aarya B.
6. Linear Regression with L2 (Ridge) Regularization def ridge_regression(X, Y, iterations=1000, learning_rate=.01, L2_penalty=1): no_of_training_examples, no_of_features = X.shape np.zeros(no_of_features) for _ in range(iterations): b, W = update_weights(X, Y, no_of_training_examples, learning_rate, L2_penalty) 7. Split the dataset into training and test sets def train_test_split(dataset, split): ### YOUR CODE HERE ### return X_train, Y_train, X_test, Y_test 8. Perform regression algorithm on dataset def evaluate_ridge_regression(dataset, split): X_train, Y_train, X_test, Y_test = functions.train_test_split(dataset, split) # Train the model b, W = functions.ridge_regression(X_train, Y_train, iterations=10000, L2_penalty=0.01) # Make a prediction with the model yhat = functions.predict(X_test, b, W) print("Predicted values:", np.round(yhat[:3], 2)) print("Real values:", Y_test[3]) print("Trained W:", round(W[0], 2)) print("Trained b:", round(b, 2)) visualise(X_test, Y_test, yhat)
Sri K.
Use the concepts discussed in the slides for handwritten dataset. Divide the dataset into train and test set (try 70-30, 80-20 train-test split & see if accuracy varies). Train the following models using the following import statements: (10 points) a. from sklearn.linear_model import LogisticRegression b. from sklearn.tree import DecisionTreeClassifier c. from sklearn.neighbors import KNeighborsClassifier d. from sklearn.discriminant_analysis import LinearDiscriminantAnalysis e. from sklearn.naive_bayes import GaussianNB f. from sklearn.svm import SVC Test the accuracy of each model for the same test data. Generate the heatmap (see below) for the confusion matrix of predictions for each model. (15 points) Find which model has the highest accuracy and what is model accuracy achieved. (5) Try 10 fold cross validation for the models & create a boxplot that shows the accuracy for each model. (20)
Dominador T.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD