Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ksipos committed Mar 5, 2020
2 parents a650aed + b6b1114 commit cc4ebd1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1,210 deletions.
16 changes: 13 additions & 3 deletions antoine/heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use_condaenv('my_env_3') # just a Python 3 environment with the 'rbo' module ins

rbo = import('rbo') # see https://github.com/changyaochen/rbo

method_names_en = c('oxford','ontonotes','wikipedia','wndomains','wordnet_original','wordnet_restricted')
method_names_fr = c('larousse','wikipedia')

# = = = = = = = = = = = = = = = = functions

dcg = function(x) {
Expand Down Expand Up @@ -76,8 +79,6 @@ score_ranking = function(evaluated,gt,metric){

# = = = = = = = = = = = = = = = = arguments

# TODO heatmap of score vs PCA dimensions and max levels

args = commandArgs(trailingOnly=TRUE)

# Rscript --vanilla heatmap.R path_root metric
Expand Down Expand Up @@ -105,6 +106,14 @@ if (!language%in%c('english','french')){
stop(paste(language,'is currently not supported!'))
}

if (language=='english'){
method_names = method_names_en
}

if (language=='french'){
method_names = method_names_fr
}

# relevant links about the metrics:
# - https://en.wikipedia.org/wiki/Learning_to_rank#Evaluation_measures
# see: https://stats.stackexchange.com/questions/8071/how-to-choose-between-pearson-and-spearman-correlation
Expand Down Expand Up @@ -287,7 +296,8 @@ rankings[['random']] = lapply(1:n_runs,function(x){
})

# re-order/re-name to optimize the heatmap (our method, random, and frequency first)
method_names = c(best_name_renamed,'random','frequency','oxford','ontonotes','wikipedia','wndomains','wordnet_original','wordnet_restricted')
method_names = c(c(best_name_renamed,'random','frequency'),method_names)

method_names_pretty = gsub('_',' ',method_names)

pdf(paste0(path_to_plots,'score_distributions.pdf'),paper='a4r',width=10,height=7)
Expand Down
15 changes: 7 additions & 8 deletions antoine/pyramid_scores_by_hand.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
my_score = function(level,n_levels,coverage){
coverage/(2^(n_levels-level))
}
levels = 0:2

levels = 1:3
n_dims = 2
n_bins = unlist(lapply(levels,function(x) 2^(x*n_dims)))

# word 1
covs = c(3/4,7/16,10/64)
sum(unlist(lapply(levels,function(level) my_score(level,length(levels),covs[level]))))
covs = c(3,7,10)/n_bins
sum(unlist(lapply(levels,function(level) covs[level+1]/(2^(max(levels)-level)))))

# word 2
covs = c(1/4,4/16,7/64)
sum(unlist(lapply(levels,function(level) my_score(level,length(levels),covs[level]))))
covs = c(1,4,7)/n_bins
sum(unlist(lapply(levels,function(level) covs[level+1]/(2^(max(levels)-level)))))


Loading

0 comments on commit cc4ebd1

Please sign in to comment.