1 Star 0 Fork 0

Askyourselfpls/DOTA2Flask

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
logic_more.py 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
Askyourselfpls 提交于 2021-05-03 14:55 . Initial commit
#-*- coding = utf-8 -*-
#@Time : 2021/4/28 9:51
#@Author : Zyh
#@File : logic_zr.py
#@Software : PyCharm
import numpy as np
class logic_more:
def loaddata(self,fn):
x= []
y=[]
with open(fn,'r') as f:
file = f.readlines()
# print(file)
for line in file:
line = line.strip().split()
# print(line[0])
x.append([float(line[0]),float(line[1]),float(line[2]),float(line[3]),float(line[4]),
float(line[5])])
y.append(float(line[-1]))
npx = np.array(x)
maxv = npx.max(0)
minv = npx.min(0)
ranges = maxv - minv
m = npx.shape[0]
x = [1]
xxx = np.tile(x, (m, 1))
normData = npx - np.tile(minv, (m, 1))
normData = normData / np.tile(ranges, (m, 1))
normData = np.column_stack((xxx, normData))
xmat = np.mat(normData)
# print(type(xmat))
ymat = np.mat(y).T
# print(xmat)
# print(ymat)
return xmat,ymat
def w_calc(self,xmat,ymat,alpha=0.001,maxg = 500):
# w._int
w = np.mat(np.random.randn(7,1))
# w updata Tzhuanzhi
for i in range(maxg):
H = 1 /(1 + np.exp(-xmat*w))
dw = xmat.T*(H-ymat)
w -= alpha*dw
return w
def w_cl(self,xmat,ymat,w):
m = xmat.shape[0]
y_yc = xmat*w
y_yc = np.sum(y_yc,axis=1)
y = y_yc.tolist()
xm = 0
ym = 0
for item in y:
if item[0] > 0.5:
xm += 1
else:
ym += 1
sum_y = np.sum(ymat)
return xm/sum_y
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/NextyearNextLife/DOTA2Flask.git
git@gitee.com:NextyearNextLife/DOTA2Flask.git
NextyearNextLife
DOTA2Flask
DOTA2Flask
master

搜索帮助