scalg
Version 0.1.5.3
该算法基于百分比接近原理的作用。最初是为一个个人项目开发的,但是后来我发现这是一种牛顿在统计中用于求解最大似然方程的形式。
pip install scalg
截至2020年9月15日,它包含两种方法( score和score_columns ),将在下面的示例中进行描述和证明。
import scalg
这将是带有相应索引和列权重的示例的示例数据集。
Columns -> 0 1 2 3
Weights -> 1 0 0 1
1[[2016 ,21999 ,62000 ,181],
Sets -> 2 [2013 ,21540 ,89000 ,223],
3 [2015 ,18900 ,100000 ,223],
4 [2013 ,24200 ,115527 ,223],
5 [2016 ,24990 ,47300 ,223]]
如果您传递源_data和权重,输出:
scalg.score(source_data, [1, 0, 0, 1])
[[2016, 21999, 62000, 181, 2.2756757812463335],
[2013, 21540, 89000, 223, 1.9553074815952338],
[2015, 18900, 100000, 223, 2.894245191297678],
[2013, 24200, 115527, 223, 1.1297208538587848],
[2016, 24990, 47300, 223, 3.0]]
如果您传递源_data,witchs and get_scores = true,则输出:
scalg.score(source_data, [1, 0, 0, 1], get_scores=True)
[2.2756757812463335, 1.9553074815952338, 2. 894245191297678, 1.1297208538587848, 3.0]
输出如果传递源_data,withs and get_score_lists = true:true:
scalg.score(source_data, [1, 0, 0, 1], get_score_lists=True)
[[1.0 ,0.0, 0.6666666666666666 ,0.0 ,1.0]
[0.49113300492610834 ,0.5665024630541872 ,1.0, 0.12972085385878485 ,0.0]
[0.7845427763202251 ,0.38880501854104677 ,0.22757852463101114 ,0.0]
[0.0 ,1.0 ,1.0 ,1.0]]
与其他元素相比,这给出了列表中每个元素的分数,从而保持其位置。
在这里,您可以使用在scalg.score中使用的相同权重,也可以在相应的顺序中指定每列的权重。在此示例中,使用权重参数[1, 0, 0, 1]或[0, 1]没有区别。
如果您传递源_data,列和权重:输出:
scalg.score_columns(source_data, [0, 1], [1, 0, 0, 1])
Scored columns Scores for corresponding columns
0| 1| |
[[2016 ,21999 ,62000 ,181 ,1.4911330049261085],
[2013 ,21540 ,89000 ,223 ,0.5665024630541872],
[2015 ,18900 ,100000 ,223 ,1.6666666666666665],
[2013 ,24200 ,115527 ,223 ,0.12972085385878485],
[2016 ,24990 ,47300 ,223 ,1.0]]
分数仅根据列0和1计算。