<jupyter_start><jupyter_text>Looking at FiveThirtyEight's data on which US State has the worst drivers. The data set includes summary level information about fatal accidents as well as insurance premiums for each state as of 2010.<jupyter_code>%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

plt.style.use('ggplot')
df = pd.read_csv('https://raw.githubusercontent.com/VictorOmondi1997/visualizing_us_worst_drivers/master/us_worst_drivers.csv')
df.head()<jupyter_output><empty_output><jupyter_text>Regression plot regression plot of premiums vs. insurance_losses<jupyter_code>sns.regplot(data=df, x='insurance_losses', y='premiums')
plt.show()
sns.lmplot(data=df, x='insurance_losses', y='premiums')
plt.show()<jupyter_output><empty_output><jupyter_text>This data set includes geographic information by state and area. It might be interesting to see if there is a difference in relationships based on the `Region` of the country.<jupyter_code>sns.lmplot(data=df, x='insurance_losses', y='premiums', hue='Region')
plt.show()<jupyter_output><empty_output><jupyter_text>The results are bit difficult to read. Maybe using multiple lines is not the best approach. Let's try another one.<jupyter_code>sns.lmplot(data=df, x='insurance_losses', y='premiums', row='Region')
plt.show()<jupyter_output><empty_output><jupyter_text>a scatter plot for fatal_collisions and premiums<jupyter_code>g = sns.PairGrid(df, vars=["fatal_collisions", "premiums"])
g.map_diag(plt.hist)
g.map_offdiag(plt.scatter)
plt.show()
sns.pairplot(df, vars=['fatal_collisions', 'premiums'], kind='scatter', hue='Region', palette='RdBu', diag_kws={'alpha':0.5})
plt.show()
sns.pairplot(df, x_vars=["fatal_collisions_speeding", "fatal_collisions_alc"], y_vars=['premiums', 'insurance_losses'], kind='scatter', hue='Region', palette='husl')
plt.show()<jupyter_output><empty_output><jupyter_text>Relationships between insurance_losses and premiums<jupyter_code>sns.pairplot(df, vars=["insurance_losses", "premiums"], kind='reg', diag_kind='kde', hue='Region', palette='BrBG', height=10)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13361462728551335, 'fraction_numerical': 0.005625879043600563, 'mean_word_length': 9.309178743961352, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '587754', 'license': 'MIT', 'n_tokens_mistral': 792, 'n_tokens_neox': 736, 'n_words': 161, 'path': 'visualizing_us_worst_drivers.ipynb', 'repo_name': 'VictorOmondi1997/visualizing_us_worst_drivers', 'size': '2133'}