Question 12 1. Train a Random Forests model where the number of estimators is 100 using the training dataset. 2. Make predictions using the test dataset 3. Compute accuracy and save as accuracy Hints: • You need to use the RandomForestClassifier function. Instantiate a RandomForestClassifier object and pass the number of estimators to the function. Train the model using the X_train and y_train. Then make predictions using X_test. Then compute the accuracy using the predicted values and y_test. • Check Module 6d: Model Performance and _Module 5c: Classification In [162]: # Your code to train random forest, make predictions, and compute accuracy goes in here accuracy = # compute accuracy here Do not alter the below cell. It is a test case for Question 6 In [163]: try: if (accuracy > 0.80): score['question 12'] = 'pass' else: score['question 12'] = 'fail' except: score['question 12'] = 'fail' score Out[163]: {'question 1': 'pass', 'question 2': 'pass', 'question 3': 'pass', 'question 4': 'pass', 'question 5': 'pass', 'question 6': 'pass', 'question 7': 'pass', 'question 8': 'pass', 'question 9': 'pass', 'question 10': 'pass', 'question 11': 'pass', 'question 12': 'pass'}
Added by Andrew R.
Close
Step 1
ensemble and accuracy_score from sklearn.metrics. If you haven't split your dataset into training and testing sets, you'll also need to import train_test_split from sklearn.model_selection. ```python from sklearn.ensemble import RandomForestClassifier from Show more…
Show all steps
Your feedback will help us improve your experience
Supreeta N and 52 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
Consider the training data for the binary classification problem [50]. a. By using the Naive Bayesian Classifier, predict the question marked lines. (First, construct the model by using half of the data by selecting randomly, and then predict the "?" by using the model.) [25]. b. The activation function is given as a step function. Use any neural network model to predict the question marked lines. The neural network model may be run only two times. (First, construct the model by using half of the data by selecting randomly, and then predict the "?" by using the model.) [25].
Adi S.
Problem 1 (Training Error vs. Test Error, ESL 2.9) In this problem, we want to use the least squares estimator to illustrate the point that the training error is generally an underestimate of the prediction error (or test error). Consider a linear regression model with p parameters: y = XB + ε, where εi ~ N(0, σ^2). We fit the model by least squares to a set of training data (x1, y1), ... (xN, yN) drawn independently from the population. Let β^ be the least squares estimate obtained from the training data. Suppose we have some test data (x̃1, ỹ1), ... (x̃M, ỹM) (N ≥ M > p) drawn at random from the same population as the training data. If Rtr(β) = 1/N Σ(yi - β^T xi)^2 and Rte(β) = 1/M Σ(ỹi - β^T x̃i)^2, prove that E[Rtr(β^)] ≤ E[Rte(β^)], where the expectations are over all that is random in each expression.
Sri K.
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