Task 2: Logistic Regression Classifier

In essence, linear regression and logistic regression are quite similar, so their model setups are very much alike. In this task, please modify the four steps from Task 1 based on what we have learned to train a logistic regression classifier using Keras. I have prepared the first step for you and written it in the code below.

dat = iris
dat = dat[which(dat$Species != "setosa"), ]
dat$Species = as.numeric(dat$Species)
pairs(dat[,-5], col = dat$Species)
x = as.matrix(dat[,-c(1,2,5)])
y = dat[,5]-2

Please use this data to train a logistic regression classifier to distinguish between Versicolor and Virginica.

Tips: When you modify the model, you should pay attention to the following key points. First, do the outputs of a regression model and a logistic model look the same? Second, do classification problems and regression problems have the same loss function?

Previous page | Lecture 3 Homepage | Next page

© 2024 Xijia Liu. All rights reserved. Contact: xijia.liu AT umu.se
Logo