本文整理汇总了Python中scipy.subtract函数的典型用法代码示例。如果您正苦于以下问题:Python subtract函数的具体用法?Python subtract怎么用?Python subtract使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subtract函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: logloss
def logloss(self, y, pred):
epsilon = 1e-15
pred = sp.maximum(epsilon, pred)
pred = sp.minimum(1-epsilon, pred)
ll = sum(y*sp.log(pred) + sp.subtract(1,y)*sp.log(sp.subtract(1,pred)))
ll = ll * -1.0/len(y)
return ll
开发者ID:joshnewnham,项目名称:udacity_machine_learning_engineer_nanodegree_capstone,代码行数:7,代码来源:evaluator.py
示例2: llfun
def llfun(act, pred):
epsilon = 1e-15
pred = sp.maximum(epsilon, pred)
pred = sp.minimum(1 - epsilon, pred)
ll = sum(act * sp.log(pred) + sp.subtract(1, act) * sp.log(sp.subtract(1, pred)))
ll = ll * -1.0 / len(act)
return ll
示例3: logloss
def logloss(act, pred):
epsilon = 1e-4
pred = sp.maximum(epsilon, pred)
pred = sp.minimum(1-epsilon, pred)
ll = -1.0/len(act) * sum(act*sp.log(pred) +
sp.subtract(1,act)*sp.log(sp.subtract(1,pred)))
return ll
示例4: logloss
def logloss(Y_true, Y_pred):
epsilon = 1e-15
pred = sp.maximum(epsilon, Y_pred)
pred = sp.minimum(1-epsilon, Y_pred)
ll = sum(Y_true*sp.log(pred) + sp.subtract(1,Y_true)*sp.log(sp.subtract(1,Y_pred)))
ll = ll * -1.0/len(Y_true)
return ll
示例5: evaluate_ll
def evaluate_ll(y, yhat):
epsilon = 1e-15
yhat = sp.maximum(epsilon, yhat)
yhat = sp.minimum(1-epsilon, yhat)
ll = sum(y*sp.log(yhat) + sp.subtract(1,y)*sp.log(sp.subtract(1,yhat)))
ll = ll * -1.0/len(y)
return ll
示例6: entropyloss
def entropyloss(act, pred):
epsilon = 1e-15
pred = sp.maximum(epsilon, pred)
pred = sp.minimum(1-epsilon, pred)
el = sum(act*sp.log10(pred) + sp.subtract(1,act)*sp.log10(sp.subtract(1,pred)))
el = el * -1.0/len(act)
return el
示例7: binary_logloss
def binary_logloss(p, y):
epsilon = 1e-15
p = sp.maximum(epsilon, p)
p = sp.minimum(1-epsilon, p)
res = sum(y * sp.log(p) + sp.subtract(1, y) * sp.log(sp.subtract(1, p)))
res *= -1.0/len(y)
return res
示例8: logloss
def logloss(actual, predict):
epsilon = 1e-15
predict = sp.maximum(epsilon, predict)
predict = sp.minum(1 - epsilon, predict)
loss = sum(actual * sp.log(predict) + sp.subtract(1, actual) * sp.log(sp.subtract(1, predict)))
loss = loss * -1.0 / len(actual)
return loss
示例9: logloss
def logloss(p, y):
epsilon = 1e-15
p = sp.maximum(epsilon, p)
p = sp.minimum(1-epsilon, p)
ll = sum(y*sp.log(p) + sp.subtract(1,y)*sp.log(sp.subtract(1,p)))
ll = ll * -1.0/len(y)
return ll
示例10: llfun
def llfun(act, pred):
p_true = pred[:, 1]
epsilon = 1e-15
p_true = sp.maximum(epsilon, p_true)
p_true = sp.minimum(1 - epsilon, p_true)
ll = sum(act * sp.log(p_true) + sp.subtract(1, act) * sp.log(sp.subtract(1, p_true)))
ll = ll * -1.0 / len(act)
return ll
示例11: logloss
def logloss(self, act, pred):
epsilon = 1e-15
pred = sp.maximum(epsilon, pred)
pred = sp.minimum(1-epsilon, pred)
pred[pred >= 1] = 0.9999999
ll = sum(act*sp.log(pred) + sp.subtract(1,act)*sp.log(sp.subtract(1,pred)))
ll = ll * -1.0/len(act)
return ll
示例12: logloss
def logloss(act, pred):
epsilon = 1e-6
pred = sp.maximum(epsilon, pred)
pred = sp.minimum(1-epsilon, pred)
#print np.mean(pred)
ll = sum(act*sp.log(pred) + sp.subtract(1,act)*sp.log(sp.subtract(1,pred)))
ll = ll * -1.0/len(act)
return ll
示例13: log_loss
def log_loss(act, pred):
epsilon = 1e-15
pred = sp.maximum(epsilon, pred)
pred = sp.minimum(1 - epsilon, pred)
ll = sum(act * sp.log(pred.astype(float)) + sp.subtract(1, act.astype(float)) * sp.log(
sp.subtract(1, pred.astype(float))))
ll = ll * -1.0 / len(act)
return ll
示例14: logloss_1
def logloss_1(act, pred):
act = act.flatten()
pred = pred.flatten()
epsilon = 1e-15
pred = sp.maximum(epsilon, pred)
pred = sp.minimum(1-epsilon, pred)
ll = sum(act*sp.log(pred) + sp.subtract(1,act)*sp.log(sp.subtract(1,pred)))
ll = ll * -1.0/len(act)
return ll
示例15: logloss
def logloss(act,pred):
epsilon = 1e-15
pred = sp.maximum(epsilon,pred)
pred = sp.minimum(1-epsilon,pred)
#实际上我觉得这个式子就是机器学习课程中的cost Function
#sum(act*log(pred) + (1-a)*log(1-p))
ll = sum(act*sp.log(pred) + sp.subtract(1,act)*sp.log(sp.subtract(1,pred)))
ll = ll * -1.0/len(act)
return ll