# 1.导入数据# 模型 y = wx + b
points = genfromtxt('linear_regress_lsm_data.csv', delimiter=',')
N =len(points)print('point count %d'%N)
x = array(points[:,0])
y = array(points[:,1])
plt.scatter(x, y)
plt.show
point count 100
<function matplotlib.pyplot.show(close=None, block=None)>
2.损失函数
# 2.损失函数defcompute_cost(points, w, b):
total_cost =0
length =len(points)for i inrange(length):
x = points[i,0]
y = points[i,1]
total_cost =(y - w * x - b)**2return total_cost /float(length)
3.训练
# 3.训练defaverage(nums):sum=0
length =len(nums)for i inrange(length):sum+= nums[i]returnsum/float(length)deffit(points):
length =len(points)
x_bar = average(array(points[:,0]))
sum_y_x =0
sum_x_power =0
sum_b =0# 求 wfor i inrange(length):
x = points[i,0]
y = points[i,1]
sum_y_x += y *(x - x_bar)
sum_x_power += x **2
w = sum_y_x /(sum_x_power - x_bar **2*float(length))# 求 bfor i inrange(length):
x = points[i,0]
y = points[i,1]
sum_b += y - w * x
b = sum_b /float(length)return w, b
4.测试
# 4.测试
w, b = fit(points)print("w is : ", w)print("b is : ", b)
cost = compute_cost(points, w, b)print("cost is :", cost)
w is : 1.3224310227553846
b is : 7.991020982269173
cost is : 1.4963859648775966
5.画拟合曲线
# 5. 画拟合曲线
plt.scatter(x, y)
y_predict = w * x + b
plt.plot(x, y_predict, c ='y')
plt.show
一、基本准备工作 1、安装依赖包 go get -u github.com/swaggo/swag/cmd/swag
go get -u github.com/swaggo/gin-swagger
go get -u github.com/swaggo/files2、在根目录上配置swagger的路由文件 //2.初始化路由router : initialize.Routers()// 配置swaggerdocs.SwaggerInfo…
一.SQL注入漏洞
1.输入id1 -- 下方出现数据说明闭合成功 2.测试得出数据库有三列 3.三处都是回显点 4.联合查询爆出库名 5.查表名 ?id-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schematest-- 6.查字段名 ?id-1 union sele…