Spaces:
Running
Running
File size: 2,910 Bytes
5657e82 c104620 5657e82 5d57412 5657e82 cd0fc76 5657e82 cd0fc76 5657e82 cd0fc76 5657e82 5d57412 5657e82 5d57412 3f8a515 5d57412 538a197 3f8a515 5d57412 3f8a515 5d57412 8e2d7d0 1955778 |
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 |
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='Privilege',
text=df['Role'], hoverinfo='text+y'
))
fig.add_trace(go.Scatter(
x=df.index, y=df['Protect_Rank'],
mode='lines+markers', name='Protection',
text=df['Role'], hoverinfo='text+y'
))
fig.add_trace(go.Scatter(
x=df.index, y=df['Neutral_Rank'],
mode='lines+markers', name='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 separately
heatmaps = {
'Scores Pearson Correlation': scores_corr_pearson,
'Ranks Pearson Correlation': ranks_corr_pearson,
'Scores Spearman Correlation': scores_corr_spearman,
'Ranks Spearman Correlation': ranks_corr_spearman,
'Scores Kendall Correlation': scores_corr_kendall,
'Ranks Kendall Correlation': ranks_corr_kendall
}
figs = {}
for title, corr_matrix in heatmaps.items():
fig = px.imshow(corr_matrix, text_auto=True, title=title)
figs[title] = fig
return figs
|