ComeçarComece de graça

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.

Este exercício faz parte do curso

Designing Machine Learning Workflows in Python

Ver curso

Instruções do exercício

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

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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.____(____(____)))
Editar e executar o código