]> git.sesse.net Git - wloh/blobdiff - www/index.pl
Train one model (with its own aux parms) per locale.
[wloh] / www / index.pl
index 506faf52ab0e4667d4c13b4420e916790f998954..7546d658ac8a4b5bf14bf8a30b8e46d408c4092b 100755 (executable)
@@ -313,27 +313,6 @@ sub find_avg_rating {
        return $sum_rating / scalar keys %$ratings;
 }
 
-sub get_auxillary_parameters {
-       my ($dbh) = @_;
-
-       my %aux_parm_names = {
-               -1 => num_iterations,
-               -2 => score_stddev,
-               -3 => rating_prior_stddev,
-               -4 => total_log_likelihood,
-       };
-
-       my $q = $dbh->prepare('SELECT * FROM ratings WHERE id < 0');
-       $q->execute;
-
-       my $aux_parms = {};
-       while (my $ref = $q->fetchrow_hashref) {
-               my $id = $ref->{'id'};
-               $aux_parms->{$aux_parm_names{$id}} = $ref->{'rating'};
-       }
-       return $aux_parms;
-}
-
 sub print_header {
        my ($cgi, $title) = @_;
        print $cgi->header(-type=>'text/html; charset=utf-8', -expires=>'now');
@@ -358,7 +337,8 @@ sub print_footer {
 EOF
 }
 
-my $aux_parms = get_auxillary_parameters($dbh);
+my $locale = wloh_common::get_locale($cgi);
+my $aux_parms = wloh_common::get_auxillary_parameters($dbh, $locale);
 my $match_stddev = $aux_parms->{'score_stddev'} * sqrt(2.0);
 
 my $division = $cgi->param('divisjon') // -1;
@@ -366,7 +346,6 @@ my $subdivision = $cgi->param('avdeling') // -1;
 my $match_player = $cgi->param('spiller');
 my $match_position = $cgi->param('posisjon');
 
-my $locale = wloh_common::get_locale($cgi);
 my $season = wloh_common::get_max_season($dbh, $locale);
 die "Nonexistent locale!" if (!defined($season));