我需要计算超过1000行的数组的列的平均值.
np.mean(some_array)给我
inf输出
但我很确定价值还可以.我从这里加载一个csv 到我的Data变量,从我的观点来看,'cement'列是"健康的".
In[254]:np.mean(Data[:230]['Cement'])
Out[254]:275.75
Run Code Online (Sandbox Code Playgroud)
但如果我增加问题的行数:
In [259]:np.mean(Data[:237]['Cement'])
Out[259]:inf
Run Code Online (Sandbox Code Playgroud)
但是当我看数据时
In [261]:Data[230:237]['Cement']
Out[261]:
array([[ 425. ],
[ 333. ],
[ 250.25],
[ 491. ],
[ 160. ],
[ 229.75],
[ 338. ]], dtype=float16)
Run Code Online (Sandbox Code Playgroud)
我没有找到这种行为的原因PS这种情况发生在Python 3.x中使用wakari(基于云的Ipython)
Numpy版本'1.8.1'
我正在加载数据:
No_Col=9
conv = lambda valstr: float(valstr.replace(',','.'))
c={}
for i in range(0,No_Col,1):
c[i] = conv
Data=np.genfromtxt(get_data,dtype=float16 , delimiter='\t', skip_header=0, names=True, converters=c)
Run Code Online (Sandbox Code Playgroud) 我尝试使用 scipy 深入研究取决于多个变量的函数优化
在使用批处理文件调用此工具后,我有一个从数据挖掘工具返回预测的函数。
def query(x):
import numpy as np
file_direc_in="path_to_input_file.csv"
file_direc_out="path_to_output_file.csv"
with open(file_direc_in, 'w') as f:
np.savetxt(f, x, delimiter=';', fmt='%.3f',newline='\r\n')
f.close()
os.system("Dataset_query.bat")
#batch file takes the array i wrote to from input_file and estimates a result
#afterwards the output will be taken from the output file:
f = open(file_direc_out,'r')
out = np.array([[float(f.readlines()[0])]])
f.close()
return out
from scipy.optimize import minimize
from calc import query
import numpy as np
x0=np.array([[1.5,50,30]])
bnds = ((1, 2), (0.1, 100), (20, 100))
res=minimize(query,x0,method='SLSQP',bounds=bnds, options={'maxiter': 10 …Run Code Online (Sandbox Code Playgroud) 我想在学习中使用“ pyomo”。我通过easy_install
coopr安装说明安装了pyomo ,Pyomo需要一个求解器才能工作,因此我想安装(GNU Linear Programming Kit)glpk_webpage,pyomo似乎安装正确,因为我可以在spyder中将其导入(我正在使用WinPython-64bit- 2.7.5.3)
import coopr.pyomo
但是,我想如果没有glpk我什么也做不了...
我从ftp服务器上下载了glpk-4.52(最新版本),但是我不知道该如何处理在“ w64”文件夹中找到的批处理文件,我应该根据“ 安装GLPK ” 使用(?)
我没有安装Visual Studio-如果没有它,是否可以工作?