Created
January 12, 2020 11:19
-
-
Save jamescalam/0be21e913435bf29354404e3e85f8ca1 to your computer and use it in GitHub Desktop.
Example code snippet for Naive Bayes fundamentals article, part [1]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import matplotlib.pyplot as plt | |
# [1] import and visualise our data | |
dataset = pd.read_csv('adult.csv') # import data | |
# from Kaggle's 'Adult Census Income' dataset | |
# lets visualise the data, we classify by income (>$50k or not) | |
# based on number of years in education and hours worked per week | |
plt.figure(figsize=(12, 8)) | |
sns.scatterplot(data=dataset, x='education.num', y='hours.per.week', | |
hue='income', s=250, alpha=0.025, palette={ | |
'<=50K': '#02AD6D', | |
'>50K': '#FF00FF'}) | |
plt.show() # visualise the data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment