1. 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). 2. 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 3. 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) 4. Find which model has the highest accuracy and what is model accuracy achieved. (5) 5. Try 10 fold cross validation for the models & create a boxplot that shows the accuracy for each model. (20)
Added by Justin D.
Close
Step 1
Divide the dataset into a train and test set: - Use a train-test split function from sklearn.model_selection to split the dataset into a training set and a test set. You can specify the test size as 0.3 or 0.2 depending on whether you want a 70-30 or 80-20 Show more…
Show all steps
Your feedback will help us improve your experience
Dominador Tan and 65 other Intro Stats / AP Statistics 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
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.
Supreeta N.
Use the data in INTQRT for this exercise. (i) Using the data from all but the last four years $(16$ quarters), estimate an $\mathrm{AR}(1)$ model for $\Delta r 6$ . (We use the difference because it appears that $r 6,$ has a unit root.) Find the RMSE of the one- step-ahead forecasts for $\Delta r 6,$ using the last 16 quarters. (ii) Now, add the error corre assumes that the cointegrating parameter is one.) Compute the RMSE for the last 16 quarters. Does the error correction term help with out-of-sample forecasting in this case? (iii) Now, estimate the cointegrating parameter, rather than setting it to one. Use the last 16 quarters again to produce the out-of-sample RMSE. How does this compare with the forecasts from parts (i) and (ii)? (iv) Would your conclusions change if you wanted to predict $r 6$ rather than $\Delta r 6 ?$ Explain.
Recommended Textbooks
Elementary Statistics a Step by Step Approach
The Practice of Statistics for AP
Introductory Statistics
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD