I am using the below code to get the bar plot. I want to get the bar plot with error bars displayed.
import seaborn as sns
def plot_coefficients(target, coeffs_df, n=10):
if coeffs_df.shape[0]==0:
return None # nothing to plot here!
data = coeffs_df.copy()
data = data.sort_values(('Coefficient','mean'), ascending=False).head(n)
g = sns.barplot(
data=data,
y='Gene',
x=('Coefficient','mean'),
hue='Feature Type',
hue_order=[
h for h in [
'Genomic Variant',
'Gene Expression',
'Proteomics',
'Methylation',
]
],
dodge=False
)
g.set(
xlim=(0,1),
xlabel='Importance [0,1]',
ylabel='',
title=f"Top {target} predictor features"
)
return g
Coefficient here is a score generated from predictive modelling that ranges from 0 to 1. 2. data here is entire data and I created a mean column. Ideally I wanted to calculate it in seaborn plot rather than creating a mean column separately before.
seaborn
assns
, right? $\endgroup$