Created
September 8, 2014 15:07
-
-
Save PirosB3/fbe3adebbe2ed012a082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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