Spaces:
Sleeping
Sleeping
File size: 4,002 Bytes
5657e82 c104620 5657e82 5d57412 5657e82 cd0fc76 5657e82 cd0fc76 5657e82 cd0fc76 5657e82 5d57412 5657e82 5d57412 538a197 5d57412 8e2d7d0 |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
import pandas as pd
import plotly.graph_objs as go
import plotly.express as px
def create_score_plot(df):
fig = go.Figure()
fig.add_trace(go.Scatter(
x=df.index, y=df['Privilege_Avg_Score'],
mode='lines+markers', name='Privilege',
text=df['Role'], hoverinfo='text+y'
))
fig.add_trace(go.Scatter(
x=df.index, y=df['Protect_Avg_Score'],
mode='lines+markers', name='Protection',
text=df['Role'], hoverinfo='text+y'
))
fig.add_trace(go.Scatter(
x=df.index, y=df['Neutral_Avg_Score'],
mode='lines+markers', name='Neutral',
text=df['Role'], hoverinfo='text+y'
))
fig.update_layout(
title=f'Scores of Resumes',
xaxis_title='Resume Index',
yaxis_title='Score',
legend_title='Score Type',
hovermode='closest'
)
return fig
def create_rank_plots(df):
fig = go.Figure()
# Add traces for ranks
fig.add_trace(go.Scatter(
x=df.index, y=df['Privilege_Rank'],
mode='lines+markers', name='Rank Privilege',
text=df['Role'], hoverinfo='text+y'
))
fig.add_trace(go.Scatter(
x=df.index, y=df['Protect_Rank'],
mode='lines+markers', name='Rank Protection',
text=df['Role'], hoverinfo='text+y'
))
fig.add_trace(go.Scatter(
x=df.index, y=df['Neutral_Rank'],
mode='lines+markers', name='Rank Neutral',
text=df['Role'], hoverinfo='text+y'
))
# Update layout
fig.update_layout(
title='Ranks of Scores',
xaxis_title='Resume Index',
yaxis_title='Rank',
legend_title='Rank Type',
hovermode='closest'
)
return fig
def create_correlation_heatmaps(df):
scores_df = df[['Privilege_Avg_Score', 'Protect_Avg_Score', 'Neutral_Avg_Score']]
ranks_df = df[['Privilege_Rank', 'Protect_Rank', 'Neutral_Rank']]
# Pearson correlation
scores_corr_pearson = scores_df.corr(method='pearson')
ranks_corr_pearson = ranks_df.corr(method='pearson')
# Spearman correlation
scores_corr_spearman = scores_df.corr(method='spearman')
ranks_corr_spearman = ranks_df.corr(method='spearman')
# Kendall Tau correlation
scores_corr_kendall = scores_df.corr(method='kendall')
ranks_corr_kendall = ranks_df.corr(method='kendall')
# Plotting the heatmaps
fig = go.Figure()
fig.add_trace(go.Heatmap(
z=scores_corr_pearson.values,
x=scores_corr_pearson.columns,
y=scores_corr_pearson.index,
colorscale='Viridis',
showscale=True,
name='Scores Pearson Correlation'
))
fig.add_trace(go.Heatmap(
z=ranks_corr_pearson.values,
x=ranks_corr_pearson.columns,
y=ranks_corr_pearson.index,
colorscale='Viridis',
showscale=True,
name='Ranks Pearson Correlation'
))
fig.add_trace(go.Heatmap(
z=scores_corr_spearman.values,
x=scores_corr_spearman.columns,
y=scores_corr_spearman.index,
colorscale='Cividis',
showscale=True,
name='Scores Spearman Correlation'
))
fig.add_trace(go.Heatmap(
z=ranks_corr_spearman.values,
x=ranks_corr_spearman.columns,
y=ranks_corr_spearman.index,
colorscale='Cividis',
showscale=True,
name='Ranks Spearman Correlation'
))
fig.add_trace(go.Heatmap(
z=scores_corr_kendall.values,
x=scores_corr_kendall.columns,
y=scores_corr_kendall.index,
colorscale='Inferno',
showscale=True,
name='Scores Kendall Correlation'
))
fig.add_trace(go.Heatmap(
z=ranks_corr_kendall.values,
x=ranks_corr_kendall.columns,
y=ranks_corr_kendall.index,
colorscale='Inferno',
showscale=True,
name='Ranks Kendall Correlation'
))
# Update layout
fig.update_layout(
title='Correlation Heatmaps',
xaxis_nticks=36
)
return fig
|