Docsity

Machine Learning: Models, Quizzes of Machine Learning

Toggle sidebar
bg1
Machine Learning: Models
DECISION TREES: What are some common uses of decision tree algorithms?
1. Classification
2. Regression
3. Measuring feature importance
4. Feature selection
DECISION TREES: What are the main hyperparameters that you can tune for decision
trees?
Generally speaking, we have the following parameters:
max depth - maximum tree depth
min samples split - minimum number of samples for a node to be split
min samples leaf - minimum number of samples for each leaf node
max leaf nodes - the maximum number of leaf nodes in the tree
max features - maximum number of features that are evaluated for splitting at each node
(only valid for algorithms that randomize features considered at each split)
Other similar hyperparameters may be derived from the above hyperparameters.
The "traditional" decision tree is greedy and looks at all features at each split point, but
many modern implementations allow splitting on randomized features (as seen in sklearn),
so max features is may or may not be a tuneable hyperparameter.
DECISION TREES: xplain how each hyperparameter affects the model's ability to learn.
Generally speaking...
max depth - increasing max depth will decreases bias and increases variance
min samples split - increasing min samples split increases bias and decreases variance
min samples leaf - increasing min samples leaf increases bias and decreases variance
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Machine Learning: Models and more Quizzes Machine Learning in PDF only on Docsity!

Machine Learning: Models

DECISION TREES: What are some common uses of decision tree algorithms?

  1. Classification
  2. Regression
  3. Measuring feature importance
  4. Feature selection DECISION TREES: What are the main hyperparameters that you can tune for decision trees? Generally speaking, we have the following parameters: max depth - maximum tree depth min samples split - minimum number of samples for a node to be split min samples leaf - minimum number of samples for each leaf node max leaf nodes - the maximum number of leaf nodes in the tree max features - maximum number of features that are evaluated for splitting at each node (only valid for algorithms that randomize features considered at each split) Other similar hyperparameters may be derived from the above hyperparameters. The "traditional" decision tree is greedy and looks at all features at each split point, but many modern implementations allow splitting on randomized features (as seen in sklearn), so max features is may or may not be a tuneable hyperparameter. DECISION TREES: xplain how each hyperparameter affects the model's ability to learn. Generally speaking... max depth - increasing max depth will decreases bias and increases variance min samples split - increasing min samples split increases bias and decreases variance min samples leaf - increasing min samples leaf increases bias and decreases variance

max leaf nodes - decreasing max leaf node increases bias and decreases variance max features - decreasing maximum features increases bias and decreases variance There may be instances when changing hyperparameters has no effect on the model. DECISION TREES: What metrics are usually used to compute splits? Gini impurity or entropy. Both generally produce similar results. DECISION TREES: What is Gini impurity? Gini impurity (also called the Gini index) is a measurement of how often a randomly chosen record would be incorrectly classified if it was randomly classified using the distribution of the set of samples. DECISION TREES: What do high and low Gini scores mean? Low Gini (near 0) = most records from the sample are in the same class High Gini (maximum of 1 or less, depending on number of classes) = records from sample are spread evenly across classes DECISION TREES: What is entropy? Entropy is the measure of the purity of members among non-empty classes. It is very similar to Gini in concept, but a slightly different calculation. DECISION TREES: What do high and low Entropy scores mean? Low Entropy (near 0) = most records from the sample are in the same class High Entropy (maximum of 1) = records from sample are spread evenly across classes DECISION TREES: Are decision trees parametric or non-parametric models? Non-parametric. The number of model parameters is not determined before creating the model. DECISION TREES: What are some ways to reduce overfitting with decision trees?

  • Reduce maximum depth
  • Increase min samples split
  • Balance your data to prevent bias toward dominant classes

current error. More and more trees are added to the current model to continue correcting error until improvements fall below some minimum threshold or a pre-decided number of trees have been created. GRADIENT BOOSTING: What hyperparameters can be tuned in gradient boosting that are in addition to each individual tree's hyperparameters? The main hyperparameters that can be tuned with GBM models are: Loss function - loss function to calculate gradient of error Learning rate - the rate at which new trees correct/modify the existing predictor Num estimators - the total number of tress to produce for the final predictor Additional hyperparameters specific to the loss function Some specific implementations, e.g. stochastic gradient boosting, may have additional hyperparameters such as subsample size (subsample size affects the randomization in stochastic variations). GRADIENT BOOSTING: How can you reduce overfitting when doing gradient boosting? Reducing the learning rate or reducing the maximum number of estimators are the two easiest ways to deal with gradient boosting models that overfit the data. With stochastic gradient boosting, reducing subsample size is an additional way to combat overfitting. Boosting algorithms tend to be vulnerable to overfitting, so knowing how to reduce overfitting is important. DIMENSIONALITY REDUCTION: Why would you want to use dimensionality reduction techniques to transform your data before training? Dimensionality reduction can allow you to:

  • Remove collinearity from the feature space
  • Speed up training by reducing the number of features
  • Reduce memory usage by reducing the number of features
  • Identify underlying, latent features that impact multiple features in the original space

DIMENSIONALITY REDUCTION: Why would you want to avoid dimensionality reduction techniques to transform your data before training? Dimensionality reduction can:

  • Add extra unnecessary computation
  • Make the model difficult to interpret if the latent features are not easy to understand
  • Add complexity to the model pipeline
  • Reduce the predictive power of the model if too much signal is lost DIMENSIONALITY REDUCTION: Name four popular dimensionality reduction algorithms and briefly describe them.
  1. Principal component analysis (PCA) - uses an eigen decomposition to transform the original feature data into linearly independent eigenvectors. The most important vectors (with highest eigenvalues) are then selected to represent the features in the transformed space
  2. Non-negative matrix factorization (NMF) - can be used to reduce dimensionality for certain problem types while preserving more information than PCA
  3. Embedding techniques - various embedding techniques, e.g. finding local neighbors as done in Local Linear Embedding, can be used to reduce dimensionality
  4. Clustering or centroid techniques - each value can be described as a member of a cluster, a linear combination of clusters, or a linear combination of cluster centroids By far the most popular is PCA and similar eigen-decomposition-based variations. DIMENSIONALITY REDUCTION: After doing dimensionality reduction, can you transform the data back into the original feature space? How? Yes and no. Most dimensonality reduction techniques have inverse transformations, but signal is often lost when reducing dimensions, so the inverse transformation is usually only an approximation of the original data. DIMENSIONALITY REDUCTION: How do you select the number of principal components needed for PCA?

K-MEANS: What is one common use case for k-mean clustering? Customer segmentation is probably the most common use case for k-means clustering (although it has many uses in various industries). Often, unsupervised clustering is used to identify groups of similar customers (or data points) and then another predictive model is trained on each cluster. Then, new customers are first assigned a cluster and then scored using the appropriate model. K-MEANS: Why is it difficult to identify the "ideal" number of clusters in a dataset using k- mean clustering? There is no "ideal" number of clusters since increasing the number of clusters always captures more information about the features (the limiting case is k=number of observations, i.e. each observation is a "cluster"). Having said that, there are various heuristics that attempt to identify the "optimal" number of clusters by recognizing when increasing the number of clusters only marginally increases the information captured. The true answer is usually driven by the application, though. If a business has the ability to create 4 different offers, then they may want to create 4 customer clusters, regardless of the data. K-MEANS: What is one heuristic to select "k" for k-means clustering? One such method is the elbow method. In short, it attempts to identify the point at which adding additional clusters only marginally increases the variance explained by the clusters. The elbow is the point at which we begin to see diminishing returns in explained variance when increasing k. K-MEANS: Does k-means clustering always converge to the same clusters? How does this affect the use of k-means clustering in production models? No, there is no guarantee that k-means converges to the same set of clusters, even given the same samples from the same population. The clusters that are produced may be radically different based on the initial cluster means selected. For this reason, it is important that the cluster definitions remain static when using k-mean clustering in production to ensure that different clusters aren't created each time during training.

LINEAR REGRESSION: What training algorithms are appropriate for a linear regression on large data sets? Which should be avoided? Appropriate: stochastic gradient descent, mini-batch gradient descent Avoided: normal equation (too computationally complex) LINEAR REGRESSION: What are some reasons that gradient descent may converge slowing and how can you address them? Problem: Low learning rate Solution: Increase the learning rate gradually (avoid making it so high that you jump over minima) Problem: Features have very dissimilar scales Solution: Rescale features using a rescaling technique LINEAR REGRESSION: How do you select the right order of polynomial for polynomial regressions? What if the data is high-dimensional? This is a difficult question and there is no easy way to automate this selection. It is suggested that you inspect the data and try to choose the order of polynomial that will best fit the data without overfitting. If the data is high-dimensional and can't be visualized, then you can train multiple models and observe when the validation error begins to increase instead of decrease. At this point you're probably overfitting your training data and should reduce the polynomial order to the point where validation error is minimized. LINEAR REGRESSION: Is a polynomial regression non-linear? No. It is a linear model that can be used to fit non-linear data. REGULARIZED LINEAR MODELS: Name and briefly explain three regularized linear models.

  • Ridge regression - linear regression that adds L2-norm penalty/regularization term to the cost function
  • Lasso - linear regression that adds L1-norm penalty/regularization term to the cost function
  • Elastic Net - linear regression that adds mix of both L1- and L2-norm penalties terms to the cost function

It is fair to say that it is a classifier because it is used for classification, although it is also technically also a regressor. SVM: What parameters can you tune for SVM? The hyperparameters that you can commonly tune for SVM are:

  • Regularization/cost parameter
  • Kernel
  • Degree of polynomial (if using a polynomial kernel)
  • Gamma (modifies the influence of nearby points on the support vector for Gaussian RBF kernels)
  • Coef0 (influences impact of high vs low degree polynomials for polynomial or sigmoid kernels)
  • Epsilon (a margin term used for SVM regressions) SVM: What are some possible uses of SVM models? E.g. classification, regression, etc SVM can be used for:
  • linear classification
  • nonlinear classification
  • linear regression
  • nonlinear regression SVM: What common kernels can you use for SVM?
  1. Linear
  2. Polynomial
  3. Gaussian RBF
  4. Sigmoid

SVM: Why is it important to scale feature before using SVM? SVM tries to fit the widest gap between all classes, so unscaled features can cause some features to have a significantly larger or smaller impact on how the SVM split is created. SVM: Can SVM produce a probability score along with its classification prediction? No. Regression: Can you explain the difference between Linear and Logistic Regression? Regression: How are the coefficients in a Linear Regression interpreted? Regression: How is the intercept in a Linear Regression interpreted? Regression: Can the coefficients in a Logistic Regression be directly interpreted? Regression: What is the Adjusted R-Squared? What range of values can it take? Regression: Why is the Adjusted R-Squared a better measure than the regular R-Squared? Regression: How does Logistic Regression work "under the hood"? Can you explain Gradient Descent? SVM: Can you explain how a Support Vector Machine works? SVM: What is the kernel trick? SVM: Where does the "support vector" term come in the SVM name? SVM: What kind of kernels exist for SVMs? Trees: How do Decision Trees work? Trees: What criteria does a tree-based algorithm use to decide on a split? Trees: How does the Random Forest algorithm work? What are the sources of randomness? Trees: How is feature importance calculated by the Random Forest? Other Supervised Learning: What is the difference between Bagging and Boosting? Other Supervised Learning: How do Gradient Boosted Machines work? Other Supervised Learning: What is Regularization, and what types do you know? Other Supervised Learning: Can a Random Forest and a GBM be easily parallelized? Why/why not? Unsupervised Learning: How does PCA work? What are the uses cases for it?

https://towardsdatascience.com/l1-and-l2-regularization-methods-ce25e7fc831c What is root cause analysis? "All of us dread that meeting where the boss asks 'why is revenue down?' The only thing worse than that question is not having any answers! There are many changes happening in your business every day, and often you will want to understand exactly what is driving a given change — especially if it is unexpected. Understanding the underlying causes of change is known as root cause analysis." https://towardsdatascience.com/how-to-conduct-a-proper-root-cause-analysis- 789b9847f84b What are hash table collisions? "If the range of key values is larger than the size of our hash table, which is usually always the case, then we must account for the possibility that two different records with two different keys can hash to the same table index. There are a few different ways to resolve this issue. In hash table vernacular, this solution implemented is referred to as collision resolution." https://medium.com/@bartobri/hash-crash-the-basics-of-hash-tables-bef82a8ea What is an exact test? "In statistics, an exact (significance) test is a test where all assumptions, upon which the derivation of the distribution of the test statistic is based, are met as opposed to an approximate test (in which the approximation may be made as close as desired by making the sample size big enough). This will result in a significance test that will have a false rejection rate always equal to the significance level of the test. For example an exact test at significance level 5% will in the long run reject true null hypotheses exactly 5% of the time." https://en.wikipedia.org/wiki/Exact_test In your opinion, which is more important when designing a machine learning model: model performance or model accuracy? https://en.wikipedia.org/wiki/Accuracy_paradox What is one way that you would handle an imbalanced data set that's being used for prediction (i.e., vastly more negative classes than positive classes)? How would you validate a model you created to generate a predictive model of a quantitative outcome variable using multiple regression?

I have two models of comparable accuracy and computational performance. Which one should I choose for production and why? How do you deal with sparsity? Is it better to spend five days developing a 90-percent accurate solution or 10 days for 100- percent accuracy? What are some situations where a general linear model fails? https://www.quora.com/What-are-the-limitations-of-linear-regression-modeling-in-data- analysis Do you think 50 small decision trees are better than a large one? Why? https://www.quora.com/Do-you-think- 50 - small-decision-trees-are-better-than-a-large-one- Why When modifying an algorithm, how do you know that your changes are an improvement over not doing anything? Is it better to have too many false positives or too many false negatives? It depends on several factors. https://www.quora.com/In-Data-Science-is-it-preferable-to-have-too-many-false-negatives- or-too-many-false-positives What is collaborative filtering? Collaborative filtering can be described as a process of finding patterns from available information to build personalized recommendations. You can find collaborative filtering in action when you visit websites like Amazon and IMDB. Also known as social filtering, this approach essentially makes suggestions based on the recommendations and preferences of other people who share similar interests. http://recommender-systems.org/collaborative-filtering/ Can you list some disadvantages related to linear models? There are many disadvantages to using linear models, but the main ones are: Errors in linearity assumptions Lacks autocorrelation It can't solve overfitting problems You can't use it to calculate outcomes or binary outcomes

algorithm from the following: Any classification algorithm Any clustering algorithm Any regression algorithm Any recommendation algorithm Which algorithm you use will depend on the specific problem you're trying to solve. In this scenario, you can move forward with a clustering algorithm and choose a k-means algorithm to achieve your goal of filtering spam from the email system. While examples aren't always necessary when answering questions about artificial intelligence, sometimes it will help make it easier for you to get your point across. https://neelbhatt.com/2017/11/25/how-to-choose-ml-algorithm-machine-learning- questions-answers-part-iii/ When is it necessary to update an algorithm? You should update an algorithm when the underlying data source has been changed or whenever there's a case of non-stationarity. The algorithm should also be updated when you want the model to evolve as data streams through the infrastructure. https://stackoverflow.com/questions/16217844/the-data-has-been-changed-error-when- stepping-from-main-form-into-sub-form What's the difference between inductive, deductive, and abductive learning? Inductive learning describes smart algorithms that learn from a set of instances to draw conclusions. In statistical ML, k-nearest neighbor and support vector machine are good examples of inductive learning. There are three literals in (top-down) inductive learning: Arithmetic literals Equality and inequality Predicates In deductive learning, the smart algorithms draw conclusions by following a truth-generating structure (major premise, minor premise, and conclusion) and then improve them based on previous decisions. In this scenario, the ML algorithm engages in deductive reasoning using a decision tree. Abductive learning is a DL technique where conclusions are made based on various

instances. With this approach, inductive reasoning is applied to causal relationships in deep neural networks. https://www.quora.com/Whats-the-difference-between-inductive-deductive-and-abductive- reasoning What steps would you take to evaluate the effectiveness of your ML model? You have to first split the data set into training and test sets. You also have the option of using a cross-validation technique to further segment the data set into a composite of training and test sets within the data. Then you have to implement a choice selection of the performance metrics like the following: Confusion matrix Accuracy Precision Recall or sensitivity Specificity F1 score For the most part, you can use measures such as accuracy, confusion matrix, or F1 score. However, it'll be critical for you to demonstrate that you understand the nuances of how each model can be measured by choosing the right performance measure to match the problem. https://medium.com/thalus-ai/performance-metrics-for-classification-problems-in-machine- learning-part-i-b085d432082b What would you do if data in a data set were missing or corrupted? Whenever data is missing or corrupted, you either replace it with another value or drop those rows and columns altogether. In Pandas, both isNull() and dropNA() are handy tools to find missing or corrupted data and drop those values. You can also use the fillna() method to fill the invalid values in a placeholder—for example, "0." https://www.analyticsindiamag.com/5-ways-handle-missing-values-machine-learning- datasets/ How is KNN different from k-means clustering? https://www.quora.com/How-is-the-k-nearest-neighbor-algorithm-different-from-k-means- clustering

fold 2 : training [1 2], test [3] fold 3 : training [1 2 3], test [4] fold 4 : training [1 2 3 4], test [5] fold 5 : training [1 2 3 4 5], test [6] How is a decision tree pruned? Pruning is what happens in decision trees when branches that have weak predictive power are removed in order to reduce the complexity of the model and increase the predictive accuracy of a decision tree model. Pruning can happen bottom-up and top-down, with approaches such as reduced error pruning and cost complexity pruning. Reduced error pruning is perhaps the simplest version: replace each node. If it doesn't decrease predictive accuracy, keep it pruned. While simple, this heuristic actually comes pretty close to an approach that would optimize for maximum accuracy. https://en.wikipedia.org/wiki/Pruning_%28decision_trees% Name an example where ensemble techniques might be useful. https://en.wikipedia.org/wiki/Ensemble_learning Ensemble techniques use a combination of learning algorithms to optimize better predictive performance. They typically reduce overfitting in models and make the model more robust (unlikely to be influenced by small changes in the training data). You could list some examples of ensemble methods, from bagging to boosting to a "bucket of models" method and demonstrate how they could increase predictive power. How would you implement a recommendation system for our company's users? https://stackoverflow.com/questions/6302184/how-to-implement-a-recommendation- system# A lot of machine learning interview questions of this type will involve implementation of machine learning models to a company's problems. You'll have to research the company and its industry in-depth, especially the revenue drivers the company has, and the types of users the company takes on in the context of the industry it's in. Why do we need dimensionality reduction techniques? (data compression, speeds up learning algorithm and visualizing data) What do we need PCA and what does it do?

(PCA tries to find a lower dimensional surface such the sum of the squared projection error is minimized) What is the difference between logistic regression and PCA? What are the two pre-processing steps that should be applied before doing PCA? (mean normalization and feature scaling) Describe the k-means algorithm. What is distortion function? Is it convex or non-convex? Tell me about the convergence of the distortion function. Topic: EM algorithm. Describe the EM algorithm intuitively. What are the two steps of the EM algorithm What is the Gaussian Mixture Model? Compare GMM vs GDA. Why does L1 regularization result in sparse models? Bayesian Machine Learning: Compare and contrast maximum likelihood and maximum a posteriori estimation. How does Bayesian methods do automatic feature selection? What do you mean by Bayesian regularization? When will you use Bayesian methods instead of Frequentist methods? (Small dataset, large feature set) How can the SVM optimization function be derived from the logistic regression optimization function? What is a large margin classifier? Why SVM is an example of a large margin classifier? In SVM, what is the angle between the decision boundary and theta? What is the role of C in SVM? What is the mathematical intuition of a large margin classifier? What is a kernel in SVM? Why do we use kernels in SVM? What is a similarity function in SVM? Why it is named so? How are the landmarks initially chosen in an SVM? How many and where?