CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Designing Machine Learning Workflows in Python

Afficher le cours

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.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de 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.____(____(____)))
Modifier et exécuter le code