• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest May 22nd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import numpy
2.
3. dataset = numpy.loadtxt(open('beeradvocate5.csv', "rb"), delimiter = ',')
4. dataset = [[(y-1)*5 for y in x] for x in dataset]
5.
6. print("1) " + str(len(dataset)))
7. print("2) " + str(numpy.average([r[0] for r in dataset])))
8. print("3) " + str(numpy.average([r[1] for r in dataset])))
9. print("4) " + str(numpy.average([r[2] for r in dataset])))
10. print("5) " + str(numpy.average([r[3] for r in dataset])))
11. print("6) " + str(numpy.average([r[4] for r in dataset])))
12. print("7) " + str(max([r[0] for r in dataset])))
13. print("8) " + str(numpy.average([r[1] for r in dataset[:500]])))
14. print("9) " + str(numpy.average([r[1] for r in dataset[-500:]])))
15. print("10) " + str(numpy.median([dataset[i][1] for i in numpy.arange(start = 0, stop = len(dataset), step = 2)])))
16. print("11) " + str([r[4] for r in dataset].index(max([r[4] for r in dataset]))))
17. print("12) " + str([numpy.var([r[i] for r in dataset]) for i in numpy.arange(len(dataset[0]))]) + " => taste")
18. print("13) " + str(sum(1 for _ in filter(lambda x: x > 15.0, numpy.array(dataset).flatten()))))
19. print("14) " + str(sum(1 for _ in filter(lambda x: x > 15.0, [r[1] for r in dataset]))))
20. print("15) " + str(sum(1 for _ in filter(lambda x: x[0] > x[1], zip([r[1] for r in dataset], [numpy.average([r[1] for r in dataset])] * len(dataset))))))
21. print("16) " + str(sum(1 for _ in filter(lambda x: x[0] > x[1], zip([r[2] for r in dataset], [numpy.median([r[2] for r in dataset])] * len(dataset))))))
22. print("17) " + str(sum(1 for _ in filter(lambda x : all(y > 15.0 for y in x), dataset))))
23. print("18) " + str(numpy.average([a[4] for a in filter(lambda x: x[3] > 15.0, dataset)])))
24. print("19) " + str(sorted([(i, numpy.average(dataset[i])) for i in numpy.arange(len(dataset))], key=lambda x: x[1], reverse=True)[1][0]))
25. print("20) " + str(sorted(filter(lambda x: x[1]>15.0, [(i, numpy.average(dataset[i]), dataset[i][3]) for i in numpy.arange(len(dataset))]), key=lambda x: x[2])[0]))
26.
27. med = numpy.median([r[4] for r in dataset])
28. print("21) " + str(numpy.average([r[1] for r in filter(lambda x: x[4] > med, dataset)])))
29.
30. print("22) " + str(max([numpy.average(dataset[i], weights = [6.,1.,0.5,0.,2]) for i in numpy.arange(len(dataset))])))
31. print("23) " + str(list(map(lambda d: numpy.average(d, weights = [6.,1.,0.5,0.,2]), dataset)).index(max([numpy.average(dataset[i], weights = [6.,1.,0.5,0.,2]) for i in numpy.arange(len(dataset))]))))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top