Docsity

Appunti di Machine Learning: Lesson 4 - Classification e Decision Trees, Dispense di Matlab

Anteprima parziale del testo

Scarica Appunti di Machine Learning: Lesson 4 - Classification e Decision Trees e più Dispense in PDF di Matlab solo su Docsity!

BIG DATA

From Linear regression models to Deep Learning

Lecturer: Lucrezia Noli

Lesson 4

Classification

2 questions:

  • An object is A or B  binary classification
    • 1 output variable that can take on two values
  • An object is A, B, C, …, N  multi-class classification
    • N output variables, each representing a class

Logistic Regression

𝑥𝑥 2

𝑥𝑥 1

𝑥𝑥 3

𝑥𝑥 4

𝑦𝑦 1

BIAS

1 binary output

It’s output y1 or not?

Logistic Regression with

SoftMax

𝑥𝑥 1

𝑥𝑥 2

𝑥𝑥 3

𝑥𝑥 4

𝑤𝑤 1 , 2

𝑤𝑤 1 , 1

𝑤𝑤 1 , 3

𝑦𝑦 2

𝑦𝑦 1

𝑦𝑦 3

3 class output

Is class y1?

Is class y2?

Is class y3?

Test Set e Training Set

TRAINING SET TEST SET

Algorithm

Confusion Matrix

True label

Valuation indices

  • From the numbers calculated before, we obtain: - Accuracy =(TP + TN) / (P + N) - Be careful: its a very general metrics, which doesn’t make any difference between TP and TN - This is a problem if you are more interested in one of the two classes (as is often the case) - Precision (Positive predictive value) = TP/(TP+FP) - Sensitivity (o Recall o True positive rate) = TP/(TP+FN) =TP/P - Specificity (o True Negative Rate) = TN/(TN+FP) = TN/N - F1 = 2* Precision*recall/(precision +recall)

True label

Metrics other than accuracy

  • Why have I said many times around that «accuracy» is a «too general» of a

metrics, and we should base our model evaluation on other metrics too?

  • Think about this case:
    • I’m trying to predict fraud. In my dataset, I have 99 cases of normal

transactions, and 1 case of fraud.

  • I run my model, where fraud is the target variable
  • The model accuracy is 99%
  • Is this a good model?

exercise

Decision Trees

  • Algorithms :
    • ID3 (Iterative Dichotomiser 3)
    • C4.5 (successor of ID3)
    • C5.0 (successor of C4.5)
    • CART (Classification And Regression Tree)
    • CHAID (CHi-squared Automatic Interaction Detector).
    • MARS: facilitates use of numerical variables
    • Conditional Inference Trees. Based on statistical methods, uses non- parametric tests to make splits. Very efficient in minimizing overfitting when tested several times, which means they’re generally unbiased and don’t require pruning.

ID3 and CART both invented independently between 1970 and 1980) ,^ but

work in similar ways

Decision Trees

Will John play tennis?

John giocherà a tennis?

Will John play tennis?