-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,17 @@ | ||
--- | ||
method: kemeny | ||
method: copeland | ||
out: /home/pooya/Projects/UTR/samples/output.dat | ||
estimators: | ||
pooya: | ||
path: /home/pooya/Projects/UTR/samples/pooya.dat | ||
weight: 1 | ||
hamed: | ||
path: /home/pooya/Projects/UTR/samples/hamed.dat | ||
listnet: | ||
path: /home/pooya/Projects/UTR/samples/listnet.dat | ||
weight: 2 | ||
javid: | ||
path: /home/pooya/Projects/UTR/samples/javid.dat | ||
weight: 5 | ||
|
||
# method: kemeny | ||
# out: /home/pooya/Projects/UTR/samples/output.dat | ||
# estimators: | ||
# listnet: | ||
# path: /home/pooya/Projects/UTR/samples/listnet.dat | ||
# weight: 2 | ||
# ranknet: | ||
# path: /home/pooya/Projects/UTR/samples/ranknet.dat | ||
# weight: 3 | ||
# listmle: | ||
# path: /home/pooya/Projects/UTR/samples/listmle.dat | ||
# weight: 3 | ||
# svm: | ||
# path: /home/pooya/Projects/UTR/samples/svm.dat | ||
# weight: 1 | ||
# evaluation: | ||
# solution_file: /home/pooya/Projects/UTR/samples/solution.dat | ||
ranknet: | ||
path: /home/pooya/Projects/UTR/samples/ranknet.dat | ||
weight: 3 | ||
listmle: | ||
path: /home/pooya/Projects/UTR/samples/listmle.dat | ||
weight: 3 | ||
svm: | ||
path: /home/pooya/Projects/UTR/samples/svm.dat | ||
weight: 1 | ||
evaluation: | ||
solution_file: /home/pooya/Projects/UTR/samples/solution.dat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
--- | ||
init: -> initializing and loading configs | ||
loading_data: -> loading data from input files | ||
init: -> Unitializing and loading configs | ||
loading_data: -> Loading data from input files | ||
dumping: -> Writing aggregation result to file | ||
evaluating: -> evaluating base rankings and the aggregation | ||
evaluating: -> Evaluating base rankings and the aggregation | ||
kemeny: -> Applying kemeny aggregating method | ||
borda: -> Applying borda aggregating method | ||
done: -> done :) | ||
copeland: -> Applying copeland aggregating method | ||
done: -> Done :) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require './lib/inits/config.rb' | ||
require './lib/common/quick.rb' | ||
|
||
module CopelandModule | ||
|
||
def self.included(base) | ||
base.extend(ClassMethods) | ||
end | ||
|
||
module ClassMethods | ||
|
||
def run data | ||
puts $MESSAGES[:copeland] | ||
scores = Hash.new { |h,k| h[k] = Hash.new {|hh,kk| hh[kk] = 0}} | ||
data.each do |estimator, hash| | ||
hash.each do |group_id, hash2| | ||
hash2.keys[0..-2].each_with_index do |instance_id,i| | ||
(i+1..hash2.keys.size-1).each do |j| | ||
#puts "comparing #{instance_id}:#{hash2[instance_id]} with #{hash2.keys[j]}:#{hash2[hash2.keys[j]]}" | ||
if hash2[instance_id] > hash2[hash2.keys[j]] | ||
scores[group_id][instance_id] += 1 | ||
scores[group_id][hash2.keys[j]] -= 1 | ||
elsif hash2[instance_id] < hash2[hash2.keys[j]] | ||
scores[group_id][instance_id] -= 1 | ||
scores[group_id][hash2.keys[j]] += 1 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
result = {} | ||
scores.each do |group_id, hash| | ||
result[group_id] = hash.keys.sort_by { |instance_id| [-1*hash[instance_id], -1*instance_id] } | ||
end | ||
|
||
puts result | ||
return result | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
1,8,9 | ||
1,6,8 | ||
1,1,7 | ||
1,4,6 | ||
1,9,5 | ||
1,7,4 | ||
1,5,3 | ||
1,2,2 | ||
1,3,1 | ||
1,222,5 | ||
1,333,4 | ||
1,444,3 | ||
1,111,2 | ||
1,555,1 | ||
2,236,5 | ||
2,234,4 | ||
2,233,3 | ||
2,231,2 | ||
2,232,1 |