将公式(方程式)存储在数据库中以供以后评估(SQL Server 2005) [英] Storing formula (equations) in database to be evaluated later (SQL Server 2005)
问题描述
我正在基于数据集计算线性回归.我不知道编译时的回归模型或参数数量.
I'm calculating linear regressions based on a data set. I do not know the regression model or number of parameters at compile-time.
我将回归方程式作为字符串存储在SQL Server 2005数据库中
I'm storing the regression equation in a SQL Server 2005 database as the string
y = 3x^2 + 2x // just an example
当我需要进行预测时,我从数据库中获取方程式,将x
替换为我预测的值,然后使用 NCalc 评估结果字符串.
When I need to make a prediction, I grab the equation from the database, substitue x
with the value I'm predicting, and use NCalc to evaluate the resulting string.
该方法似乎可以正常工作,但是我想知道是否有一种我错过的更好的方法或SQL Server的内置功能可以让我在数据库端进行这些计算/strong>.
That method seems to work OK, but I'm wondering if there's a better way or a built-in feature of SQL Server that I've missed that would allow me to do these calculations on the database side.
推荐答案
您可以编写仍然使用NCalc进行计算的CLR存储过程.
You could write a CLR stored procedure that still uses NCalc to do the calculation.
这篇关于将公式(方程式)存储在数据库中以供以后评估(SQL Server 2005)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!