เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Novelty Detection เบื้องต้น

คุณพบว่า novelty detection มีประโยชน์มากกว่า outlier detection และต้องการทดสอบว่าใช้งานได้จริงกับตัวอย่างง่าย ๆ ที่เคยลองมาก่อน คราวนี้จะใช้ลำดับตัวอย่าง 30 รายการที่มีค่าเท่ากับ 1.0 ทั้งหมดเป็นชุดข้อมูล training และดูว่าตัวอย่าง 10.0 จะถูกระบุว่าเป็น novelty หรือไม่ โดยมี pandas ในชื่อ pd และโมดูล LocalOutlierFactor ในชื่อ lof พร้อมใช้งานแล้ว

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การออกแบบ Machine Learning Workflows ด้วย Python

ดูคอร์ส

คำแนะนำการฝึกหัด

  • สร้าง DataFrame ของ pandas ที่ประกอบด้วยตัวอย่าง 30 รายการซึ่งมีค่าเท่ากับ 1.0 ทั้งหมด
  • สร้าง local outlier factor novelty detector
  • Fit detector กับข้อมูล training
  • แสดงผล novelty label ของ datapoint 10.0 ที่แปลงเป็น DataFrame แล้ว

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# 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.____(____(____)))
แก้ไขและรันโค้ด