get_rating()
        
        Returns the unmodified average rating.
321073
def get_real_rating(self):
        """"""
        if not (self.votes and self.score):
            return 0
        return float(self.score)/self.votes
1061391
protected function getRatings()
    {
        $ratings = array();

        for ($i = 1; $i <= $this->maximum_value; $i++) {
            $ratings[$i] = sprintf('%s/%s', $i, $this->maximum_value);
        }

        return $ratings;
    }
251187
def rate(self, rating):
        
        parameters = {
            'voterid': self._current_user_id,
            'target_userid': self.id,
            'type': 'vote',
            'cf': 'profile2',
            'target_objectid': 0,
            'vote_type': 'personality',
            'score': rating,
        }
        response = self._session.okc_post('vote_handler',
                                          data=parameters)
        response_json = response.json()
        log_function = log.info if response_json.get('status', False) \
                       else log.error
        log_function(simplejson.dumps({'rate_response': response_json,
                                       'sent_parameters': parameters,
                                       'headers': dict(self._session.headers)}))
        self.refresh(reload=False)
85959
def avg_rate(self):
        
        if not self._has_data or 'sum' not in self.result['end']:
            return None
        bps = self.result['end']['sum']['bits_per_second']
        return bps / 8 / 1024 / 1024
837811
public function getRatingValue()
    {
        if ($this->_ratingValue === null) {
            return null;
        }

        $range = new RangeValue($this->_ratingValue);
        $range->ensureRange($this->_worstRating ?: 0, $this->_bestRating ?: 5);

        return $this->_ratingValue = $range->getValue();
    }
304767
def get_averages(self):
        
        networks = [unescape_html(n.string) for n in self.soup.find_all('td', width='77')]
        table = self.soup.find_all('td', style=re.compile('^font'))

        # Each element is a list split as [rating, share]
        rateshares = [r.string.split('/') for r in table[:5] if r.string]
        viewers = [v.string for v in table[5:] if v.string]
        averages = {}

        # Load the averages dict
        for index, network in enumerate(networks):
            viewer = convert_float(unescape_html(viewers[index]))
            rating = convert_float(unescape_html(rateshares[index][0]))
            share = convert_float(unescape_html(rateshares[index][1]))
            averages[network] = {'viewer': viewer, 'rating': rating, 'share': share}

        return averages
915122
def average_precision(truth, recommend):
    
    if len(truth) == 0:
        if len(recommend) == 0:
            return 1.
        return 0.

    tp = accum = 0.
    for n in range(recommend.size):
        if recommend[n] in truth:
            tp += 1.
            accum += (tp / (n + 1.))
    return accum / truth.size
647597
static function stats( $ContentObjectID )
    {
        static $cachedStats = array( 0 => null );
        if ( isset( $cachedStats[$ContentObjectID] ) )
        {
            return $cachedStats[$ContentObjectID];
        }
        else
        {
            $custom = array( array( 'operation' => 'sum( rating_count )',
                                    'name'      => 'rating_count' ) ,
                             array( 'operation' => 'avg( rating_average )',
                                    'name'      => 'rating_average' ) );
            $cond = array( 'contentobject_id' => $ContentObjectID );
            $return = self::fetchObjectList( self::definition(), array() ,$cond, null, null, false, false, $custom );

            if ( isset( $return[0]['rating_count'] ) )
                $return = $return[0];

            $cachedStats[$ContentObjectID] = $return;
        }
        return $return;
    }
112757
def rating_count(obj):
    
    count = Rating.objects.filter(
        object_id=obj.pk,
        content_type=ContentType.objects.get_for_model(obj),
    ).exclude(rating=0).count()
    return count
1264325
def mean(self):
        

        return np.dot(np.array(self.norm_scores), self.weights)
377714
def rating(self, value):
        """"""
        self._rating = value
        self._thumb  = self._link_to_img()
71994
def update_rating(self, postid):
        '''
        
        '''
        post_data = self.get_post_data()
        rating = float(post_data['rating'])
        postinfo = MPost.get_by_uid(postid)
        if postinfo and self.userinfo:
            MRating.update(postinfo.uid, self.userinfo.uid, rating=rating)
            self.update_post(postid)
        else:
            return False
533103
public function getRating() : ?int 
    {
        if ( ! $this->hasRating()) {
            $this->setRating($this->getDefaultRating());
        }
        return $this->rating;
    }
1227188
def creditusage(cls):
        """"""
        rating = cls.call('hosting.rating.list')
        if not rating:
            return 0

        rating = rating.pop()
        usage = [sum(resource.values())
                 for resource in rating.values()
                 if isinstance(resource, dict)]
        return sum(usage)
735282
def unrate_url(obj):
    
    return reverse('ratings_unrate_object', args=(
        ContentType.objects.get_for_model(obj).pk,
        obj.pk,
    ))
825023
protected function make_rating( $repo_meta ) {
		$watchers    = ! empty( $repo_meta['watchers'] ) ? $repo_meta['watchers'] : 0;
		$forks       = ! empty( $repo_meta['forks'] ) ? $repo_meta['forks'] : 0;
		$open_issues = ! empty( $repo_meta['open_issues'] ) ? $repo_meta['open_issues'] : 0;

		$rating = abs( (int) round( $watchers + ( $forks * 1.5 ) - ( $open_issues * 0.1 ) ) );

		if ( 100 < $rating ) {
			return 100;
		}

		return $rating;
	}
1278234
def _weight_generator(self, reviewers):
        
        scores = [r.anomalous_score for r in reviewers]
        mu = np.average(scores)
        sigma = np.std(scores)

        if sigma:
            def w(v):
                """Compute a weight for the given reviewer.

                Args:
                  v: anomalous score of a reviewer.
                Returns:
                  weight of the given anomalous score.
                """
                try:
                    exp = math.exp(self.alpha * (v - mu) / sigma)
                    return 1. / (1. + exp)
                except OverflowError:
                    return 0.

            return w

        else:
            # Sigma = 0 means all reviews have same anomalous scores.
            # In this case, all reviews should be treated as same.
            return lambda v: 1.