sklearn.linear_model的继承在Python中没有像预期的那样工作

时间:2015-02-01 11:24:39

标签: python scikit-learn

我想使用精彩的Scikit-Learn软件包,但是当我尝试

class LogisticMe(linear_model.LogisticRegression):
  def __init__(self):

   super(LogisticMe,self).__init__(self)

我收到以下错误:      'LogisticMe'对象没有属性'upper'

我的新类不应该继承父级的所有属性吗?

完整筹码:

AttributeError Traceback (most recent call last)
<ipython-input-4-0ddd1566e0dd> in <module>()
----> 1 l = logistic_me.LogisticMe()

/home/michael/Python/Uplift/logistic_me.py in __init__(self)
  9   def __init__(self):
 10 
---> 11     super(LogisticMe,self).__init__(self)
 12 
 13   def fit(self,X,T,y):

/home/michael/anaconda/lib/python2.7/site-packages/sklearn/linear_model   /logistic.pyc in __init__(self, penalty, dual, tol, C, fit_intercept, intercept_scaling, class_weight, random_state)
102             penalty=penalty, dual=dual, loss='lr', tol=tol, C=C,
103             fit_intercept=fit_intercept, intercept_scaling=intercept_scaling,
--> 104             class_weight=class_weight, random_state=random_state)
105 
106     def predict_proba(self, X):

/home/michael/anaconda/lib/python2.7/site-packages/sklearn/svm/base.pyc in __init__(self, penalty, loss, dual, tol, C, multi_class, fit_intercept, intercept_scaling, class_weight, verbose, random_state)
608 
609         # Check that the arguments given are valid:
--> 610         self._get_solver_type()
611 
612     def _get_solver_type(self):

/home/michael/anaconda/lib/python2.7/site-packages/sklearn/svm/base.pyc in _get_solver_type(self)
626                                  "`crammer_singer`")
627             solver_type = "P%s_L%s_D%d" % (
--> 628                 self.penalty.upper(), self.loss.upper(), int(self.dual))
629         if not solver_type in self._solver_type_dict:
630             if self.penalty.upper() == 'L1' and self.loss.upper() == 'L1':

AttributeError: 'LogisticMe' object has no attribute 'upper' 

0 个答案:

没有答案
相关问题