ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Designing Machine Learning Workflows in Python

Ver curso

Instrucciones del ejercicio

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

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# 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 y ejecutar código