定制 ilicmiljan/weighted-ratings 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ilicmiljan/weighted-ratings

最新稳定版本:v1.1.0

Composer 安装命令:

composer require ilicmiljan/weighted-ratings

包简介

A lightweight PHP library for calculating the Wilson Lower Bound Score and Bayesian Approximation weights for sorting algorithms based on user feedback.

README 文档

README

A lightweight PHP library for calculating the Wilson Lower Bound Score and Bayesian Approximation weights for sorting algorithms based on user feedback.

Installation

Weighted Ratings Library is available via Composer. Just add this line to your composer.json file:

"ilicmiljan/weighted-ratings": "^1.0" 

or you can run:

composer require ilicmiljan/weighted-ratings 

Note that the vendor folder and the vendor/autoload.php script are generated by Composer and they are not part of Weighted Ratings Library.

Configuration

Available Formulas

RatingWeightCalculator::FORMULA_WILSON_LOWER_BOUND RatingWeightCalculator::FORMULA_BAYESIAN_APPROXIMATION

Optional Configuration Parameters

  • ausmeNegativeRatingisLessThan - Number of stars in the rating that are assumed as negative (Default: 3)
  • confidence - Statistical Confidence used in Formulas (Default: 0.95)

Without RatingWeightConfig

You can use default optional config parameters to calculate weights without instantiating RateLimiterConfig. This can be achieved by setting the formula in the instance of RatingWeightCalculator.

Using RatingWeightConfig

You can create a new instance of RatingWeightConfig with all the parameters and pass it to the RatingWeightCalculator.

Changing Formula

The formula for one instance of RatingWeightCalculator can be set only once. Changing formula in the runtime will throw an exception.

Usage

With Default Config Parameters

$weightCalculator = new RatingWeightCalculator(); $ratingWeight = $weightCalculator->formula(RatingWeightCalculator::FORMULA_WILSON_LOWER_BOUND) ->calculateWeight([2,4,6,12,24]);

With Custom Parameters

$weightCalculator = new RatingWeightCalculator( new RatingWeightConfig(RatingWeightCalculator::FORMULA_WILSON_LOWER_BOUND, 5, 0.9) ); $ratingWeight = $weightCalculator->calculateWeight([2,4,6,12,24,48,92,184,]);

Testing

To run Unit Tests inside this library you can use this command:

./vendor/bin/phpunit 

Infection PHP Metrics:

  • Mutation Score Indicator (MSI): 98%
  • Mutation Code Coverage: 100%
  • Covered Code MSI: 98%

统计信息

  • 总下载量: 47.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固