의사 결정 경계와 마진 시각화
이전 연습 문제에서는 선형적으로 분리 가능한 데이터셋에 대해 두 개의 선형 분류기를 만들었는데, 하나는 cost = 1, 다른 하나는 cost = 100이었죠. 이번 연습 문제에서는 두 분류기의 마진을 하나의 플롯에 시각화해 보겠습니다. 다음 객체들을 사용할 수 있습니다:
- 학습 데이터셋:
trainset. cost = 1과cost = 100분류기: 각각svm_model_1과svm_model_100.cost = 1분류기의 기울기와 절편:slope_1,intercept_1.cost = 100분류기의 기울기와 절편:slope_100,intercept_100.- 두 비용에 대한 가중치 벡터: 각각
w_1,w_100. - 학습 데이터의 기본 산점도:
train_plot.
ggplot2 라이브러리는 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
R에서의 Support Vector Machine
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
#add decision boundary and margins for cost = 1 to training data scatter plot
train_plot_with_margins <- train_plot +
geom_abline(slope = ___, intercept = ___) +
geom_abline(slope = ___, intercept = ___-1/w_1[2], linetype = "dashed")+
geom_abline(slope = ___, intercept = ___+1/w_1[2], linetype = "dashed")
#display plot
train_plot_with_margins