티스토리 뷰
Categorical Plot Types¶
In [1]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
stripplot() and swarmplot()¶
In [2]:
df = pd.read_csv('./dataset/schoolimprovement2010grants.csv')
In [3]:
sns.stripplot(data=df,
x='Award_Amount',
y='Model Selected',
jitter=True)
Out[3]:
In [4]:
# Create and display a swarmplot with hue set to the Region
sns.swarmplot(data=df,
x='Award_Amount',
y='Model Selected',
hue='Region')
Out[4]:
boxplots, violinplots and lvplots¶
In [5]:
# Create a boxplot
sns.boxplot(data=df,
x='Award_Amount',
y='Model Selected',)
Out[5]:
In [7]:
# Create a violinplot with the husl palette
sns.violinplot(data=df,
x='Award_Amount',
y='Model Selected',
palette='husl')
Out[7]:
In [9]:
# Create a lvplot(boxenplot) with the Paired palette and the Region column as the hue
sns.boxenplot(data=df,
x='Award_Amount',
y='Model Selected',
palette='Paired',
hue='Region')
Out[9]:
barplots, pointplots and countplots¶
In [10]:
# Show a countplot with the number of models used with each region a different color
sns.countplot(data=df,
y='Model Selected',
hue='Region')
Out[10]:
In [12]:
# Create a pointplot and include the capsize in order to show bars on the confidence interval
sns.pointplot(data=df,
y='Award_Amount',
x='Model Selected',
capsize=.1)
Out[12]:
In [13]:
# Create a barplot with each Region shown as a different color
sns.barplot(data=df,
y='Award_Amount',
x='Model Selected',
hue='Region')
Out[13]:
Regression Plots¶
Regression and residual plots¶
In [15]:
df = pd.read_csv('./dataset/college_datav3.csv')
In [16]:
# Display a regression plot for Tuition
sns.regplot(data=df,
y='Tuition',
x='SAT_AVG_ALL',
marker='^',
color='g')
Out[16]:
In [17]:
# Display the residual plot
sns.residplot(data=df,
x='Tuition',
y='SAT_AVG_ALL',
color='g')
Out[17]:
Regression plot parameters¶
In [18]:
# Plot a regression plot of Tuition and the Percentage of Pell Grants
sns.regplot(data=df,
y='Tuition',
x='PCTPELL')
Out[18]:
In [19]:
# Create another plot that estimates the tuition by PCTPELL
sns.regplot(data=df,
y='Tuition',
x='PCTPELL',
x_bins=5)
Out[19]:
In [20]:
# The final plot should include a line using a 2nd order polynomial
sns.regplot(data=df,
y='Tuition',
x='PCTPELL',
x_bins=5,
order=2)
Out[20]:
Binning data¶
In [21]:
# Create a scatter plot by disabling the regression line
sns.regplot(data=df,
y='Tuition',
x='UG',
fit_reg=False)
Out[21]:
In [22]:
# Create a scatter plot and bin the data into 5 bins
sns.regplot(data=df,
y='Tuition',
x='UG',
x_bins=5)
Out[22]:
In [23]:
# Create a regplot and bin the data into 8 bins
sns.regplot(data=df,
y='Tuition',
x='UG',
x_bins=8)
Out[23]:
Matrix plots¶
Creating heatmaps¶
In [24]:
df = pd.read_csv('./dataset/daily_show_guests_cleaned.csv')
# Create a crosstab table of the data
pd_crosstab = pd.crosstab(df['Group'], df['YEAR'])
print(pd_crosstab)
# Plot a heatmap of the table
sns.heatmap(pd_crosstab)
# Rotate tick marks for visibility
plt.yticks(rotation=0)
plt.xticks(rotation=90)
Out[24]:
Customizing heatmaps¶
In [25]:
# Create the crosstab DataFrame
pd_crosstab = pd.crosstab(df['Group'], df['YEAR'])
# Plot a heatmap of the table with no color bar and using the BuGn palette
sns.heatmap(pd_crosstab, cbar=False, cmap='BuGn', linewidths=0.3)
# Rotate tick marks for visibility
plt.yticks(rotation=0)
plt.xticks(rotation=90)
Out[25]:
'Study > AI' 카테고리의 다른 글
[RL] Windows 10에서 mujoco_py 구동 (12) | 2021.01.26 |
---|---|
[RL] Feature Construction for Linear Methods (0) | 2021.01.22 |
[DS] Distributions (0) | 2020.06.02 |
[DS][Visualization] A Visual History of Nobel Prize Winners (0) | 2020.05.12 |
[DL] Optimization Techniques (0) | 2020.01.28 |
[TIP] Jupyter에서 서버상의 데이터를 읽어오기 (0) | 2020.01.15 |
[DL] Types of Computer Vision Models (0) | 2020.01.08 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Off-policy
- Windows Phone 7
- bias
- processing
- Offline RL
- Distribution
- windows 8
- 한빛미디어
- RL
- 딥러닝
- 강화학습
- Pipeline
- Kinect
- 파이썬
- ColorStream
- ai
- Variance
- dynamic programming
- TensorFlow Lite
- Expression Blend 4
- reward
- DepthStream
- PowerPoint
- Kinect for windows
- arduino
- Policy Gradient
- End-To-End
- Gan
- Kinect SDK
- SketchFlow
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함