-
-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathrandom_selection.py
More file actions
34 lines (27 loc) · 729 Bytes
/
random_selection.py
File metadata and controls
34 lines (27 loc) · 729 Bytes
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
29
30
31
32
33
34
""" Random Selection
"""
# Importing the libraries
import matplotlib.pyplot as plt
import pandas as pd
import random
def main():
# Importing the dataset
dataset = pd.read_csv('Ads_CTR_Optimisation.csv')
# Implementing Random Selection
N = 10000
d = 10
ads_selected = []
total_reward = 0
for n in range(0, N):
ad = random.randrange(d)
ads_selected.append(ad)
reward = dataset.values[n, ad]
total_reward = total_reward + reward
# Visualising the results
plt.hist(ads_selected)
plt.title('Histogram of ads selections')
plt.xlabel('Ads')
plt.ylabel('Number of times each ad was selected')
plt.show()
if __name__ == '__main__':
main()