forked from micah5/sponsorship_remover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.py
28 lines (21 loc) · 745 Bytes
/
stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sys
import numpy as np
import datetime
import math
from argparse import ArgumentParser
def pretty_date(seconds):
return str(datetime.timedelta(seconds=math.ceil(seconds)))
def main(argv):
parser = ArgumentParser()
parser.add_argument("-c", "--channel", dest="channel", help="channel id")
args = parser.parse_args()
data = np.load('output/%s.npy' % args.channel)
sum_avg = 0
for list in data:
arr = np.array(list)
sum_avg += np.count_nonzero(arr==0)/arr.size
avg = sum_avg/data.size
print('Avg of video that is sponsorship:', round(avg*100), '%')
print('Avg time of sponsorship:', pretty_date(np.count_nonzero(arr==0)*5), '%')
if __name__ == "__main__":
main(sys.argv[1:])