Skip to content

Instantly share code, notes, and snippets.

@PirosB3
Created September 8, 2014 15:07
Show Gist options
  • Save PirosB3/fbe3adebbe2ed012a082 to your computer and use it in GitHub Desktop.
Save PirosB3/fbe3adebbe2ed012a082 to your computer and use it in GitHub Desktop.
MAX_TRACKS = 20
MAX_VECTORS = 200
SHOP_ID = 1
MAX_SECONDS_IN_THE_PAST = 30 * 60
from random import randint
from sklearn.datasets import make_regression
import numpy as np
import pylab
import time
def create_dataset_vector():
to = randint(1, MAX_VECTORS)
X, Y = make_regression(n_samples=to, n_features=1, n_informative=1,\
random_state=0, noise=35)
# Only one feature
X = X.T[0]
to_millis = int(round(time.time()))
from_millis = to_millis - randint(0, MAX_SECONDS_IN_THE_PAST)
timestamps = map(int, np.linspace(from_millis, to_millis, to))
print "Created %s [X, Y, ts] vectors, with timestamp range from %s to %s" % (
to, from_millis, to_millis
)
return [{'x': x, 'y': y, 'timestamp': timestamp}
for x, y, timestamp
in np.array([X, Y, timestamps]).T
]
def main():
data = {
'X8123': {
'tracks': {
'1': create_dataset_vector(),
'2': create_dataset_vector()
}
}
}
from pymongo import MongoClient
client = MongoClient('5.101.98.142', 49153)
client.dummy.data.insert(data)
#curve_data, t = make_s_curve(100)
#curve_data = curve_data.T[1:3]
#pylab.figure()
#pylab.scatter(X, Y, label='noisy measurements')
#pylab.show()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment