def get_point_error(self, x, t): """Return network error for ONE datapoint""" # Update error, see 4.2 in miniproject description assert len(x) == self.d, "Invalid size of data point (x)" a = self.compute_layers_output(x) # Compute log(1 + e^(-t*a)) as (-t*a + log(1 + e^(t*a))) temp = -t*a assert type(temp) == s.float64 return temp + s.log1p(s.exp(-temp))
def total_error(self, result, expected, k): error = 0 tmp = - result * expected if k==2 : #Negative error error += sp.sum(sp.log1p(sp.exp(tmp[tmp<0]))) #Positive error error += sp.sum(tmp[tmp>=0]+sp.log(1+sp.exp(tmp[tmp>=0]))) misclassified = sp.sum(sp.absolute(sp.sign(result)-expected))/2 else : error += 0.5*sp.sum(LA.norm(result-expected)**2) misclassified = sp.sum(sp.argmax(result,axis=0)!=sp.argmax(expected, axis=0)) misclassified /= result.shape[1]*1.0 return error, misclassified
data['price'].describe() # In[540]: plt.figure(figsize=(8, 7)) sns.distplot(data.price) # In[541]: data.price.skew() # 왜도 #data.price.kurt() # 첨도 # In[542]: data['log_price'] = sp.log1p(data['price']) # In[543]: sns.distplot(data.log_price) # In[544]: plt.hist(data.log_price) #빈도수 # In[545]: a = (data.corr()[data.corr() > 0.5].sum() > 1) # In[546]: