Calmcode - human learn: outliers

Outliers

1 2 3 4 5 6 7 8

The machine learning drawing feature in human-learn can also be used as an outlier detection model. To demonstrate this, let's make some more drawings just like before.

from hulearn.experimental.interactive import InteractiveCharts

charts = InteractiveCharts(df, labels="species")
charts.add_chart(x="bill_length_mm", y="bill_depth_mm")

Instead of turning this into a classifier we can also turn it into a model that detects outliers instead.

from hulearn.outlier import InteractiveOutlierDetector

# Load the model using drawn-data.
model = InteractiveOutlierDetector(json_desc=charts.data())

X, y = df.drop(columns=['species']), df['species']
preds = model.fit(X, y).predict(X)

You can see the drawn shapes reflected in this models output.

plt.scatter(X['bill_length_mm'], X['bill_depth_mm'], c=preds)
plt.xlabel('bill_length_mm')
plt.ylabel('bill_depth_mm')