sr_errorfuncs.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:SoRa 作者: LLNL 项目源码 文件源码
def __call__(self, individual):
        try:
            # Transform the tree expression in a callable function
            func = toolbox.compile(expr=individual)

            error = numpy.fabs((func(*self.inVarValues) - self.targetVarValues)) / self.targetVarValues
            maxerror = numpy.max(error)

            return (maxerror,)
        except NameError as ne:
            print ne
            print ne.message
        except Exception as e:
            return (sys.float_info.max,)

#R^2 is a common regression measurement to find how much variance is explained by the approximation.
#It works well early on in the calcuation, but loses percision has the approximation becomes close.
#
# The data is a list of lists, the labels give the names of interesting data.
# The config file defines which data lists are of use.
# All data lists are expected to be of equla length.  Repeated values are perfectly OK.
# The config file defines a set of "inVars" which are the input variables.  (e.g. rho, T)
# it also defines a single "targetVar" which is the array of function values.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号