Get startedGet started for free

A simple novelty

You find novelty detection more useful than outlier detection, but want to make sure it works on the simple example you came up with before. This time you will use a sequence of thirty examples all with value 1.0 as a training set, and try to see if the example 10.0 is labeled as a novelty. You have access to pandas as pd, and the LocalOutlierFactor module as lof.

This exercise is part of the course

Designing Machine Learning Workflows in Python

View Course

Exercise instructions

  • Create a pandas DataFrame containing thirty examples all equal to 1.0.
  • Initialize a local outlier factor novelty detector.
  • Fit the detector to the training data.
  • Output the novelty label of the datapoint 10.0, casted to a DataFrame.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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.____(____(____)))
Edit and Run Code