Python inheritance change attribute type -


i trying build class inherits class sklearn

class my_lasso(linear_model.lasso):      def __init__(self, alpha=1.0, fit_intercept=true, normalize=false,                  precompute=false, copy_x=true, max_iter=1000, tol=1e-4,                  warm_start=false, positive=false, random_state=none,                  selection='cyclic'):         super(my_lasso, self).__init__(                 alpha=alpha, fit_intercept=fit_intercept,                 normalize=normalize, precompute=precompute, copy_x=copy_x,                 max_iter=max_iter, tol=tol, warm_start=warm_start,                 positive=positive, random_state=random_state,                 selection=selection)      def fit(self, x, y):         super(my_lasso, self).fit(x, y)         self.x = x         self.y = y         self.residus = self.y - self.predict(self.x)         self.r2 = self.score(self.x, self.y)         self.error = np.linalg.norm(self.residus) ** 2         self.support = np.zeros(x.shape[1])         self.support[self.coef_ != 0] = 1 

what don't understand when test class changes attribute intercept_ array

in [5]: testlasso.intercept_ out[5]: array([ 23.44591837]) 

same when trying inherit linearregression. coefs double arrays

in [7]: testls.coef_ out[7]:  array([[-0.56194996,  0.80247616, -0.0150445 , -5.76399971,  0.23495704,      2.77166415]]) 

any hints?

thanks lot!

first, if you're not overriding constructor don't need block.

your code fine. shape of intercept_ , coef_ determined number of targets 2.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -