Update page 'Solutions to the questions concerning R language'

xuanyi.wang
2023-05-22 21:11:01 +02:00
parent bda8e91291
commit f1a2c5e004
@@ -444,4 +444,52 @@ The maximal margin classifier has to be in between observations #2, #3 and #5, #
=>(2,1.5),(4,3.5) =>(2,1.5),(4,3.5)
b=(3.5−1.5)/(4−2)=1 b=(3.5−1.5)/(4−2)=1
a=X2−X1=1.5−2=−0.5 a=X2−X1=1.5−2=−0.5
```
```
plot(x1, x2, col = colors, xlim = c(0, 5), ylim = c(0, 5))
abline(-0.5, 1)
```
**iii.**
```
0.5−X1+X2>0
```
**iv.**
```
plot(x1, x2, col = colors, xlim = c(0, 5), ylim = c(0, 5))
abline(-0.5, 1)
abline(-1, 1, lty = 2)
abline(0, 1, lty = 2)
```
**v.**
```
plot(x1, x2, col = colors, xlim = c(0, 5), ylim = c(0, 5))
abline(-0.5, 1)
arrows(2, 1, 2, 1.5)
arrows(2, 2, 2, 1.5)
arrows(4, 4, 4, 3.5)
arrows(4, 3, 4, 3.5)
```
**vi.**
A slight movement of observation #7 (4,1) blue would not have an effect on the maximal margin hyperplane since its movement would be outside of the margin.
**vii.**
```
plot(x1, x2, col = colors, xlim = c(0, 5), ylim = c(0, 5))
abline(-0.8, 1)
```
```
−0.8−X1+X2>0
```
**viii.**
```
plot(x1, x2, col = colors, xlim = c(0, 5), ylim = c(0, 5))
points(c(4), c(2), col = c("red"))
``` ```