간단한 Novelty
여러분은 이상치 탐지보다 novelty detection이 더 유용하다고 생각하지만, 이전에 만들었던 간단한 예시에서도 잘 작동하는지 확인하고 싶어요. 이번에는 값이 모두 1.0인 30개의 예시를 학습 세트로 사용하고, 예시 10.0이 새로움(novelty)으로 라벨링되는지 확인해 볼 거예요. pandas는 pd로, LocalOutlierFactor 모듈은 lof로 사용할 수 있어요.
이 연습은 강의의 일부입니다
Python으로 설계하는 Machine Learning 워크플로
연습 안내
- 값이 모두
1.0인 예시 30개를 담은 pandas DataFrame을 생성하세요. - Local Outlier Factor 기반 novelty 탐지기를 초기화하세요.
- 탐지기를 학습 데이터에 맞춰 학습(fit)하세요.
- 데이터 포인트
10.0을 DataFrame으로 변환해 입력하고, 해당 포인트의 novelty 라벨을 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create a list of thirty 1s and cast to a dataframe
X = ____([1.0]*30)
# Create an instance of a lof novelty detector
detector = lof(____)
# Fit the detector to the data
detector.____(____)
# Use it to predict the label of an example with value 10.0
print(detector.____(____(____)))