请说明“无效的BXL流”

时间:2019-04-03 20:47:42

标签: sql-server python-3.x stored-procedures

我正在尝试开发一个进行机器语言预测的存储过程。 到目前为止,这是我所做的:

channel

此代码在以下行崩溃:

M

显示消息:无效的BXL流

如果我将预测行注释掉,则会得到:

DROP PROCEDURE IF EXISTS get_prediction_xgb_classify;
GO

CREATE PROCEDURE get_prediction_xgb_classify (@my_text varchar(100))
AS  
BEGIN
DECLARE @my_script nvarchar(4000)
SET @my_script = '

import numpy as np
from sklearn.externals import joblib

predictors = "" + "' + @my_text + '"
fields = predictors.strip().split(",")
n_fields = len(fields)

clf = joblib.load("C:/sm/trained_models/xgb_classify.pkl")
print("clf:\n", clf)
row = np.array(predictors.split(","),dtype=float).reshape(1,5)
print(" row: ", row)

predicted = clf.predict(row)[0]
#print(" predicted: ", predicted)

#probabilities = clf.predict_proba(row)[0]
#probability = probabilities[predicted]
#print("predicted: ", predicted, ", probabilities: ", probabilities, ", probability: ", probability)

'
EXEC sp_execute_external_script @language = N'Python',   
@script = @my_script
END
GO

EXEC get_prediction_xgb_classify "0.215, -0.499, 1.654, 4.25, 1.559"
GO

我还将这段代码放在Visual Studio 2017中,并取消了所有打印语句的注释。好了并取得了良好的结果。

任何建议将不胜感激。

查尔斯

0 个答案:

没有答案