我这样做linear regression有StatsModels:
import numpy as np
import statsmodels.api as sm
from statsmodels.sandbox.regression.predstd import wls_prediction_std
n = 100
x = np.linspace(0, 10, n)
e = np.random.normal(size=n)
y = 1 + 0.5*x + 2*e
X = sm.add_constant(x)
re = sm.OLS(y, X).fit()
print(re.summary())
prstd, iv_l, iv_u = wls_prediction_std(re)
Run Code Online (Sandbox Code Playgroud)
我的问题是,iv_l和iv_u为上,下置信区间或预测区间?
我如何得到别人?
我需要所有点的置信度和预测间隔,做一个情节.
我正在研究cuda 5.5,但我没有任何Nvidia GPU.在旧版本的nvcc中有一个标志--multicore来编译CPU的cuda代码.在新版本的nvcc中,有什么选择?我正在研究Linux.
试图卸载一个用pip安装的软件包,我卸载一些,现在pip不起作用.我尝试安装pandas:
[sudo] pip install pandas
Run Code Online (Sandbox Code Playgroud)
这是错误:
Requirement already satisfied (use --upgrade to upgrade): pandas in /usr/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/local/lib/python2.7/dist-packages (from pandas)
Downloading/unpacking pytz (from pandas)
Downloading pytz-2013b.zip (535kB): 535kB downloaded
Running setup.py egg_info for package pytz
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'egg_info'
Complete output from command python …Run Code Online (Sandbox Code Playgroud) 我安装pip:
$ sudo apt-get install python-setuptools, python-pip
Run Code Online (Sandbox Code Playgroud)
但是当我尝试用pip安装东西时我有这个错误
sudo pip install Flask
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.3.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2565, in load_entry_point
raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'pip') not found
Run Code Online (Sandbox Code Playgroud)
为什么??谢谢.
我是 python 新手,遇到了这个问题。我已经安装了 Pandas、Numpy、Scipy,并且我使用 apt-get install python-statsmodels 安装了统计模型,但是当我尝试使用时:
import statsmodels.api as sm
Run Code Online (Sandbox Code Playgroud)
但我有这个问题:
ImportError Traceback (most recent call last)
<ipython-input-1-6030a6549dc0> in <module>()
----> 1 import statsmodels.api as sm
ImportError: No module named statsmodels.api
Run Code Online (Sandbox Code Playgroud)
为什么??
我有一个名为 main_parallel.py的python脚本mpi4py。我可以使用time表单来测量时间,cli但是,如何制作类似于 cProfile 的配置文件?我喜欢看到代码每个部分的调用次数。我不能使用 cProfile 因为它仅用于串行代码。
谢谢!
我是Python对象的新手,并且有很多问题.我需要将一个函数传递给我的对象,然后评估该函数.代码类似于:
from sympy import var
class eval:
def __init__(self, M):
self.M = M
def fun(self, x):
M = self.M
print M(x)
x = var('x')
ak = eval(x+2)
ak.fun(x)
Run Code Online (Sandbox Code Playgroud)
这是错误:
TypeError
Traceback (most recent call last)
(ipython-input-1-b7ef311bd1f0> in <module)()
12
13 ak = eval(x+2)
---> 14 ak.fun(x)
(ipython-input-1-b7ef311bd1f0) in fun(self, x)
7 def fun(self, x):
8 M = self.M
----> 9 print M(x)
10
11 x = var('x')
TypeError: 'Add' object is not callable
Run Code Online (Sandbox Code Playgroud) 我正在制作一个应用程序,我需要上传文件并使用它.我可以成功上传,但是当我重定向时,我无法传递文件(就像参数一样).该文件是全局对象.
@app.route('/analysis', methods = ['GET', 'POST'])
def analysis():
if request.method == 'POST':
file = getattr(g, 'file', None)
file = g.file = request.files['file']
return redirect(url_for('experiment'))
else:
return render_template('upload.html')
@app.route('/experiment', methods = ['GET', 'POST'])
def experiment():
file = g.get('file', None)
filename = secure_filename(file.filename)
if request.method == 'POST':
#do something with the file
return render_template('experiment.html', data = data)
else:
return render_template('experiment.html')
Run Code Online (Sandbox Code Playgroud)
这给出了这个错误:
AttributeError: '_RequestGlobals' object has no attribute 'get'
Run Code Online (Sandbox Code Playgroud)
我做错了?谢谢!