Skip to content

Instantly share code, notes, and snippets.

@adzkar
Last active February 26, 2020 04:17
Show Gist options
  • Select an option

  • Save adzkar/c38f16036bf0fc53d33c0cc66adc6aec to your computer and use it in GitHub Desktop.

Select an option

Save adzkar/c38f16036bf0fc53d33c0cc66adc6aec to your computer and use it in GitHub Desktop.

Revisions

  1. adzkar revised this gist Dec 1, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion selebgram.py
    Original file line number Diff line number Diff line change
    @@ -59,7 +59,6 @@ def inference(follower, rate):
    def sugeno(param):
    return ((50 * param[0]) + (70 * param[1]) + (100 * param[2]))/sum(param)


    datas = [ data.split(',') for data in open('influencers.csv').read().splitlines()[1:] ]
    datas = [ [int(data[0]), int(data[1]), float(data[2])] for data in datas ]

  2. adzkar revised this gist Dec 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion selebgram.py
    Original file line number Diff line number Diff line change
    @@ -57,7 +57,7 @@ def inference(follower, rate):
    return [rej, consd, acc]

    def sugeno(param):
    return ((50 * param[0]) + (60 * param[1]) + (100 * param[2]))/sum(param)
    return ((50 * param[0]) + (70 * param[1]) + (100 * param[2]))/sum(param)


    datas = [ data.split(',') for data in open('influencers.csv').read().splitlines()[1:] ]
  3. adzkar created this gist Dec 1, 2019.
    73 changes: 73 additions & 0 deletions selebgram.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@
    def memberFollower(x):
    low, avg, high = 0,0,0
    if x > 20000:
    low = 0
    elif x > 15000 and x <= 20000:
    low = (20000 - x) / (20000-15000)
    elif x <= 15000:
    low = 1

    if x > 55000 or x < 15000:
    avg = 0
    elif x >= 15000 and x <= 25000:
    avg = (x - 15000)/(25000-15000)
    elif x >= 55000 and x >= 25000:
    avg = (55000 - x)/(55000 - 25000)

    if x > 65000:
    high = 1
    elif x < 55000:
    high = 0
    elif x >= 55000 and x <= 65000:
    high = (65000 - x)/(65000 - 55000)

    return [low, avg, high]

    def memberRate(x):
    low, avg, high = 0,0,0
    if x > 4:
    low = 0
    elif x <= 2:
    low = 1
    elif x >= 4 and x < 2:
    low = (4 - x)/(4-2)

    if x > 7 or x < 2:
    avg = 0
    elif x >= 2 and x < 4:
    avg = (x-2)/(4-2)
    elif x >= 4 and x <= 6:
    avg = 1
    elif x <= 7 and x > 6:
    avg = (7-x)/(7-6)

    if x >= 8:
    high = 1
    elif x < 7:
    high = 0
    elif x >= 7 and x < 8:
    high = (7-x)/(8-7)

    return [low, avg, high]

    def inference(follower, rate):
    rej = max(max(follower[0], rate[0]), max(follower[0], rate[1]), max(follower[1], rate[0]))
    consd = max(max(follower[0], rate[2]), max(follower[1], rate[1]), max(follower[2], rate[0]))
    acc = max(max(follower[1], rate[2]), max(follower[2], rate[1]), max(follower[2], rate[2]))
    return [rej, consd, acc]

    def sugeno(param):
    return ((50 * param[0]) + (60 * param[1]) + (100 * param[2]))/sum(param)


    datas = [ data.split(',') for data in open('influencers.csv').read().splitlines()[1:] ]
    datas = [ [int(data[0]), int(data[1]), float(data[2])] for data in datas ]

    for data in datas:
    follower = memberFollower(data[1])
    rate = memberRate(data[2])
    inf = inference(follower, rate)
    data.append(round(sugeno(inf),2))

    datas = sorted(datas, reverse=True, key= lambda x: x[3])
    print datas[:20]