I am trying to customize the power function for regression problems, and the following is the code:
def _pow(x1,x2):
with np.errstate(over='ignore', invalid='ignore'):
return np.where(abs(x1.all()) < 1.0 and abs(x2.all()) < 1.0, np.power(x1,x2), 1.)
I learned from issue #221 , the POWER function is very easy to overflow. As suggested, I tried to limit both X1 and X2. While the overflow problem still exists, and overflow can only be avoided when both X1 and X2 are less than 1.However, this closure make the prediction results unsatisfactory, my code is ineffective for the easier regression problems of POWER function:
I am trying to customize the power function for regression problems, and the following is the code:
def _pow(x1,x2):
with np.errstate(over='ignore', invalid='ignore'):
return np.where(abs(x1.all()) < 1.0 and abs(x2.all()) < 1.0, np.power(x1,x2), 1.)
I learned from issue #221 , the POWER function is very easy to overflow. As suggested, I tried to limit both X1 and X2. While the overflow problem still exists, and overflow can only be avoided when both X1 and X2 are less than 1.However, this closure make the prediction results unsatisfactory, my code is ineffective for the easier regression problems of POWER function:
np.random.seed(42)
X = np.random.rand(500, 1)
y = np.power(X[:, 0] , 0.6)
Could you please help me with this problem?