我正在尝试在 JupyterLab 上的 ipynb 笔记本上使用 patsy 包创建 B 样条线:from patsy import dmatrixbs = dmatrix("bs(x, df=50, degree=1) - 1", {"x": x})axes[0].plot(x, bs)axes[0].set_title("Basis functions")plt.show()我第一次运行它时效果很好。但是当我尝试再次重新运行此单元时,它失败并出现以下错误:-----------------------------------------------------TypeError                                 Traceback (most recent call last)/opt/conda/lib/python3.8/site-packages/patsy/compat.py in call_and_wrap_exc(msg, origin, f, *args, **kwargs)     35     try:---> 36         return f(*args, **kwargs)     37     except Exception as e:/opt/conda/lib/python3.8/site-packages/patsy/eval.py in eval(self, expr, source_name, inner_namespace)    16         code = compile(expr, source_name, "eval", self.flags, False)--> 165         return eval(code, {}, VarLookupDict([inner_namespace]    166                                             + self._namespaces))<string> in <module>TypeError: 'DesignMatrix' object is not callableThe above exception was the direct cause of the following exception:PatsyError                                Traceback (most recent call last)<ipython-input-6-6ed4ba95a384> in <module>      2       3 _, axes = plt.subplots(2, figsize=(16, 16))----> 4 bs = dmatrix("bs(x, df=50, degree=1) - 1", {"x": x})      5 axes[0].plot(x, bs)      6 axes[0].set_title("Basis functions")/opt/conda/lib/python3.8/site-packages/patsy/highlevel.py in dmatrix(formula_like, data, eval_env, NA_action, return_type)    288     """    289     eval_env = EvalEnvironment.capture(eval_env, reference=1)--> 290     (lhs, rhs) = _do_highlevel_design(formula_like, data, eval_env,    291                                       NA_action, return_type)    292     if lhs.shape[1] != 0:
                    
                    
                添加回答
举报
0/150
	提交
		取消
	
