Linear Regressions
It’s Classified!
¯\_(ツ)_/¯
KNN
Programming
100

Provide a question one could answer using a linear regression model.

Examples:

  • How long will it take this person to repay the loan I just gave them?


  • How badly will the Phillies lose again tonight?

100

Provide a question one could answer using a classification model.

Examples:

  • Will this person repay the loan I just gave them?

  • Will the Phillies lose again tonight? (Yes. Yes they will.)

100

I have a Pandas DataFrame named users. One of the Series is named age. I run this code: users[users.age > 25]. What does this code return, and how does it "work"?

Assuming that the age column is a has a numeric dtype this code will look at the age column of users and return all observations in the users dataframe who have a value in the 'age' column that is greater than 25

100

 In the image below, which would be the best value for k assuming that the algorithm you are using is k-Nearest Neighbor.

~10

100

When is the __init__ method called for a python class?

When the class is instantiated

200

In what situation would I want to evaluate my model with mean squared error instead of mean absolute error?

MSE penalizes outliers more than MAE. MAE assigns equal weight to the data whereas MSE emphasizes the extremes - the square of a very small number (smaller than 1) is even smaller, and the square of a big number is even bigger

200

What does K represent in k-nearest neighbor classifier?

The number of closest neighbors used to apply either an average (or other defined voting mechanism) for your target prediction from those neighbors

200

Which is the optimal model?

Top Left: low bias and low variance


200

 Which of the following option is true about k-NN algorithm?

A) It can be used for classification
B) It can be used for regression
C) It can be used in both classification and regression 

C

200

What are any methods on a class with double underscores around the name called?

hidden methods

300

When plotting residuals, what pattern do we want to see?

Randomness

300

What is another term for the True Positive Rate and True Negative Rate?

Sensitivity and Specificity

300

What is model regularization?

Introduce error function, punishes model complexity to avoid overfitting

300

Which of the following machine learning algorithm can be used for imputing missing values of both categorical and continuous variables?

A) K-NN
B) Linear Regression
C) Logistic Regression

A

300

What is the first argument any method in a class should take?

self

400

In what case would I want to use a Lasso Regression over a Ridge Regression?

I believe that few features will be important.

400

What is the difference between precision and recall?

recall = TP / (TP + FN)

precision = TP / (TP + FP)

400

What is the difference between a parametric and non-parametric model?



400

What happens to the Bias as you increase the number of  k in k-NN?

bias will be increase

400

What does the __str__ method do on a class?


Printable string representation. Sample call: str(obj).

It denotes what to print when str(obj) is called

500

What is the regularized regression method that linearly combines the L1 and L2 penalties of the lasso and ridge methods?

Elastic Net Regularization

500

What is the role of the sigmoid function in a classification model?

The sigmoid function ensures that all output values will fall between 0 and 1, for any value of x. Further, this function outputs the probability that y = 1.

500

Answer the following:

What is leakage?

Why is it a problem?

Give an example of leakage.

Creation of unexpected additional information in the training data, allowing a model or machine learning algorithm to make unrealistically good predictions.

Causes models to over-represent their generalization error and often renders them useless in the real world.

Examples:

  • Leaking test data into the training data. Leaking the correct prediction or ground truth into the test data. 

  • Leaking of information from the future into the past. 

  • Retaining proxies for removed variables a model is restricted from knowing. 

  • Etc.

500

What is the difference between Manhattan and Euclidean distance measures?

In 2d the Euclidean distance measures the shortest distance in the plane, the Manhattan metric the shortest path if you are only allowed to move horizontally or vertically. For example if a = (0,0) b = (3,4) then
dist_euclid (a,b) = sqrt(3^2+4^2) = 5
dist_manhattan(a,b) = 3+4 = 7

500

What is the output of print(obj1.two(),obj2.two()) given the below code?

obj1=A()
obj2=B()

class A:
    def one(self):
        return self.two()
 
    def two(self):
        return 'A'
 
class B(A):
    def two(self):
        return 'B'

A B

M
e
n
u