DSCI 100 COMPREHENSIVE ANSWERS AND
QUESTIONS SET A+
✔✔evaluate classifier without collecting more data - ✔✔split into training set and testing
set
- only use training set when building the classifier
✔✔What does prediction accuracy calculation assess? - ✔✔It assesses how well our
predictions match the actual labels for the observations in the test set.
✔✔How is prediction accuracy calculated? - ✔✔It is calculated by dividing the number
of correct predictions by the total number of predictions.
✔✔What is a confusion matrix used for? - ✔✔To gain a more comprehensive view of
performance.
✔✔What does a confusion matrix show? - ✔✔How many test set labels of each type are
predicted correctly and incorrectly.
✔✔What is precision in the context of a confusion matrix? - ✔✔Quantifies how many
positive predictions were actually positive.
✔✔What is recall in the context of a confusion matrix? - ✔✔Quantifies how many
positive observations were correctly identified as positive.
✔✔What is the purpose of set.seed in programming? - ✔✔To ensure the result can be
reproduced.
✔✔What happens if the seed value is the same in set.seed? - ✔✔The result will be the
same.
✔✔How does set.seed help with randomness in analysis? - ✔✔It helps ensure the
analysis is fair, unbiased, and not influenced by human input.
, ✔✔cross validation - ✔✔for choosing the best K value
- split the data into validation set and training set
✔✔8 step for KNN classification - ✔✔1. use initial_split to split data into training and
testing set
2. use vfold_cv to split training set for cross-validation
3. create a recipe to specify class label and predictors, preprocess data
4. create a nearest_neighbors model spec, with neighbors - tune()
5. add recipe and model spec to a workflow() and use tune_grid to estimate classifier
accuracy for K values
6. pick a K
7. make a new model spec with K value, and restrain using fit
8. evaluate accuracy using the predict function
✔✔pros and cons of KNN - ✔✔pros
- simple intuitive algorithm
- requires few assumptions about what the data must look like
- works for binary and multi-class classification problems
cons
- becomes very slow with large data sets
- may not perform well with a lot of predictors
- may not perform well when classes are imbalanced
✔✔difference between regression and classification - ✔✔classifications predict
categorical values
regressions predict numerical values
✔✔What is overfitting in machine learning? - ✔✔Overfitting occurs when a model is
influenced too much by the training data.
✔✔What is a consequence of overfitting? - ✔✔A model that overfits will not make
accurate predictions on new data.
✔✔underfitting - ✔✔the model is not influenced enough by the training data
✔✔pros and cons of knn regression - ✔✔pros
- simple, intuitive algorithm
- requires few assumptions about what the data must look like
- works well with non-linear relationships cons
- becomes very slow as the training data gets larger
- may not perform well with a large number of predictors
- may not predict well beyond the range of values input in your training data
✔✔linear regression - ✔✔when there is a big training set the line we draw should
minimize the average squared vertical distance
QUESTIONS SET A+
✔✔evaluate classifier without collecting more data - ✔✔split into training set and testing
set
- only use training set when building the classifier
✔✔What does prediction accuracy calculation assess? - ✔✔It assesses how well our
predictions match the actual labels for the observations in the test set.
✔✔How is prediction accuracy calculated? - ✔✔It is calculated by dividing the number
of correct predictions by the total number of predictions.
✔✔What is a confusion matrix used for? - ✔✔To gain a more comprehensive view of
performance.
✔✔What does a confusion matrix show? - ✔✔How many test set labels of each type are
predicted correctly and incorrectly.
✔✔What is precision in the context of a confusion matrix? - ✔✔Quantifies how many
positive predictions were actually positive.
✔✔What is recall in the context of a confusion matrix? - ✔✔Quantifies how many
positive observations were correctly identified as positive.
✔✔What is the purpose of set.seed in programming? - ✔✔To ensure the result can be
reproduced.
✔✔What happens if the seed value is the same in set.seed? - ✔✔The result will be the
same.
✔✔How does set.seed help with randomness in analysis? - ✔✔It helps ensure the
analysis is fair, unbiased, and not influenced by human input.
, ✔✔cross validation - ✔✔for choosing the best K value
- split the data into validation set and training set
✔✔8 step for KNN classification - ✔✔1. use initial_split to split data into training and
testing set
2. use vfold_cv to split training set for cross-validation
3. create a recipe to specify class label and predictors, preprocess data
4. create a nearest_neighbors model spec, with neighbors - tune()
5. add recipe and model spec to a workflow() and use tune_grid to estimate classifier
accuracy for K values
6. pick a K
7. make a new model spec with K value, and restrain using fit
8. evaluate accuracy using the predict function
✔✔pros and cons of KNN - ✔✔pros
- simple intuitive algorithm
- requires few assumptions about what the data must look like
- works for binary and multi-class classification problems
cons
- becomes very slow with large data sets
- may not perform well with a lot of predictors
- may not perform well when classes are imbalanced
✔✔difference between regression and classification - ✔✔classifications predict
categorical values
regressions predict numerical values
✔✔What is overfitting in machine learning? - ✔✔Overfitting occurs when a model is
influenced too much by the training data.
✔✔What is a consequence of overfitting? - ✔✔A model that overfits will not make
accurate predictions on new data.
✔✔underfitting - ✔✔the model is not influenced enough by the training data
✔✔pros and cons of knn regression - ✔✔pros
- simple, intuitive algorithm
- requires few assumptions about what the data must look like
- works well with non-linear relationships cons
- becomes very slow as the training data gets larger
- may not perform well with a large number of predictors
- may not predict well beyond the range of values input in your training data
✔✔linear regression - ✔✔when there is a big training set the line we draw should
minimize the average squared vertical distance