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