Notebook 7 COPY Flashcards

(76 cards)

1
Q

What are the two main pandas data structures?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

import statement for pandas?

A

import pandas as pd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to read a csv in pandas?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do we look at the first 10 and last 10 entries in a dataframe?

What is an issue that arises here?

A

Cant view both at the same time use the name of the dataframe e.g. just “iris” to display both the first and last 5 entries in a data frame

doing this also displays the number of rows and columns in the dataframe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you “print” both the head and tail of a table in the same comand line

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does df.info report?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does df.describe() report?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How would we pull the column “sepal_length” from the iris dataframe?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the three ways of indexing and selecting data in a dataframe?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

for the iris dataframe, display two new data frames where df1 contains the columns “sepal_length” and “sepal_width” using column name indexing and the second contains displays the same using slicing?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do we print the shape of dataframe?

A

df.shape

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the two ways to extract the design matrix X and vector of targets y from the iris Dataframe?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can we find the mean of a df using np?

A

np.mean(df)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can we sort a dataframe based off as specific column in ascending order?

A

in desending order can set ascending = False or drop it from the code all together

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What do we need to check if our csv isnt not in columns?

A

Need to check how it is separated in this case it was separated by a semi-colon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the import statement for seaborn?

A

import seaborn as sns

as the guys name was Samuel Norman Seaborn

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the following code display?

sns.pairplot(iris, hue=’species’)
plt.show()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How do I adjust this function to only display the lower corner (as it is a mirror of the upper corner) and adjust the markets of the graphs)?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How do you use seaborn to plot this following graph for the iris dataset?

What does it show?

A

removing the inner quartile replaces it with a boxplot

Also as seaborn likes the graphs to be based on categorical data if you swap the x and y axis the graph will be orientated horizontally.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do I create a heatmap for the data set “flights” with seaborn?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What do we use scikit-learn for?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are the import states for some of the main ML algos we will use?

A

from sklearn import linear_model,tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Given our design matrix X and label vector y how can I use SVM to train and make a prediction on the sollowing unseen array?

X_unseen = np.array([[6.7, 2.8, 5.2, 2.1]])

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How do I adjust this code to use the decision tree classifier?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the advantages of the decision tree classifier?
26
What are the disadvantages of the decision tree classifier?
27
What is the code for loading and printing a confusion matrix? What does the matrix show?
ADD TO THIS
28
How does a decision tree classifier work?
ADD TO THIS from user guide
29
What is the import code for train_test_split?
30
Why dont we test on the same parameters that our model learns from?
31
How do we create test and training data code for the iris data set using the train_test_split fucntion?
32
When testing for different hyperparameters why is their still a risk of overfitting?
33
How do we solve this issue?
34
How do we implement the cross-validation procedure here?
35
1) load diabetes data set 2) Split the target training/test data 3) Create the linear regression 4) train the model 5) Make predictions using the testing set 6) plot the target as a funciton of bmi of body mass 7) plot target as function of bp average blood preure 8) plt truth vs prediction
36
What is the least squares solution? What is the big-O of OLS?
37
What is the Ridge regression from OLS?
Has the same time complexity as OLS
38
How do we implement the Ridge model?
39
What is the classifier varient of Ridge on scikit learn?
40
How do we set the regularisation parameter for RidgeCV and RidgeClassifier CV?
41
What is the Lasso model?
42
How do we implement the Lasso model?
43
How do we set the regularisation parameters for Lasso?
44
What else does the estimator LassoLarsIC use to find its optimal alphas?
45
What is the equivalence between the alpha of lasso and the regularisation parameter of SVM?
46
How do I adjust this code for the Ridge regression?
47
How do I adjust this code for the Lasso regression?
48
Why do we use the standardscaler?
49
What does a confusion matrix show?
50
What is the code to use svm to classify some data and then create a confusion matrix?
51
What are the three way to scale the data?
52
What does the StandardScaler?
53
Once we have initialised scaled data, how do we implement it into code using a SVM classifier and print its confusion matrix and score?
Wha
54
What classifier isnt that sensitive to scaling?
55
How to implement the DecisionTreeClassifier model using scaling for the winequality date set? Perform the classification and repeat and display the confusion matrix and clf.score? How does it compare to when you use unscaled data (repeat the task with unscaled data)?
Not that much different
56
What are the two ways to show a confusion matrix based on this unscaled train_test data of the winequality dataset?
57
What are hyperparameters and how do they relate to Cross-validation?
58
What is the simpliest way to use cross-validation?
59
What happens when the cv argument is a integer in cross_val_score?
60
How do the cross_validate and cross_val_score differ?
61
What does cross_val_predict do? When is it appropriate or inappropriate to use?
62
What function do we use to find the names and current values for all parameters for a given estimator?
63
What does a search for a hyperparameters consist of generally?
64
What are the two generic approaches for parameter searches?
65
What is the Exhaustive Grid Search method in SciKit learn?
66
How do we tune the decision threshold of the classifier once he model has been trained?
67
How can we tune the decision theshold through different strategies controlled by the parameter scoring?
68
What do you need to note regarding the internal cross-validation?
W
69
What are all the import statements needed for cross validation?
70
71
Run the svm.SVC classifier on the unscaled data
72
How do we code this?
73
When tuning Hyperparameter seearch with a manual search with a loop what do we do once we have calculated the scores to decide which Hyperparameter is the best?
74
How do we perform a Hyperparameter grid search using GridSearch CV? How do you perform a Hyperparameter grid search over both C and gamma at the same time?
If things have gone well, you should find that with C and gamma set you can now predict approximately 66% of the cases correctly. This is a substantial improvement over the approximately 45% found at the beginning of this notebook before doing any scaling or hyperparameter tuning. Note also that the 66%
75
What do we do once we have the best set of hyperparameters?
76
What is the default number of folds the GridSearchCV() uses
cv = 5