草庐IT

define-ing

全部标签

python - sklearn : User defined cross validation for time series data

我正在尝试解决机器学习问题。我有一个包含时间序列元素的特定数据集。对于这个问题,我使用了著名的python库-sklearn。这个库中有很多交叉验证迭代器。还有几个迭代器用于自己定义交叉验证。问题是我真的不知道如何为时间序列定义简单的交叉验证。这是我想要获得的一个很好的例子:假设我们有几个时期(年),我们想将我们的数据集分成几个block,如下所示:data=[1,2,3,4,5,6,7]train:[1]test:[2](ortest:[2,3,4,5,6,7])train:[1,2]test:[3](ortest:[3,4,5,6,7])train:[1,2,3]test:[4](

python - 操作系统 : Defining a new URL handler that points straight at a Python script

我正在尝试在OSX下定义一个新的URL处理程序,它将指向一个python脚本。我已将Python脚本打包成一个小程序(右键单击.py,然后打开方式->构建小程序)我已将以下内容添加到小程序的Info.plist中:CFBundleURLTypesCFBundleURLNameDoMyThingCFBundleURLSchemesdmt我还使用了MoreInternetpreferencespane将“dmt”指定为协议(protocol),但是当我尝试让它将该协议(protocol)链接到我的小程序时,它说“将应用程序设置为助手时出现问题”有人知道我应该从这里去哪里吗?谢谢

python - 输入(): "NameError: name ' n' is not defined"

这个问题在这里已经有了答案:input()error-NameError:name'...'isnotdefined(15个答案)关闭6年前。好的,所以我正在用python编写成绩检查代码,我的代码是:unit3Done=str(input("HaveyoudoneyourUnit3ControlledAssessment?(Typeyorn):")).lower()ifunit3Done=="y":passelifunit3Done=="n":print"Sorry.YoumusthavedoneatleastoneunittocalculatewhatyouneedforanA*"

python - Cython 编译错误 : dynamic module does not define module export function

我正在用Cython构建一个包。我使用以下作为setup.py的结构:fromdistutils.coreimportsetupfromdistutils.extensionimportExtensionfromCython.Buildimportcythonizeimportnumpyimportscipyextensions=[Extension("xxxxx",["xxxx/xxxxx.pyx"],include_dirs=[numpy.get_include(),"."]),Extension("nnls",["xxxxx/xxxxx.pyx"],include_dirs=[n

Python 错误 : name 'admin' is not defined

我是第一次在Django中创建Python应用程序。我知道我必须取消注释urls.py中的管理工具,我已经做到了。我还添加了autodiscover。每次我尝试向管理面板添加新功能时,我都会收到此错误:“名称错误:未定义名称‘admin’”这是我在我的模型中用来添加到管理面板的代码:classChoiceInline(admin.StackedInline):model=Choiceextra=3classPollAdmin(admin.ModelAdmin):fieldsets=[(None,{'fields':['question']}),('Dateinformation',{'

python - "NameError: name ' ' is not defined"用户在 Python 中输入后

这个问题在这里已经有了答案:input()error-NameError:name'...'isnotdefined(15个答案)关闭7年前。我完全不知道为什么这不起作用。应该可以精确工作,对吧?UserName=input("Pleaseenteryourname:")print("HelloMr."+UserName)raw_input("")我得到这个异常:Traceback(mostrecentcalllast):File"Test1.py",line1,inUserName=input("Pleaseenteryourname:")File"",line1,inNameErr

python - 名称错误 : name 're' is not defined

这个问题在这里已经有了答案:NameError:name'datetime'isnotdefined(2个答案)关闭4年前。我是python的新手。很新。我从教程中复制了以下内容#!/usr/bin/pythonfromurllibimporturlopenfromBeautifulSoupimportBeautifulSoupwebpage=urlopen('http://feeds.huffingtonpost.com/huffingtonpost/LatestNews').readpatFinderTitle=re.compile('(.*)')patFinderLink=re.

python - 名称错误 : name 'exit' is not defined

我使用cxfreeze从planrequest.py创建了一个Windows可执行文件。它似乎工作正常,但是当我运行exe文件时,我得到NameError:name'exit'isnotdefinednameexitisnotdefinedinpython说明修复方法是使用importsys。但是,我使用importsys.该代码作为python脚本运行良好(例如,我在编译为可执行文件之前广泛测试了命令行参数。)importsocketimportsysiflen(sys.argv)==1:print("Usage:")print("PlanRequest[RequestString]

python - 名称错误 : global name 'HTTPError' is not defined

我在try子句中有一个命令,我知道它会引发异常。我试图在“except”子句中捕获它,但except子句似乎不承认异常的存在。未处理的异常(即未包含在try子句中)在交互窗口中看起来像这样:Traceback(mostrecentcalllast):File"",line1,inFile"C:\Users\Andy\software\Turkeys\actions.py",line234,inannotateannotation=annotator.ncbo_annotate(thing)File"C:\Users\Andy\software\Turkeys\annotator.py"

python 名称错误: name '__file__' is not defined

这个问题在这里已经有了答案:howcanigettheexecutable'scurrentdirectoryinpy2exe?(4个答案)关闭8年前。我试着用py2exe编译这个脚本:importosfile1=os.path.dirname(os.path.realpath('__file__'))file2=os.path.realpath(__file__)设置脚本:fromdistutils.coreimportsetupimportpy2exeimportsys,osiflen(sys.argv)==1:sys.argv.append("py2exe")setup(opti