Digestize

In this short post, we look at how to create a pie chart as follows:

Pie chart with percentages and labels

The key code blocks are as follows:

The function to compute the percentages:

def my_autopct(pct):
return ('%.2f' % pct)

The function to assign labels:

def get_new_labels(sizes, labels):
new_labels = [label for size, label in zip(sizes, labels)]
return new_labels

How do you show the labels only for the significant shares (especially if we have many entries in the bar chart)?

--

--

This short post demonstrates how you can add the count values to the top of the bars in a bar chart.

Bar chart annotated with the counts

Here’s the code snippet:

The high-level idea is as follows:

  1. Create the chart and save to ax
  2. Use the following code snippet to annotate with the counts:
for p in ax.patches:
ax.annotate(str(p.get_height()), (p.get_x() * 1.005, p.get_height() * 1.005))

--

--

In novelty detection, you have a dataset that contains only good data and you are trying to check if new observations are similar to the the good data. In other words, our goal is to check if new observations are outliers.

In outlier detection, you dataset may already have outliers and your goal is to identify such outliers.

Both novelty detection and outlier detection are used to detect anomalies.

Outlier detection is an unsupervised anomaly detection algorithm.

Novelty detection is a semi-supervised anomaly detection algorithm.

Outlier detection methods available in scikit-learn (LOF does not have a decision boundary as it does not have a predict method when used as an outlier detection algorithm)

--

--

Digestize

Digestize

#probability #statistics #ML #DL #coding #security #building #digest