AttributeError:“ LinearRegression”对象没有属性“ init” [Python 2.7,Windows 10]

时间:2018-08-23 15:24:23

标签: scikit-learn regression init attributeerror linear

我正在尝试运行一个代码,该代码最初是使用Lynux库pygsl编写的。为了在Windows上运行它,有人试图用pygsl的线性回归和三次样条命令代替scipy的命令:

from sklearn import linear_model

class BC_CSpline:
  def __init__( self, type, t, f ):
    self.type = type
    self.t = t
    self.f = f
    self.func = interpolate.interp1d( len( t ), kind='cubic' )
    self.func.init( t, f )    
  def eval( self, time ):
    return self.type, self.func.eval( time )

class BC_Linear:
  def __init__( self, type, t, f ):
    self.type = type
    self.t = t
    self.f = f
    self.func = linear_model.LinearRegression( len(t) )
    self.func.init( t, f )    
  def eval( self, time ):
    return self.type, self.func.eval( time )

当我尝试运行主代码时,它会显示下一条消息:

  

self.func.init(t,f)

     

AttributeError:“ LinearRegression”对象没有属性“ init”

任何人都可以解释我的问题是什么吗?预先谢谢你。

0 个答案:

没有答案