如果你想在较大的一个中插入一个小图,你可以使用Axes,就像这里一样.
问题是我不知道如何在子图中做同样的事情.
我有几个子图,我想在每个子图中绘制一个小图.示例代码将是这样的:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
for i in range(4):
ax = fig.add_subplot(2,2,i)
ax.plot(np.arange(11),np.arange(11),'b')
#b = ax.axes([0.7,0.7,0.2,0.2])
#it gives an error, AxesSubplot is not callable
#b = plt.axes([0.7,0.7,0.2,0.2])
#plt.plot(np.arange(3),np.arange(3)+11,'g')
#it plots the small plot in the selected position of the whole figure, not inside the subplot
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
提前致谢!
我正在执行交叉验证以便正确分类.首先,我使用scikit-learn中的StratifiedKfold函数.在某些时候,我想进行更多迭代,然后我改为StratifiedShuffleSplit.通过这个新功能,我获得的结果发生了变化.最后,我意识到如果我指定一个random_state,我会再次获得与使用StratifiedKfold作为CV时获得的结果类似的结果.
总之,如果我指定random_state,对于不同的值,我会得到稍微不同的结果,类似于我使用StratifiedKfold获得的结果(通过一次迭代,或者计算我自己的混洗,如此处所示).但是,如果random_state为none或未指定,则我获得的结果完全改变.
我检查了当random_state为None时,列车和测试索引是不同的,并按预期分层.
我没有随机数生成器的经验,但这对我没有任何意义
查看代码,我意识到当random_state为None时,调用函数check_random_state.此函数,如果seed为none,则返回np.random(link)使用的RandomState单例.
我写了一些有问题的代码.如果我用下面的那个更改注释行,我会得到不同的结果.
import numpy as np
import sklearn as skl
(...)
#skCVs=skl.cross_validation.StratifiedShuffleSplit(classes,n_iter=iterations*kfoldCV,test_size = 1/float(kfoldCV),random_state=5)
skCVs=skl.cross_validation.StratifiedShuffleSplit(classes,n_iter=iterations*kfoldCV,test_size = 1/float(kfoldCV))
for train,test in skCVs:
(classification, ...)
Run Code Online (Sandbox Code Playgroud)
我正在使用sklearn的0.14版本.
你有任何解释或线索可以帮助理解正在发生的事情吗?
python random machine-learning scikit-learn cross-validation