Create a Decision tree classifier in scikit-learn using the data given below: features = [[2, 100], [6, 25], [1, 300], [1, 1000], [4, 100], [10, 100]] Label = [1, 2, 1, 1, 2, 2] Note: 1 - Sports/Race Car and 2 - Family Car
Added by Samuel W.
Step 1
You will need `DecisionTreeClassifier` from `sklearn.tree` and `train_test_split` from `sklearn.model_selection`. ```python from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split ``` Show more…
Show all steps
Your feedback will help us improve your experience
Liam Haas-Neill and 69 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
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.
Answer the following: a.Consider the following data set (with two attributes and two possible classes Y, N) for a binary class problem. The attributes are nominal with two possible values. We intend to create a decision tree. Income H H L H H L L L H H Education L H H L H L L L H L Will Buy N N N Y N Y Y N Y Y Calculate the gain in the Gini index when splitting on Income and Education. Which attribute would the decision tree induction algorithm choose? (3 marks) b.Consider an ensemble of 3 independent 2-class classifiers, each of which has an error rate of 0.3. The ensemble predicts class of a test case based on majority decision among the classifiers. What is the error rate of the ensemble classifier? (3 marks)
Ameer S.
Match each of the prediction probabilities decision boundaries visualized below with the model that created them: 1. KNN (k=1); 2. Neural Network; 3. Decision Tree 1. Decision Tree; 2. Neural Network; 3. KNN (k=1) 1. Decision Tree; 2. KNN (k=1); 3. Neural Network 1. Neural Network; 2. Decision Tree; 3. KNN (k=1)
Sai S.
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