LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Designing Machine Learning Workflows in Python

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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.____(____(____)))
Code bearbeiten und ausführen