美文网首页
微信传播指数WCI(V14.2)

微信传播指数WCI(V14.2)

作者: Mracale | 来源:发表于2024-01-09 14:28 被阅读0次
    """
        功能:WCI指数计算器
    """
    
    import math
    import xlrd
    
    def main():
    
        y_or_n = input('是否退出程序(y/n)?')
        while y_or_n != 'y':
            # 总阅读数R
            print('请输入以下参数:')
            n = float(input('文章总数(n)'))
            R = float(input('阅读总数(R)'))
            Z = float(input('在看总数增量(Z)'))
            Rt = float(input('头条文章阅读量(Rt)'))
            Zt = float(input('头条文章在看数(Zt)'))
            L = float(input('点赞总数(L)'))
            Lt = float(input('头条文章点赞总数(Lt)'))
            Rmax = float(input('最大阅读数(Rmax)'))
            Zmax = float(input('最大在看数(Zmax)'))
            Lmax = float(input('最大点赞数(Lmax)'))
            d = 30
    
            #微信传播指数WCI(V14.2)
            P1 = 0.85*math.log(R / d + 1) + 0.09*math.log(Z / d * 10 + 1) +0.06*math.log(L / d * 10 + 1)
    
            P2 = 0.85*math.log(R / n + 1) + 0.09*math.log(Z / n * 10 + 1) + 0.06*math.log(L / n * 10 + 1)
    
            P3 = 0.85*math.log(Rt / d + 1) + 0.09*math.log(Zt / d * 10 + 1) + 0.06*math.log(Lt / d * 10 + 1)
    
            P4 = 0.85*math.log(Rmax + 1) + 0.09*math.log(Zmax * 10 + 1) + 0.06*math.log(Lmax * 10 + 1)
    
            P5 = 0.6 * P1 + 0.2 * P2 + 0.1 * P3 + 0.1 * P4
            WCI = P5*P5*1.2 * 10
    
            print('WCI指数为:', WCI)
            print('————————————————————————————')
            y_or_n = input('是否退出程序(y/n)?')
    
    def myln(x):
        try:
            return math.log(x)
        except ValueError:
            return 1
    
    def test():
        data = xlrd.open_workbook_xls("C:/Users/Administrator/Desktop/1112.xls")
        table = data.sheets()[0]
        nrows = table.nrows
        for i in range(nrows):
            if i ==0:
                continue
            val = table.row_values(i)
            try:
                n = val[2]
                R = val[6]
                Z = val[11]
                Rt = val[16]
                Zt = val[18]
                L = val[22]
                Lt = val[25]
                Rmax = val[19]
                Zmax = val[20]
                Lmax = val[24]
                d = 30
    
                # 微信传播指数WCI(V14.2)
                P1 = 0.85 * myln(R / d + 1) + 0.09 * myln(Z / d * 10 + 1) + 0.06 * myln(L / d * 10 + 1)
    
                P2 = 0.85 * myln(R / n + 1) + 0.09 * myln(Z / n * 10 + 1) + 0.06 * myln(L / n * 10 + 1)
    
                P3 = 0.85 * myln(Rt / d + 1) + 0.09 * myln(Zt / d * 10 + 1) + 0.06 * myln(Lt / d * 10 + 1)
    
                P4 = 0.85 * myln(Rmax + 1) + 0.09 * myln(Zmax * 10 + 1) + 0.06 * myln(Lmax * 10 + 1)
    
                P5 = 0.6 * P1 + 0.2 * P2 + 0.1 * P3 + 0.1 * P4
                WCI = P5 * P5 * 1.2 * 10
                print(val[0] + ":", WCI)
            except ValueError:
                print(ValueError)
    
    if __name__ == '__main__':
        test()
    
    

    相关文章

      网友评论

          本文标题:微信传播指数WCI(V14.2)

          本文链接:https://www.haomeiwen.com/subject/paqandtx.html