Beispiel #1
0
	def post(self,requests,modelName):
		try:
			filePath=requests.POST.get('filePath')
			if not filePath:
				raise Exception("Invalid Request Parameter")
		except:
			return JsonResponse({'error':'Invalid Request Parameter'},status=400)
		return Scoring.predicttestdata(filePath,modelName)
Beispiel #2
0
	def get(self,requests,modelName):
		try:
			jsonData = json.loads(requests.GET['jsonRecord'])
			if not jsonData:
				raise Exception("Invalid Request Parameter")
		except:
			return JsonResponse({'error':'Invalid Request Parameter'},status=400)
		return Scoring.predicttestdata(None,modelName,jsonData)
Beispiel #3
0
 def test_07_scoreCsvDataWithSKL(self):
     logging.info("Test Case : Score csv data with SKL model.")
     filePath = os.path.abspath('testUseCase/supportdata/irisSKL.pmml')
     result = Scoring.loadModelfile(filePath)
     modelName = 'irisSKL'
     filePath = os.path.abspath('testUseCase/supportdata/iris_test.csv')
     result = Scoring.predicttestdata(filePath, modelName)
     result = json.loads(result.__dict__['_container'][0])
     self.assertEqual('result' in result, True)
     self.assertEqual(result['result'].endswith('.csv'), True)
     logging.info("PASSED")
Beispiel #4
0
 def test_09_scoreJsonDataWithNN(self):
     logging.info("Test Case : Score json data with NN model.")
     filePath = os.path.abspath('testUseCase/supportdata/irisNN.pmml')
     result = Scoring.loadModelfile(filePath)
     modelName = 'irisNN'
     filePath = os.path.abspath('testUseCase/supportdata/iris_test.json')
     result = Scoring.predicttestdata(filePath, modelName)
     result = json.loads(result.__dict__['_container'][0])
     self.assertEqual('result' in result, True)
     self.assertEqual(result['result'].endswith('.txt'), True)
     logging.info("PASSED")
Beispiel #5
0
    def test_11_scoreSignleRecordWithSKL(self):
        logging.info("Test Case : Score single record with SKL model.")
        filePath = os.path.abspath('testUseCase/supportdata/irisSKL.pmml')
        result = Scoring.loadModelfile(filePath)

        modelName = 'irisSKL'
        data = json.loads(
            '{"sepal_length":4,"sepal_width":5,"petal_length":3,"petal_width":5}'
        )
        result = Scoring.predicttestdata(None, modelName, data)
        result = json.loads(result.__dict__['_container'][0])
        self.assertEqual('result' in result, True)
        self.assertEqual(result['result'].endswith('.txt'), True)
        logging.info("PASSED")