Spaces:
Running
Running
Download scripts/validate-artifact-comparison.js from othmanekabal/tdgbench-studio: direct link, hf CLI and curl.
- Browser
- Download file 5.01 kB
-
https://huggingface.co/spaces/othmanekabal/tdgbench-studio/resolve/main/scripts/validate-artifact-comparison.js
- Command line
-
hf download hf://spaces/othmanekabal/tdgbench-studio/scripts/validate-artifact-comparison.js
-
curl -L -o validate-artifact-comparison.js https://huggingface.co/spaces/othmanekabal/tdgbench-studio/resolve/main/scripts/validate-artifact-comparison.js
5.01 kB
| const fs=require('fs'); | |
| const vm=require('vm'); | |
| const context={ | |
| normKey:value=>String(value).trim().toLowerCase().replace(/[^a-z0-9]+/g,'_').replace(/^_|_$/g,''), | |
| esc:value=>String(value).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), | |
| lbMetricIndex:metric=>({accuracy:0,macro_f1:1,recall:2,precision:3})[metric], | |
| lbMetricLabel:index=>['Accuracy','Macro-F1','Recall','Precision'][index] | |
| }; | |
| vm.createContext(context); | |
| ['assets/js/data/catalog.js','assets/js/data/leaderboard-data.js','assets/js/domain/artifact-results.js','assets/js/core/state.js','assets/js/pages/leaderboard-artifacts.js'].forEach(file=>vm.runInContext(fs.readFileSync(file,'utf8'),context)); | |
| if(context.S.lb.artifactModels.has('RGCN'))throw new Error('RGCN ne doit pas être présélectionné sans résultat importé.'); | |
| const imported=context.artifactRowsFromRaw([ | |
| {dataset:'dbpedia',graph:'cg',model:'SAGEConv',partition:'test',metric:'f1_macro',mean:.61,std_split:.02,std_seed:.01,initial_embedding_model:'sentence-transformers/all-MiniLM-L6-v2'}, | |
| {dataset:'dbpedia',graph:'GT2KG_tdg',model:'SAGEConv',partition:'test',metric:'f1_macro',mean:.55,std_split:.03,std_seed:.02,initial_embedding_model:'sentence-transformers/all-MiniLM-L6-v2'} | |
| ],'final_results.json'); | |
| if(imported.length!==2)throw new Error('Les artefacts long format ne sont pas lus.'); | |
| if(imported[0].graph!=='curated'||imported[1].graph!=='tdg')throw new Error('Les alias de graphes DBpedia sont incorrects.'); | |
| context.LB_ARTIFACTS.rows=imported; | |
| context.S.lb.dataset='dbpedia'; | |
| context.S.lb.artifactMetric='macro_f1'; | |
| context.S.lb.artifactEmbedding='sbert'; | |
| context.S.lb.artifactModels=new Set(['SAGEConv','GCN','RGCN','RotatEGCN_attn']); | |
| context.S.lb.artifactGraphs=new Set(['curated','tdg']); | |
| const data=context.artifactChartData(context.S.lb); | |
| if(data.categories.length!==2||data.series.length!==4)throw new Error('La sélection graphes/modèles est incorrecte.'); | |
| const sage=data.series.find(series=>series[0]==='SAGEConv'); | |
| const gcn=data.series.find(series=>series[0]==='GCN'); | |
| if(!sage||!data.value(data.categories[0],sage).imported)throw new Error('GraphSAGE importé est absent.'); | |
| if(!gcn||!data.value(data.categories[0],gcn))throw new Error('Les références intégrées sont absentes.'); | |
| ['grouped','panels','slope'].forEach(view=>{ | |
| context.S.lb.artifactView=view; | |
| const html=context.artifactVisualization(context.S.lb); | |
| if(!html.includes('artifact-chart')||!html.includes('GraphSAGE'))throw new Error('Visualisation '+view+' invalide.'); | |
| }); | |
| const kggen=context.artifactRowsFromRaw([ | |
| {dataset:'biomed',graph:'KGGEN',model:'GCN',partition:'test',metric:'f1_macro',mean:.51,std_split:.02,std_seed:.01,initial_embedding_model:'sentence-transformers/all-MiniLM-L6-v2'}, | |
| {dataset:'biomed',graph:'KGGEN',model:'RGCN',partition:'test',metric:'f1_macro',mean:.58,std_split:.03,std_seed:.02,initial_embedding_model:'sentence-transformers/all-MiniLM-L6-v2'} | |
| ],'final_results.json'); | |
| context.LB_ARTIFACTS.rows=kggen; | |
| context.S.lb.dataset='biomed'; | |
| context.S.lb.artifactKind='graphs'; | |
| context.S.lb.artifactModels=new Set(['GCN','RGCN']); | |
| context.S.lb.artifactGraphs=new Set(['umls','gt2kg','kggen']); | |
| const kggenOptions=context.artifactGraphOptions('biomed'); | |
| if(!kggenOptions.some(graph=>graph[0]==='kggen'&&graph[1]==='KG-GEN'))throw new Error('KGGen officiel est absent des graphes comparables.'); | |
| const kggenData=context.artifactChartData(context.S.lb); | |
| if(kggenData.categories.length!==2||kggenData.series.length!==3)throw new Error('La comparaison UMLS/GT2KG/KGGen est incorrecte.'); | |
| const kggenSeries=kggenData.series.find(series=>series[0]==='kggen'); | |
| if(!kggenSeries||!kggenData.value(kggenData.categories[0],kggenSeries).imported)throw new Error('Les mesures KGGen importées sont absentes.'); | |
| const legacy=context.artifactRowsFromRaw([{ | |
| kg_name:'KG_GEN_kg',model_name:'RotatEGCN_attn',hidden_channels:256, | |
| test_acc_mean:.5944,test_acc_std:.0223,test_f1_mean:.5799,test_f1_std:.0332 | |
| }],'best_by_graph_model.csv'); | |
| if(legacy.length!==2||legacy[0].dataset!=='biomed'||legacy[0].graph!=='kggen')throw new Error('Le format historique KGGen n’est pas reconnu.'); | |
| if(legacy[1].metric!=='macro_f1'||legacy[1].stdSeed!==.0332)throw new Error('Les métriques historiques KGGen sont incorrectes.'); | |
| const selectedLegacy=context.selectLeaderboardArtifactFiles([ | |
| {name:'all_results.json',webkitRelativePath:'KG_GEN_graph/all_results.json'}, | |
| {name:'all_results_summary.csv',webkitRelativePath:'KG_GEN_graph/all_results_summary.csv'}, | |
| {name:'best_by_graph_model.csv',webkitRelativePath:'KG_GEN_graph/best_by_graph_model.csv'}, | |
| {name:'summary_KG_GEN_kg__GCN__h64.csv',webkitRelativePath:'KG_GEN_graph/KG_GEN_kg/GCN/h64/summary_KG_GEN_kg__GCN__h64.csv'} | |
| ]); | |
| if(selectedLegacy.length!==1||selectedLegacy[0].name!=='best_by_graph_model.csv')throw new Error('Le dossier historique KGGen ne sélectionne pas le bon agrégat.'); | |
| console.log('Comparaison d’artefacts valide : import, fusion et trois visualisations.'); | |