From 9b87157a1caebd2915315dfca9d0183c0407aa2d Mon Sep 17 00:00:00 2001 From: Yassine Date: Tue, 30 May 2017 10:01:38 +0200 Subject: [PATCH] Add files via upload --- .../bike-sharing prediction/datasource.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 samples/features/machine-learning-services/python/getting-started/bike-sharing prediction/datasource.py diff --git a/samples/features/machine-learning-services/python/getting-started/bike-sharing prediction/datasource.py b/samples/features/machine-learning-services/python/getting-started/bike-sharing prediction/datasource.py new file mode 100644 index 00000000..214ce082 --- /dev/null +++ b/samples/features/machine-learning-services/python/getting-started/bike-sharing prediction/datasource.py @@ -0,0 +1,38 @@ +from revoscalepy.computecontext.RxComputeContext import RxComputeContext +from revoscalepy.computecontext.RxInSqlServer import RxInSqlServer +from revoscalepy.computecontext.RxInSqlServer import RxSqlServerData +from revoscalepy.etl.RxImport import rx_import_datasource + + +class DataSource(): + + def __init__(self, connectionstring): + + """Data source remote compute context + + + Args: + connectionstring: connection string to the SQL server. + + + """ + self.__connectionstring = connectionstring + + + + def loaddata(self): + dataSource = RxSqlServerData(sqlQuery = "select * from dbo.trainingdata", verbose=True, reportProgress =True, + connectionString = self.__connectionstring) + + self.__computeContext = RxInSqlServer(connectionString = self.__connectionstring, autoCleanup = True) + data = rx_import_datasource(dataSource) + + return data + + def getcomputecontext(self): + + if self.__computeContext is None: + raise RuntimeError("Data must be loaded before requesting computecontext!") + + return self.__computeContext +