Or, which of these doggos is most similar to a sausage?
Sausage dogs are among the cutest creatures in existence, no doubt. Just look at this majestic unit:
Credit: Igor Bredikhin via Wikipedia
Corgis and Basset Hounds are two other sausage dogs in contention for ultimate sausage-ness, but which of these sausage dogs are objectively closer to the sausage ideal? Where do other dog breeds fall on the sausage-ness spectrum? These are important questions that need answering.
The most important metric to consider when measuring sausage-ness is, of course, the side profile of the dog: is it longer than it is tall? We can use the ratio of (back) length to height to compare dogs on this metric. I'm going to call this ratio the
S-index in my code, but you can call it sausage-ness if you like.
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
It's surprisingly difficult to find morphometric data for dog breeds. The American Kennel Club provides height and weight information but not back length, which is crucial in determining S-index. The authors of this paper collected a large variety of measurements, including back length, but they haven't supplied any raw data. If this were a proper scientific study, I'd have to contact the authors with a request for data, but I've already invested more time than I should in this study of sausage dogs, so here we go.
The design-focused website dimensions.com does provide back lengths. Instead of the withers height which is used by the American Kennel Club, height in the rest of this notebook refers to standing height. This is simply because I don't currently have the time to collect the withers height. Using withers height would probably give us a better indicator of sausage-ness.
Note that this website doesn't cite the source of their data, so take this otherwise scientifically rigorous study of sausage dogs with a large heap of salt. Only 51 dog breeds are available here, which is an okay but rather modest sample size. Furthermore, only minimum and maximum values are provided, so I had to settle with using mid-range as a measure of central tendency.
I collected the necessary data from dimensions.com and stored them in a csv file. All measurements are in metric units. No cleaning necessary, which is always nice!
df = pd.read_csv('data.csv')
|6||Cavalier King Charles Spaniel||48||51||38||42||5.9||8.2|
|8||Jack Russell Terrier||46||55||36||43||4.1||6.8|
|15||Pembroke Welsh Corgi||56||66||36||43||10.0||14.0|
|22||English Springer Spaniel||69||84||65||79||18.0||25.0|
|23||Australian Cattle Dog||71||84||53||64||14.0||16.0|
|36||Bernese Mountain Dog||89||105||76||91||32.0||52.0|
def calc_mid(a, b):
Get mid-range from min and max.
return (a+b) / 2
df['length_mid'] = df.apply(lambda x: calc_mid(x['length_min'], x['length_max']), axis=1)
df['height_mid'] = df.apply(lambda x: calc_mid(x['height_min'], x['height_max']), axis=1)
df['s_index'] = df['length_mid'] / df['height_mid']
I initially planned to display the data in a scatter plot, but labelling each point would create too much visual clutter. Nonetheless, it shows that most dog breeds in our sample are longer than they are tall.
g = sns.lmplot(data=df, x='height_mid', y='length_mid')
We lose information about absolute height and length by using the
S-index ratio, but it makes it easier to compare sausage-ness directly.
fig, ax = plt.subplots(figsize=(20, 18))
sns.barplot(ax=ax, data=df.sort_values('s_index', ascending=False), x='s_index', y='breed', color='#42b7bd')
# Vertical line at x=1
ax.set_title('Sausage-ness of dog breeds', fontsize=24, pad=30)
ax.set_ylabel('Breed', labelpad=20, fontsize=18)
ax.set_xlabel('Length / Height', labelpad=20, fontsize=18)
# Annotation with box
bbox_props = dict(boxstyle="rarrow,pad=0.6", fc="cyan", ec="#42b7bd", lw=2)
t = ax.text(1.35, 49, 'Approaching theoretical sausage ideal', bbox=bbox_props)
# Annotation with arrows
ax.annotate('Tall bois', xy=(0.993056, 49), xycoords='data', xytext=(1.1, 49), textcoords='data',
ax.annotate('', xy=(0.850427, 50), xycoords='data', xytext=(1.15, 49), textcoords='data',
arrowprops=dict(arrowstyle='->', color='red', connectionstyle='angle'))
Perhaps unsurprisingly, the Dachshund is the most sausage-y of sausage dogs, followed closely by the Basset Hound. I'd expected the Corgi to have a higher
S-index than it does here. The Havanese isn't a breed I would normally classify as a sausage dog at first glance, but it goes to show how deceiving all that fur can be.
It's also interesting to note that we have two tall bois in our sample. The Great Dane and the Standard Poodle are both taller than they are long.
Credit: Lilly M via Wikipedia
Credit: Tim Wilson via Wikipedia
Now you know which sausage dogs are more sausage-y, where other dogs lie on the sausage-ness (cough
S-index) spectrum, and which dogs are tall bois. You're welcome.
Things I Learned
This project is more than a little tongue-in-cheek, but I managed to get a surprising amount out of it.
My first instinct was to use mean or median height and length as a measure of central tendency, but I stopped short as sooon as I realised that I only had access to the minimum and maximum values. I Googled around and found this thread about the mid-range as an estimator of the mean. It's a pretty dismal statistic, but you work with what you have.
I haven't used Matplotlib and Seaborn in a while. Though I love Seaborn for abstracting away a lot of finicky styling decisions, I now realise I need to go through the Seaborn docs properly to understand how it interfaces with Matplotlib. Specifically, I should read up on figure-level and axes level Seaborn functions (in this notebook, the scatter plot and bar plot are figure-level and axes-level functions respectively).
Day 30 of #100DaysToOffload