【发布时间】:2018-09-26 11:26:14
【问题描述】:
我想创建一个模型并将其部署到 SQL Server 中,以便将它与新的 PREDICT() 内置函数一起使用。 但是,我似乎坚持使用 R 中的 RxSqlServerData 方法。 每当我运行我的脚本时,我都会收到此错误:
rxExecJob 中的错误(rxCallInfo(matchCall, .rxDeprecated = "covariance"), : 数据必须是 RxSqlServerData 数据源 这个计算上下文。
到目前为止,这是我的代码:
#Logistic plain select sql query
#input_query = 'SELECT app.ClientAgeToApplicationDate AS Age, IIF(conc.FirstInstallmentDelay>60,1,0) AS FPD60 FROM dim.Application app JOIN dim.Contract con ON app.ApplicationID = con.ApplicationID JOIN dim.Contract_Calculated conc ON con.ContractID = conc.ContractId'
#LinReg aggregated query
input_query = '
*SQL QUERY, too long to paste...*
'
connStr <- paste("Driver=SQL Server; Server=", "czphaddwh01\\dev",
";Database=", "DWH_Staging", ";Trusted_Connection=true", sep = "");
#Set compute context to SQL Server. Does not load any data into a memory of the local client. OBDC can't.
cc <- RxInSqlServer(connectionString = connStr);
rxSetComputeContext(cc)
input_data <- RxSqlServerData(sqlQuery = input_query, connectionString = connStr)
risk <- rxImport(input_data)
#head(risk)
#Binary regression for non-aggregated sql query
#logit_model <- rxLogit(Age ~ FPD60, data = risk)
#LinReg for aggregated sql query
LinReg_model <- rxLinMod(RiskFPD60 ~ Age, data = risk)
我是 R 新手。任何帮助将不胜感激。
【问题讨论】:
标签: r sql-server microsoft-r