我想在教学时忽略所有包装中的警告,但是scikit-learn似乎可以解决使用warnings包来控制它的问题.例如:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
from sklearn import preprocessing
/usr/local/lib/python3.5/site-packages/sklearn/utils/fixes.py:66: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead
if 'order' in inspect.getargspec(np.copy)[0]:
/usr/local/lib/python3.5/site-packages/sklearn/utils/fixes.py:358: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead
if 'exist_ok' in inspect.getargspec(os.makedirs).args:
Run Code Online (Sandbox Code Playgroud)
我是否错误地使用了这个模块,或者是否正在做一些不应该做的事情?
在远程计算机上使用Matplotlib时(例如在Travis CI上),我遇到了与未设置的DISPLAY环境变量相关的频繁运行时错误.按照建议,我在测试脚本的开头设置了Agg后端matplotlib.use,并确保没有调用show().不过,我仍然会遇到以下错误:
Traceback (most recent call last):
File "/home/travis/anaconda/envs/testenv/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/travis/build/pymc-devs/pymc/pymc/tests/test_plots.py", line 36, in test_multichain_plots
forestplot(ptrace, vars=['early_mean', 'late_mean'])
File "/home/travis/build/pymc-devs/pymc/pymc/plots.py", line 325, in forestplot
interval_plot = subplot(gs[0])
File "/home/travis/anaconda/envs/testenv/lib/python2.7/site-packages/matplotlib/pyplot.py", line 896, in subplot
fig = gcf()
File "/home/travis/anaconda/envs/testenv/lib/python2.7/site-packages/matplotlib/pyplot.py", line 450, in gcf
return figure()
File "/home/travis/anaconda/envs/testenv/lib/python2.7/site-packages/matplotlib/pyplot.py", line 423, in figure
**kwargs)
File "/home/travis/anaconda/envs/testenv/lib/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py", line 31, in new_figure_manager
return new_figure_manager_given_figure(num, thisFig)
File "/home/travis/anaconda/envs/testenv/lib/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py", line 38, in new_figure_manager_given_figure
canvas = FigureCanvasQTAgg(figure) …Run Code Online (Sandbox Code Playgroud) 我有一些代码总结了一个包含着名的泰坦尼克号数据集的DataFrame,如下所示:
titanic['agecat'] = pd.cut(titanic.age, [0, 13, 20, 64, 100],
labels=['child', 'adolescent', 'adult', 'senior'])
titanic.groupby(['agecat', 'pclass','sex']
)['survived'].mean()
Run Code Online (Sandbox Code Playgroud)
这将根据groupby调用生成具有MultiIndex的以下DataFrame :
agecat pclass sex
adolescent 1 female 1.000000
male 0.200000
2 female 0.923077
male 0.117647
3 female 0.542857
male 0.125000
adult 1 female 0.965517
male 0.343284
2 female 0.868421
male 0.078125
3 female 0.441860
male 0.159184
child 1 female 0.000000
male 1.000000
2 female 1.000000
male 1.000000
3 female 0.483871
male 0.324324
senior 1 female 1.000000
male 0.142857
2 male 0.000000 …Run Code Online (Sandbox Code Playgroud) 在TM 1.x中,有一个首选项设置可以突出显示当前行.这个选项似乎在TM2中消失了.我假设tm_properties中有一些设置可以设置,但我无法弄清楚.我已经尝试将lineHighlight设置为颜色,但这不起作用.有没有人想到这个?
我想知道是否可以在同一个IPython笔记本中使用Bokeh生成静态HTML输出和内联图.我目前看到的是,一旦我打电话output_notebook()或output_file("myfile.html")我被困在使用输出模式.例如,如果我最初使用output_notebook,则随后调用output_file不会创建输出文件.
我喜欢Vim 7.3中的相对行编号功能,但是我很难让它普遍存在.对于许多文件,行编号恢复为绝对模式,即使我已指定:
set rnu
Run Code Online (Sandbox Code Playgroud)
在我的.vimrc档案中.知道是什么原因引起的吗?我在OSX 10.6上使用Vim 7.3,带有Janus扩展包.
我不知何故最终在[remote]部分中使用了以下的git配置:
fetch = +refs/heads/master:refs/remotes/origin/master
Run Code Online (Sandbox Code Playgroud)
这当然意味着我永远不会看到我的合作者添加的分支.我意识到我需要将其更改为:
fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
但我很困惑为什么我的配置首先以这种方式结束,更重要的是,我怎么能避免它再次发生.知道如何设置一个回购,以便它不会这样做吗?
谢谢,cf
我试图将一个LaTeX变量嵌入到一些reStructuredText中.我知道".. raw ::"指令,但我想将它嵌入到一段文本中.具体来说,我希望从模板考试文档中复制\numquestions \和\numpoints\variables.我尝试过使用:raw : \numquestions\,但这似乎没有效果.有没有办法做到这一点?
是否有Estimator在 TF2 中序列化和恢复模型的指南?文档非常参差不齐,其中大部分都没有更新到 TF2。我还没有在任何地方看到一个清晰而完整的例子,任何地方都Estimator被保存,从磁盘加载并用于从新输入进行预测。
TBH,我对这看起来有多复杂感到有些困惑。Estimators 被宣传为拟合标准模型的简单、相对高级的方法,但在生产中使用它们的过程似乎非常神秘。例如,当我通过tf.saved_model.load(export_path)获取一个AutoTrackable对象从磁盘加载模型时:
<tensorflow.python.training.tracking.tracking.AutoTrackable at 0x7fc42e779f60>
不清楚为什么我不Estimator回来。看起来曾经有一个听起来很有用的函数tf.contrib.predictor.from_saved_model,但自从contrib消失了,它似乎不再起作用了(除了它出现在 TFLite 中)。
任何指针都会非常有帮助。如你所见,我有点失落。
我有一个Pandas DataFrame,其中包含我想根据"population"列中的值删除的行:
data['population'].value_counts()
general population 21
developmental delay 20
sibling 2
general population + developmental delay 1
dtype: int64
Run Code Online (Sandbox Code Playgroud)
在这里,我想删除两行sibling作为值.所以,我相信以下应该做的诀窍:
data = data.drop(data.population=='sibling', axis=0)
Run Code Online (Sandbox Code Playgroud)
它会丢弃2行,正如您在结果值计数中看到的那样,但它们不是具有指定值的行.
data.population.value_counts()
developmental delay 20
general population 19
sibling 2
general population + developmental delay 1
dtype: int64
Run Code Online (Sandbox Code Playgroud)
知道这里发生了什么吗?
Theano中返回Vector中特定值的索引的过程是什么?在NumPy中,该值为numpy.where(my_array==x)。Theano Tensor.where是一个switch语句。
python ×6
pandas ×2
bokeh ×1
git ×1
latex ×1
matplotlib ×1
scikit-learn ×1
tensorflow ×1
textmate ×1
textmate2 ×1
theano ×1
vim ×1
warnings ×1