# sigmoid函数
import numpy as np
import math
import matplotlib.pyplot as plt
x = np.arange(-10, 10, 0.1)
y = []
for t in x:
y_1 = 1 / (1 + math.exp(-t))
y.append(y_1)
plt.plot(x, y, label="sigmoid")
plt.xlabel("x")
plt.ylabel("y")
plt.ylim(0, 1)
plt.legend()
plt.show()
# 其他函数
import math
# sigmoid函数在x小于-700的时候会有异常 1/(1 + math.exp(-x))
def score_change(x):
if x < -1:
return 9.99-math.log(-x)
elif x >= -1 and x <= 1:
return 10+x/100
else:
return 10.01+math.log(x)
def score_change_1(x):
if x < -10000:
return 0.01 + 1/math.log(-x)
elif x > 10000:
return 0.99 + math.log(x)
else:
return 0.98/2000 * x +0.51
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(-20000, 20000, 0.1)
y = []
for t in x:
y.append(score_change(t))
plt.plot(x, y, label="other")
plt.xlabel("x")
plt.ylabel("y")
plt.xlim(-20000, 20000)
plt.ylim(-0, 30)
plt.legend()
plt.show()