-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain-imported-git.py
34 lines (26 loc) · 994 Bytes
/
main-imported-git.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
29
30
31
32
33
34
# This is a sample Python script
# Import dependencies
import random
import matplotlib.pyplot as plt
import json
import os
import matplotlib
matplotlib.use('Agg')
plt.switch_backend('Agg')
# Print to console/stdout
print("Hello, {0}!".format(os.environ['DOMINO_PROJECT_OWNER']))
# Define a helper function to generate a random number
def random_number(start, stop):
return random.uniform(start, stop)
# Plot the values of random points
x = random.sample(range(1000), 100)
xbins = [0, len(x)]
plt.bar(range(0, 100), x)
# plt.show()
plt.savefig('{}/results/myHistogramFromPython.png'.format(os.environ["DOMINO_WORKING_DIR"]), format='png')
# Generate and save some key statistics to dominostats.json
# learn more at http://support.dominodatalab.com/hc/en-us/articles/204348169
r2 = round(random_number(0, 1), 4)
p = round(random_number(0, 1), 4)
with open('{}/dominostats.json'.format(os.environ["DOMINO_WORKING_DIR"]), 'w') as f:
f.write(json.dumps({"R^2": r2, "p-value": p}))