Assignment 4 for Lecture 4 - Baseline Models - Chapter 5 
 

1.  Fill-in-the-blank: A __________  ___________ algorithm provides a set of predictions that you can evaluate as you would any predictions for your problem.

•   Baseline prediction

2.  List the two most used baseline algorithms.

•   Random Prediction Algorithm.
•   Zero Rule Prediction Algorithm

3.  When starting on a new problem that is more difficult than a conventional classification or regression problem, which baseline algorithm should we devise first?

•   Random Prediction Algorithm

4.  Fill-in-the-blank: The ___________  _________ algorithm predicts a random outcome as observed in the ____________  ___________ .

•   random prediction algorithm
•   training data

5.  What is it that the random prediction algorithm requires with respect to data storage?

•   the data storage requirements for the random prediction algorithm are minimal, as it does not use or rely on any data storage to generate its outputs.

6.  Why is it a good idea to fix the random number seed prior to using the random prediction algorithm?

•   to ensure that we get the same set of random numbers, and in turn the same decisions each time the algorithm is run

7.  What does the function, random_algorithm( ), do?

•   It takes both a training dataset that includes output values and a test dataset for which output values must be predicted

8.  Fill-in-the-blank:  The random prediction function will work for  both ________  ________ problems.

•   classification and regression problems

9.  Fill-in-the-blank: The random prediction function assumes that the output value in the training data is the _______  ________ for each row.

•   Final column

10. How are unique output values selected for each row in the test set?

•   It is selected for each row in the test set.

11. Fill-in-the-blank: Output values in the training dataset are __________ .


•   Are either 0 or 1

12. Will the calculated random predictions be placed in  the training dataset, or the test dataset?

•   Test dataset

13. Fill-in-the-blank: The _________  __________ algorithm is a better baseline than the random prediction algorithm.

•   Zero Rule Algorithm

14. When working with classification problems, what is the one rule for the zero rule algorithm?

•   To predict the class value that is most common in the training dataset.

15. What does the function, zero_rule_algorithm_classification( ), do?

•   It implements the zero rule algorithm for the classification case

16. Given a list of class values observed in the training data, the max( ) function takes a set of unique class values and returns what kind of class values?

•   it returns the class value that has the highest count of observed values in the list of class values observed in the training dataset

17. If all class values have the same count, then what is the first class value selected from the dataset used for?

•   Then choose the first class value observed in the dataset

18. Fill-in-the-blank: The ________  ________ require the prediction of a real number.

•   Regression problems

19. When using the zero rule algorithm, what is a good default prediction for real numbers?

•   Central tendency values such as the mean

20. Complete - the - sentence: A good default is to  _______________

•   Use the mean

21. What does the function, zero_rule_algorithm_regression( ), do?

•   It calculates the mean value for the observed output values in the training dataset  

22. Fill-in-the-blank: Once calculated, the ________ is then predicted for each row in the __________ .

•   the mean, test data

23. Go to Listing 5.5 in your text. In Listing 5.5, explain each line from “define zero_rule_algorithm_classification(train, test):” to “return predicted.”

   Def zero_rule-algorithm_classification(train,         test);

    •   The function takes two arguments, train and         test, which are the training and test               datasets

   Output_values = row[-1] for row in train]

   •    This line extracts the class labels of all          instances in the train dataset and stores them       in the classes list. It uses a list                 comprehension to iterate over each row in the       train dataset (for row in train) and extract        the last element of the row (row[-1]), which        is assumed to be the class label.
   
   Prediction = max(set(output_values),                   key=output_values.count)
   
      • The code uses the max() function to find the         most common class label in the output_values         list. The set() function is used to convert         the list to a set, which removes duplicates,         and the key argument of the max() function          specifies that the maximum element should be         the one with the highest count. Next, the           predicted class label is returned as the            output of the function.

   Predicted =[prediction for I in range(len(test))]
   
    •   The code creates a list of predicted class          labels for the test dataset. It assigns the         predicted class label to each element in the        list.

   Return predicted
    •   the list of predicted class labels is returned       as the output of the function

24. Give a brief summary of why baseline algorithms are used.

•   They provide the required point of comparison when evaluating all other machine learning algorithms on your problem. Once established, you can comment on how much better a given algorithm is as compared to the naïve baseline algorithms, providing context on just how good a given method is.