Last active
          February 26, 2020 04:17 
        
      - 
      
 - 
        
Save adzkar/c38f16036bf0fc53d33c0cc66adc6aec to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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]) + (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 ] | |
| 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] | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment