Flashcards
Final Exam
Cards in this deck (163)
- 1simple regressiononly uses one independent variable
- 2error (or residual) in a regressionhow far off was our estimate?
- 3what does R-square telling you in a regression output?% of variation in the dependent variable explained by the independent variable
- 4what is the R-Squared also known as?coefficient of determination
- 5what is the standard error in a regression output?similar to the std dev -- is the std error of a prediction
- 6what do p-values indicate in a regression output?the significance of the model and the independent variable
- 7Multiple Regressionmore than one independent variable
software will find the set of betas that minimize the total squared errors - 8Adjusted R Squareit is R square but just adjusts for
- 9What does "Significance F" in an ANOVA table mean?the significance of the entire model
- 10True or False: Regression was intended for numeric variables.TRUE
- 11Script in R: attitude.MLRInteractionmodel <- lm(rating ~ complaints + privileges + learning + raises + critical + advance, data=attitude) what is the "rating" part of the scripty variable - dependent variable
- 12what does the "lm" function in R do?runs a regression
- 13what is the interaction term in a regression?attitude.MLRInteractionmodel <- lm(rating ~ complaints + privileges + learning + raises + critical + advance + critical*advance, data=attitude)
thee critical * advance - 14prior to making a prediction in R with forecasting, what do you have to do and with what command?create a data frame
- 15what does "c ( ...)" do in a prediction regression model?to predict ratings for three new branches with values the variable
- 16what happens when a regression is trying to be run, but there is qualitative data?the data must be turned into dummy variables
- 17what are dummy variables also called?indicator variables
- 18true or false: Dummy Variables are binary.TRUE
- 19what does binary mean?Two answers:
Yes / No
Male / Female
Weekend / Weekday - 20Dummy Variablequalitative data that is binary and assigns one category of a value 0 and the other value 1
treated like any other independent variable - 21true or false: when you have more than two dummy variables, you can give them the values 2,3,4.false -- binary only can use 0 and 1
- 22can you plug in values of a dummy variable into a regression to find a prediction of y?yes, it will handle these just fine and will be able to make predictions same as other variables
- 23what do we do if there are more than 2 categories for a dummy variable?treat one category as default then create a / dummy variable for each other category
- 24example of having more than 2 categories for a dummy variable?if the variable can be "red," "yellow," or "green," treat red as the default, and create two dummy variables: one for yellow, and one for green
- 25when forecasting with regression, what can it capture?(additive) seasonality using a set of dummy variables
a linear trend if we include a "time" variable that orders the data points - 26can you make an assessment of importance on a dummy variable?DO NOT MAKE ASSESMENT OF COEFFICENT ON DUMMY VARIABLE of "importance" - but you can make inferences on the sign of the coefficient
- 27what is the key function in R when creating dummy variables?The key function is model.matrix. It will create a dummy variable for each value of a category variable and store them in a new data set
- 28what are the pros of forecasting with regression?Can incorporate additional independent variables (besides time)
More software options - 29what are the cons of forecasting with regression?Can't easily capture non-constant trends or seasonal effects
Computationally much more intensive if we're going to forecast many periods - 30what is a reasonable assumption of regression?regression treats the effect of each independent variable as independent of one another
- 31what does regression ignore when capturing interactions between variables?synergistic or anti synergistic effects between variables
- 32true or false: dummy vriables shift the regression line up or down and also can change the slope of the line.false. cannot change the slope of the line
- 33if you want to see the reaction between X1 and X2 in a model, what must you do?create a new variable whose value is X1 *X2
this will capture a non-additive relationship in their effects of Y - 34what are some of the shortcomings of regression?captures additive linear effects -- but cannot really expand from here
sensitive to outliers
"Parametric"
Prone to mistakes with a very large number of variables - 35what do we mean when we say regressions are "parametric"?Uses a mathematical model with implicit assumptions of how variables relate to one another
- 36what type of models have we used for predicting with a smaller dataset?regression
forecasting time series - 37what are some more flexible methods for larger datasets when predicting?KNN
classification / regression trees
logistic regressions - 38Why can predictive models be made difficult?Curse of Dimensionality
- 39Curse of Dimensionalitymany difficulties arise as the number of variables becomes large
The "space," which is very difficult to visualize, becomes huge - 40what does it mean when we day that most predictive models (except for time series) rely on multivariate data?predict one variable based on other
- 41true or false: Most all predictive models are complex.false they can range from very simple to extremely complex
- 42what does k-nearest neighbor do?To predict an outcome for a new data point, use the k most similar data points from the data set
- 43what are the steps to k-nearest neighbors?1. identify the k most similar points
2. take the average outccome of those k points - 44how do we choose k?-k=1 considers the single most similar data point
-k=n gives us an average or classification based on every data point - 45what is the tradeoff with knn?similarity is good, but random noise is bad
- 46what is the main different in regression than the other predictive models?we based the model on all of the available data because it gives us better predictions
- 47Difference in comparing two regression models versus comparing two KNN models?Easy to compare two regression models but not as easy to do a comparison of k-nearest neighbors.
- 48what is the main package used inn R for KNN?fnn
- 49what is a good way to compare KNN models?partitioning
- 50what are you doing when you partition data?set aside a portion of the data when building the models, then use that data to check how well each model predicts the "future"
- 51what are the two sets that the data points are split into when partitioning data?training set
validation/test set - 52what is the training set used for in partitioning data?The training set is used to build candidate models, and is typically the largest
- 53steps of partitioning data1. Split the data points randomly into sets
2. Use the models to predict the outcomes for the data points in the other set(s)
3.Evaluate the models' predictions against the actual outcomes - 54before partitioning in R, what must you do?set.seed function sets the starting point for random number generation
- 55how do you evaluate the predictions in partitioning data with the actual outcomes?All models produce the same error metric (want to minimize)
Root mean squared error (RMSE) for numeric outcomes - 56what does this line of R code do? training <- sample (1:1000, 600)stores 600 different randomly chosen integers from 1 to 1000 in an object called training
- 57when do you partition data?always do this before building predictive models in R
(except regression) - 58what function in R is used to partition data?sample function
- 59when comparing multiple different methods, how many times should we partition?we only need to partition once, and then build each model using the same training set
- 60what does it mean when we run a loop in KNN?the loop tries a range of values for k to find which gives the most accurate predictions
- 61what does a loop check?checks to see if the current RMSE beats the best RMSE observed so far
- 62in the loop: best.k <- -1 RMSE <- -1 best.RMSE <- 99999999 for (i in 1:50) { lc.knn <- knn.reg(lc.training, lc.test, lc.training.results, k=i) RMSE <- (mean((lc.knn$pred - lc.test.results)^2))^0.5 if (RMSE < best.RMSE) { best.k <- i best.RMSE <- RMSE } } print(paste("The optimal value of k is",best.k,"with a RMSE of",best.RMSE)) what does best.k<--1 mean?the best value for k
- 63in the loop: best.k <- -1 RMSE <- -1 best.RMSE <- 99999999 for (i in 1:50) { lc.knn <- knn.reg(lc.training, lc.test, lc.training.results, k=i) RMSE <- (mean((lc.knn$pred - lc.test.results)^2))^0.5 if (RMSE < best.RMSE) { best.k <- i best.RMSE <- RMSE } } print(paste("The optimal value of k is",best.k,"with a RMSE of",best.RMSE)) what does RMSE<- 999999 mean?this needs to be large enough so all RMSE are smaller than this
trying to find smallest rmse - 64in the loop: best.k <- -1 RMSE <- -1 best.RMSE <- 99999999 for (i in 1:50) { lc.knn <- knn.reg(lc.training, lc.test, lc.training.results, k=i) RMSE <- (mean((lc.knn$pred - lc.test.results)^2))^0.5 if (RMSE < best.RMSE) { best.k <- i best.RMSE <- RMSE } } print(paste("The optimal value of k is",best.k,"with a RMSE of",best.RMSE)) what does "(i for 1:50) mean?This loop checks values of k from 1 to 50.
- 65in R, if you wanted to remove the name column, how would you do so?data <- data[,-1]
- 66what does the .6 in this command mean? training <- sample(1:nrow(dc), 0.6*nrow(dc))The following command will randomly select 60% of the row numbers in the data set to represent the training data
- 67what does the "==" mean in this function: sum(DC.knn == DC.test.results) / length(DC.test.results)?comparison -- gives you how many times the knn model and the actual results are equal
- 68in the command: DC.knn.new[1:nrow(DCnew)] what does "nrow" mean?the last row
- 69what command do you use to change a column name in R?names(data) [column] <- NewName
- 70when creating a classification tree in R, what does "mindev" mean in this code? DC.tree <- tree(DEDUCTIBLE ~ ., data=dc[training,], mindev=0.001)how much variation you allow in the tree -- increase in mindev, smaller the tree
- 71when running a logistic regression in R, what does the code: DC.test.probabilities <- predict(DC.lr,DC.test,type = "response") do?creates a list of the model's probabilities of each organization in the test set having tax-deductible donations
- 72when running logistic regression in R, what does DC.lr.classifications <- round(DC.test.probabilities,0) do?The following command converts the probabilities to binary 0/1 classifications
to see overall accuracy have to convert to binary - 73Regression Treesgrouping together data points that will likely have similar outcomes
By similarity that means the outcomes have a small variance - 74what type of outcomes do regression trees work on?quantitative
- 75Explain how you make a regression tree.Split the data repeatedly into successively smaller groups that have similar outcomes
Each split is done in a way that minimizes the variances within the two resulting subgroups -- splitting created two more branches of the tree
Once we're finished, each endpoint of the tree is a group of similar data points from the training set - 76how do you make a prediction with a regression tree?1.Determine which group the data point would fall into
2.Use the average outcome from that group as the prediction - 77when do you stop growing a regression tree?you do not want to overfit a tree.
the model would be so detailed that it would predict training set 100% but would do very poorly with future data - 78when do you know to split a group in Regression Trees?Only split a group if the average outcomes for the two smaller groups are sufficiently different
- 79what is the most popular package in R for regression trees?tree package
can build a tree and change any of the several parameters to control the size of the tree - 80what does the mindev parameter call for?the amount of variation you are allowing in the tree. the smaller the mindev- the bigger the tree
- 81what is problem with using regression trees sometimes?Regression trees can be overly sensitive to outliers in the training set
- 82what can be an improvement of a regression tree?Ensemble trees
- 83what do ensemble trees do?Basic idea is to create lots of weaker regression trees using the training set, and aggregate their predictions
making a bunch of trees and seeing the mistakes - 84what are two types of methods of ensemble trees?Bagging (bootstrap aggregation)
Random trees (a.k.a. "random forests") - 85Bagging with Ensemble TreesCreate lots of regression trees
Each tree is based on a random sample of the training set
Use the average prediction - 86what is bagging with Ensemble trees good for?Good for reducing the effect of outliers in the training set
- 87Random Trees with Ensemble TreesCreate lots of regression trees
Each tree uses only a random subset of the variables
Use the average prediction - 88what is random trees with Ensemble Trees good for?Works well when the number of relevant variables is large
If you have a lot of variables that have real but small affects - this will get picked up in the tree - 89what is not good to use Random Trees with Ensemble Trees for?Will not be good if you have small amount of variables with high affects
- 90how can you use KNN with binary variables?classification trees
- 91Classification TreesFor a binary outcome variable
Splits each group attempting to get as close as possible to all 0s and 1s in each of the two smaller groups
At each endpoint of the tree, reports the proportion of 1s in that group - 92true or false: classifications are binary.TRUE
- 93Classification accuracyproportion of points in the test set that the model classifies correctly
- 94how do you find classification accuracy?num of correct predictions / num of points in test set
- 95for the best classification accuracy you want to..Maximize this, or alternatively, minimize error rate
- 96how do you find the error rate of a classification?1 - classification accuracy
- 97what are the two types of errors in classification accuracy?Two types of errors (predict FALSE, result is TRUE, and predict TRUE, result is FALSE)
- 98Logistic RegressionClassification method that tries to estimate P(0) and P(1)
- 99what is the difference between a regression and logistic regression?Predicts a probability rather than a numeric variable
- 100true of false: the relationship between the independent variables and probability is usually very non-linear.TRUE
- 101what does logistic regression allow us to do that we cannot do in a regular regression?Logistic regression is a trick that allows us to use regression to estimate probabilities
- 102what is the function in R to create Logistic Regressions?glm
- 103what function in R can help find probabilities of a logistic regression?predict function
- 104what are some of the main elements of alignments in designing an effective table?Left-align text in table
Right-align numbers in table
Center column headers, or match data alignment - 105true or false: in designing an effective table, you should use commas on large numbers.TRUE
- 106what does this line in R create? ggplot(mtcars,aes(y=hp,x=disp)) + geom_point()scatterplot
- 107what does "aes" in this code in R mean when creating s scatter plot?The "aes" function adds an "aesthetic" to the chart. An aesthetic describes visible properties of the chart
- 108what does "geom" mean in the R code when creating a scatterplot?A "geom" is a geometric object that represents data
- 109what are the different types of "geom"s that can be run in R when creating chartsgeom_line -- line plot
geom_bar -- bar plot
geom_point --scatter plot
geom_histogram -- histogram - 110what does the function "geom_abline" mean in R?add lines to plots
- 111what does "ggplot" in R code do?creates a visualization
- 112what does the following line of R code do? ggplot(patients, aes(y=pulse,x=age)) + geom_point()creates a scatterplot of patients' age and pulse
- 113in this code, ggplot(mtcars,aes(y=hp,x=disp)) + geom_point(aes(color = wt)) what does "wt" mean?color is based on the weight
- 114what is a Sparkline?A very small line chart, with no axes or labels
Meant to be embedded in text, near relevant data, or as part of a dashboard - 115what is a Radar Chart?Useful for multivariate data
Display values or performance across several metrics - 116what is a Radar-GIS Chart useful for?Display geographic data, typically on a map
- 117what does the ggplot2 pack in R do?grammar of graphics
- 118what is a Tableau?Powerful & flexible software package for visualizing data
- 119what is the most important element in designing effective charts?choosing the correct type
- 120what are some good practices in the designing of effective charts?Label axes
Make distinct lines, bars, or sets of points that overlap visually easy to distinguish (e.g. use contrasting colors)
Don't duplicate labels
Don't get too fancy -- avoid chartjunk
Minimize lie factor - 121what is chartjunk?Anything visible that conveys no meaning
- 122what is a lie factor in designing charts?The degree to which ratios are misrepresented
distorting ratios between values - 123what is an example of a high lie factor?the y-axis begins at a high number
- 124what are some general ideas you should do before presenting?know your audience
know your purpose
use numbers and words - 125what should you know about your audience prior to presenting?How numerate are they?
How well do they know the subject matter?
In what form(s) are they accustomed to seeing this kind of information?
How much detail do they expect? - 126what should you know about your purpose of presenting before doing so?Are you trying to inform or persuade?
Either way, present data & results honestly - 127if you are trying to just inform in a presentation what should you do?If trying to inform, explain takeaways and any relevant pros & cons of choices
- 128if you are trying to persuade in a presentation what should you do?If trying to persuade, provide an argument that's supported by the quantitative results
- 129what is the problem with just using words and not numbers in a presentation?Language describing uncertainty is vague; "likely" means different things to different people
Might be interpreted incorrectly or inconsistently - 130what is the problem with using just problems with numbers and not words?Might not provide enough context for everyone
Might have people who are not numerate - 131true or false: Descriptive and predictive models are inputs to decisionsTRUE
- 132when making a decision with prescriptive analytics what do we have to consider?When making a decision, need to consider:
Alternatives: what are our choices?
Objective: what is it we're trying to maximize/minimize?
Uncertainties: what are the unknown factors that can affect the result? - 133what does prescriptive analytics heavily rely on?prescriptive models
- 134assumption of prescriptive models?Models: models always leave stuff out - simplified versions of the real life problem
Any model you use will have assumptions - 135Ex: for a pharmaceutical company deciding whether to run clinical trials on a new heart medication or not.. what would be the alternatives, objective, uncertainties?alternatives: run trials, don't run trials
objective: maximize profit
uncertainties: will the trial demonstrate that the medication is effective? - 136what is the most common and important concept for decisions with uncertainty?Expected Value
- 137true or false: Expected Value always solves every piece of the problem.False-- Not going to solve every piece of the problem but always a good start
- 138Expected Valuethe weighted average of all of the possible results
- 139example: If an investment has an 80% chance of losing $1000, and a 20% chance of gaining $5000, what is the Expected Value?=0.8*-1000 + 0.2*5000
= -800 + 1000
=$200 - 140what is the decision rule that is usually most accurate?Expected Value
- 141what is an example where you would not want to use Expected Value as the decision rule?Car Insurance - because it would be negative
It protects you is TERRIBLE instances - only happens once - 142what is expected value good for when making a decision?smaller decisions
repeated decisions
decisions with no disastrous possible outcomes - 143what is expected value bad for when making a decision?large one-time decisions
risk analysis - 144what is a decision tree?A structure illustrating a sequence of decisions and uncertainties with a result, expressed in terms of our objective, at each possible end of the tree
- 145what are decision tree also called?discrete decision choice
- 146true or false: decision trees are the same as regression and classification trees.FALSE
- 147what is the hardest part in making a decision tree?going from the real world problem to making the tree - once drawn it is easy to use - going from words to tree
- 148once the decision tree is made, how do you choose what decision?1st: choose the branch with the BEST EV - not always the highest - maybe you are wanting to minimize
- 149路 Sensitivity Analysisexplores how changes in parameter values affect our decision
- 150when is a sensitivity analysis often used?with large/complex models, or when some inputs are subjective
- 151what do sensitivity tests ask?what if questions
if a variable changes a decision -- is it sensitive?
if we choose an alternative is it robust to the parameters? - 152how do we know if a decision is "sensitive"?The decision is sensitive to a parameter if small or likely changes in its value change the choice of alternative
- 153how do we know if an alternative is "robust"?An alternative is robust if it is desirable under many or most possible or likely changes in parameter values
- 154what does a one-way sensitivity analysis examine?how the best decision depends on one particular parameter
uses sliders in Excel - 155when is optimization used?sometimes the number of possible alternatives are enormous -- so use this instead of decision tree if you have more than just a couple of choices
- 156example of when to use Optimization?large furniture retailer is deciding how many tables, desks, and chairs to order this month
"35 tables, 25 desks, and 140 chairs" is one alternative - 157what is the first step in Optimization?Instead of specifying each alternative, specify what the decision variables are
for the example the variables are: -Number of tables (T), number of desks (D), number of chairs (C) - 158what are the steps to optimization?specifying each alternative, specify what the decision variables are
We also need to specify constraints
Find Values of decision variables that maximize profit while meeting the constraints - 159can we calculate optimization on our own?Optimization is done with software
Excel Solver (free optimization add-in that comes with Excel)
Lots of more advanced software for larger or more complex optimization problems - 160how do you specifically identify if the analytics are prescriptive and not just descriptive or predictive?a decision is directly made
- 161what is the only method that produces a probability as an output?logistic regression
- 162which method gives you the likelihood of a scenario but not the probability?Classification Tree
- 163Logistic Regressionwhich method gives you the likelihood of a scenario but not the probability?