lecture 2 model based classification
play

Lecture 2: Model-based classification Felix Held, Mathematical - PowerPoint PPT Presentation

Lecture 2: Model-based classification Felix Held, Mathematical Sciences MSA220/MVE440 Statistical Learning for Big Data 28th March 2019 Reprise: Statistical Learning (I) (|) [] (GLM)) 2. linear


  1. Lecture 2: Model-based classification Felix Held, Mathematical Sciences MSA220/MVE440 Statistical Learning for Big Data 28th March 2019

  2. Reprise: Statistical Learning (I) ๐‘™ ๐”ฝ ๐‘ž(๐‘ง|๐ฒ) [๐‘ง] โ‰ˆ ๐ฒ ๐‘ˆ ๐œธ (GLM)) 2. linear regression (viewpoint: generalized linear models ๐‘ง ๐‘— ๐‘š ๐ฒ ๐‘—๐‘š โˆˆ๐‘‚ ๐‘™ (๐ฒ) โˆ‘ 1/25 Regression 1. k-nearest neighbour regression ๐‘”(๐ฒ) = ๐”ฝ ๐‘ž(๐‘ง|๐ฒ) [๐‘ง] ห† loss โ–ถ Theoretically best regression function for squared error โ–ถ Approximate (1) or make model-assumptions (2) ๐”ฝ ๐‘ž(๐‘ง|๐ฒ) [๐‘ง] โ‰ˆ 1

  3. Reprise: Statistical Learning (II) Classification sensible model assumptions instead? 2. Instead of approximating ๐‘ž(๐‘—|๐ฒ) from data, can we make ๐ฒ ๐‘š โˆˆ๐‘‚ ๐‘™ (๐ฒ) โˆ‘ ๐‘™ 1. k-nearest neighbour classification ๐‘ž(๐‘—|๐ฒ) 1โ‰ค๐‘—โ‰ค๐ฟ ๐‘‘(๐ฒ) = arg max ฬ‚ possible classes 2/25 โ–ถ Theoretically best classification rule for 0-1 loss and ๐ฟ โ–ถ Approximate (1) or make model-assumptions (2) ๐‘ž(๐‘—|๐ฒ) โ‰ˆ 1 1 (๐‘— ๐‘š = ๐‘—)

  4. Amendment: kNN methods There are two choices to make when implementing a kNN method 1. The metric to determine a neighbourhood 2. The number of neighbours, i.e. ๐‘™ The choice of metric changes the underlying local model of the method while ๐‘™ is a tuning parameter. 3/25 โ–ถ e.g. Euclidean/ โ„“ 2 norm, Manhattan/ โ„“ 1 norm, max norm, โ€ฆ

  5. Model-based classification

  6. Classification as regression 0 1 Note that ๐ฒ ๐‘ˆ ๐œธ = otherwise 1 2 1 ๐ฒ ๐‘ˆ ๐œธ โ‰ค 4/25 model approximation for Bayesโ€™ rule as well ๐‘ž(0|๐ฒ) = 1 โˆ’ ๐‘ž(1|๐ฒ) โ‰ˆ 1 โˆ’ ๐ฒ ๐‘ˆ ๐œธ , we indirectly specified a ๐‘ž(1|๐ฒ) = ๐”ฝ ๐‘ž(๐‘—|๐ฒ) [๐‘—] โ‰ˆ ๐ฒ ๐‘ˆ ๐œธ Note that ๐‘— has a discrete distribution. ๐”ฝ ๐‘ž(๐‘—|๐ฒ) [๐‘—] = 0 โ‹… ๐‘ž(0|๐ฒ) + 1 โ‹… ๐‘ž(1|๐ฒ) = ๐‘ž(1|๐ฒ) โ–ถ Consider a two-class problem, with ๐‘— ๐‘š = 0 or ๐‘— ๐‘š = 1 โ–ถ Instead of 0-1 loss, use square error loss, i.e. โ–ถ Linear regression model assumption โ–ถ Since we are approximating ๐‘ž(1|๐ฒ) and ๐‘‘(๐ฒ) = { 2 defines the decision boundary

  7. 0-1 regression The solid black lines show the decision boundary . 5/25 4.5 โ— 1.0 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 4.0 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— Sepal Width โ— โ— โ— 3.5 โ— โ— โ— โ— โ— โ— Coding โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 0.5 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 3.0 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 2.5 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 0.0 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 2.0 โ— 5 6 7 5 6 7 Sepal Length Sepal Length Species setosa versicolor โ— โ—

  8. 0-1 regressions and outliers 6/25 5 โ— โ— Case โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— x 2 โ— โ— No outlier โ— โ— โ— โ— โ— โ— โ— โ— โ— 0 โ— โ— โ— โ— With Outlier โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โˆ’5 โ— โ— 0 5 10 x 1

  9. Dummy encoding for categorical variables In regression, when a predictor ๐‘ฆ is categorical , i.e. takes one Example: ๐‘ฆ = 1 โ†’ ๐‘จ = (1, 0, 0) ๐‘ฆ = 2 โ†’ ๐‘จ = (0, 1, 0) ๐‘ฆ = 3 โ†’ ๐‘จ = (0, 0, 1) Idea Turn a classification problem into a regression problem by as vectors in dummy encoding. 7/25 of ๐ฟ values, it is common to use a dummy encoding . representing the class outcomes ๐‘— ๐‘š in the training data (๐‘— ๐‘š , ๐ฒ ๐‘š )

  10. Multiple classes ๐‘‘(๐‘ฆ) = arg max for ๐‘— โ‰  ๐‘˜ ๐ฒ ๐‘ˆ ๐œธ (๐‘—) 1โ‰ค๐‘—โ‰ค๐ฟ ๐‘ž(๐‘—|๐ฒ) โ‰ˆ arg max 1โ‰ค๐‘—โ‰ค๐ฟ 8/25 ๐‘š ๐‘จ (๐ฟ) โ‹ฎ ๐‘š ๐‘จ (1) blackboard). If there are ๐ฟ classes then โ–ถ This creates a sequence of 0-1 regressions (see โˆถ= 1 (๐‘— ๐‘š = 1) โ†’ ๐‘ž(๐‘จ (1) = 1|๐ฒ) โ‰ˆ ๐ฒ ๐‘ˆ ๐œธ (1) โˆถ= 1 (๐‘— ๐‘š = ๐ฟ) โ†’ ๐‘ž(๐‘จ (๐ฟ) = 1|๐ฒ) โ‰ˆ ๐ฒ ๐‘ˆ ๐œธ (๐ฟ) โ–ถ Note that ๐‘ž(๐‘—|๐ฒ) = ๐‘ž(๐‘จ (๐‘—) = 1|๐ฒ) โ‰ˆ ๐ฒ ๐‘ˆ ๐œธ (๐‘—) โ–ถ Classification rule Decision boundaries are defined by ๐‘‘(๐‘ฆ) = ๐ฒ ๐‘ˆ ๐›พ (๐‘—) = ๐ฒ ๐‘ˆ ๐›พ (๐‘˜)

  11. Multiple 0-1 regressions 9/25 1 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— Coding โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 0 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 1 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— Coding โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 0 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 0 5 10 Predictor Class โ— 1 โ— 2 โ— 3

  12. Problems with 0-1 regression Observations : 1. ๐ฒ ๐‘ˆ ๐œธ is unbounded but models a probability ๐‘ž(๐‘—|๐ฒ) โˆˆ [0, 1] 2. Only values of ๐ฒ ๐‘ˆ ๐œธ around 0.5 (for binary classification) or close to the maximal value (for multiple classes) are really of interest. 3. Sensitive to points far away from the boundary (outliers) (adding polynomial predictors can sometimes help, but this is arbitrary and data dependent) Inspiration from GLM Can we transform ๐ฒ ๐‘ˆ ๐œธ such that the transformed values are in [0, 1] , are similar to the original values when close to 0.5 and insensitive outliers far away from the boundary? 10/25 4. Masking: Classes can get buried among other classes

  13. Logistic function and Normal Distribution CDF Logistic (sigmoid) function โˆš2๐œŒ 1 โˆ’โˆž ๐‘ฆ Standard Normal CDF 1 + exp (๐‘ฆ) exp (๐‘ฆ) ๐œ(๐‘ฆ) = 11/25 1.00 0.75 0.50 y 0.25 0.00 โˆ’4 โˆ’2 0 2 4 x Type Logistic Function Standard Normal CDF ฮฆ(๐‘ฆ) = โˆซ exp (โˆ’๐‘จ 2 2 ) d ๐‘จ

  14. (occurs seldom in practice) Logistic and probit regression more predictors forces the intercept to โˆ’โˆž and the corresponding predictor coefficient to +โˆž . 12/25 โ–ถ We arrive at logistic regression when assuming ๐‘ž(1|๐ฒ) = ๐”ฝ ๐‘ž(๐‘—|๐ฒ) [๐‘—] = ๐œ โˆ’1 (๐ฒ ๐‘ˆ ๐œธ) or probit regression when assuming ๐‘ž(1|๐ฒ) = ๐”ฝ ๐‘ž(๐‘—|๐ฒ) [๐‘—] = ฮฆ โˆ’1 (๐ฒ ๐‘ˆ ๐œธ) โ–ถ Parameters can be estimated by iteratively reweighted least squares (Details in ESL Ch. 4.4.1) โ–ถ A warning: Problematic situation in two-class case โ–ถ Assume two classes can be separated perfectly in one or โ–ถ Logistic regression tries to fit a step-like function, which

  15. Logistic regression and outliers 13/25 5 Case โ— โ— โ— โ— โ— โ— 0โˆ’1: no outlier โ— โ— โ— โ— โ— x 2 โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— 0โˆ’1: with outlier โ— โ— โ— โ— โ— โ— 0 โ— โ— โ— โ— โ— โ— Logistic: with outlier โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โ— โˆ’5 โ— 0 5 10 x 1

  16. Multi-class logistic regression ๐‘˜ (๐ด) = classifier, โ€ฆ multinomial logistic regression, maximum entropy ๐ฟโˆ’1 ๐‘“ ๐ฒ ๐‘ˆ (๐œธ (๐‘š) โˆ’๐œธ (๐ฟ) ) ๐‘ž(๐‘—|๐ฒ) = or ๐ฟ โˆ‘ ๐‘“ ๐ฒ ๐‘ˆ ๐œธ (๐‘—) ๐‘ž(๐‘—|๐ฒ) = ๐‘“ (๐‘จ ๐‘˜ โˆ’๐‘จ ๐ฟ ) ๐ฟโˆ’1 ๐‰ โˆ‘ outcome leads again to a series of regression problems. ๐‰ ๐‘˜ (๐ด) = โ‡” ๐‘“ ๐‘จ ๐‘˜ 14/25 ๐ฟ โ–ถ In case of ๐ฟ > 2 classes, using dummy encoding for the โ–ถ Requirement: Probabilities should be modelled, i.e. in ๐‘ž(๐‘—|๐ฒ) โˆˆ [0, 1] for each class and โˆ‘ ๐‘— ๐‘ž(๐‘—|๐ฒ) = 1 โ–ถ Softmax function: ๐‰ โˆถ โ„ ๐ฟ โ†ฆ [0, 1] ๐ฟ ๐‘š=1 ๐‘“ ๐‘จ ๐‘š 1 + โˆ‘ ๐‘š=1 ๐‘“ (๐‘จ ๐‘š โˆ’๐‘จ ๐ฟ ) โ–ถ Model now: ๐‘š=1 ๐‘“ ๐ฒ ๐‘ˆ ๐œธ (๐‘—) 1 + โˆ‘ ๐‘š=1 ๐‘“ ๐ฒ ๐‘ˆ (๐œธ (๐‘š) โˆ’๐œธ (๐ฟ) ) โ–ถ This method has many names: softmax regression,

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend