草庐IT

num_round

全部标签

python - 参数 num_class 的 xgboost sklearn 包装器值 0 应大于等于 1

我正在尝试使用sklearn提供的XGBClassifier包装器解决多类问题。我的类是[0,1,2],我使用的目标是multi:softmax。当我尝试拟合分类器时,我得到了xgboost.core.XGBoostError:value0forParameternum_classshouldbegreaterequalto1如果我尝试设置num_class参数,我会得到错误gotanunexpectedkeywordargument'num_class'Sklearn会自动设置这个参数,所以我不应该传递那个参数。但为什么会出现第一个错误? 最佳答案

python - 为什么Python的round这么奇怪?

我的代码:#!/usr/bin/python#-*-coding:utf-8-*-print(round(1.555,1))#Itseemsnormalprint(round(1.555,2))#Whyitisnotoutput1.56?print(round(1.556,2))#Itseemsnormal输出:sam@sam:~/code/python$./t2.py1.61.551.56sam@sam:~/code/python$round(1.555,1)输出1.6。为什么round(1.555,2)不输出1.56? 最佳答案

python - 如何在Python中使用Round-towards-Infinity实现除法

我希望3/2等于2而不是1.5我知道该操作有一个数学术语(不称为舍入),但是我现在不记得它了。无论如何,我该怎么做而不必执行两个功能?我不想要的东西:answer=3/2thenmath.ceil(answer)=2(whydoesmath.ceil(3/2)=1?)我想要的东西前:"function"(3/2)=2 最佳答案 简短回答...Python仅为两种类型的除法提供native运算符:“真”除法和“舍入”除法。因此,您所需的功能无法作为一个单一功能使用。但是,可以使用一些短表达式轻松实现许多不同类型的舍入除法。根据标题的要

python - 为 tf.split() 使用 num_splits 变量

是否可以为tf.split()的num_split参数使用占位符输入?理想情况下,我想做这样的事情:num_splits=tf.placeholder(tf.int32)inputs=tf.placeholder(tf.int32,[5,None])split_inputs=tf.split(1,num_splits,inputs)TypeError:Expectedintforargument'num_split'not.我的方法可能有问题。我希望枚举可变形状张量中的一个维度。谢谢! 最佳答案 核心图操作有一个“张量输入-张量输出

Python 3 十进制四舍五入与 ROUND_HALF_UP 上下文

任何人都可以解释或提出修复,为什么当我在Python3中将小数舍入为四舍五入时,它会将2.5舍入为2,而在Python2中它会正确舍入为3:Python3.4.3和3.5.2:>>>importdecimal>>>context=decimal.getcontext()>>>context.rounding=decimal.ROUND_HALF_UP>>>round(decimal.Decimal('2.5'))2>>>decimal.Decimal('2.5').__round__()2>>>decimal.Decimal('2.5').quantize(decimal.Decima

python - Pandas 数据框 : ValueError: num must be 1 <= num <= 0, 不是 1

我在尝试绘制pandasdataframe时遇到以下错误:ValueError:nummustbe1代码:importmatplotlib.pyplotaspltnames=['buying','maint','doors','persons','lug_boot','safety']custom=pd.DataFrame(x_train)//onlyaportionofthecsvcustom.columns=namescustom.hist()plt.show()我尝试再次从csv读取文件,但我得到了完全相同的错误。编辑:printx_train输出:[[0.00.00.00.00

python - Num day to Name day 与 Pandas

如果我使用这个函数pd.DatetimeIndex(dfTrain['datetime']).weekday我得到了日期,但是我找不到任何给出日期名称的函数...所以我需要将0转换为星期一,将1转换为星期二,依此类推。这是我的数据框的示例:datetimeseasonholidayworkingdayweathertempatemphumiditywindspeedcount02011-01-0100:00:0010019.8414.395810.00001612011-01-0101:00:0010019.0213.635800.00004022011-01-0102:00:0010

python - 为什么 Ruby 的 Float#round 行为与 Python 不同?

"Behaviorof“round”functioninPython"观察到Python圆像这样float:>>>round(0.45,1)0.5>>>round(1.45,1)1.4>>>round(2.45,1)2.5>>>round(3.45,1)3.5>>>round(4.45,1)4.5>>>round(5.45,1)5.5>>>round(6.45,1)6.5>>>round(7.45,1)7.5>>>round(8.45,1)8.4>>>round(9.45,1)9.4接受的答案确认这是由float的二进制表示不准确引起的,这是合乎逻辑的。假设Ruby的float和Pyt

python - 将 mkl_set_num_threads 与 numpy 一起使用

我正尝试像这样使用mkl_set_num_threads设置numpy计算的线程数importnumpyimportctypesmkl_rt=ctypes.CDLL('libmkl_rt.so')mkl_rt.mkl_set_num_threads(4)但我一直遇到段错误:ProgramreceivedsignalSIGSEGV,Segmentationfault.0x00002aaab34d7561inmkl_set_num_threads__()from/../libmkl_intel_lp64.so获取线程数没问题:printmkl_rt.mkl_get_max_threads(

python - 如何在不使用 num2word 库的情况下将数字转换为单词?

我需要将1-99中的数字转换为单词。这是我到目前为止得到的:num2words1={1:'One',2:'Two',3:'Three',4:'Four',5:'Five',\6:'Six',7:'Seven',8:'Eight',9:'Nine',10:'Ten',\11:'Eleven',12:'Twelve',13:'Thirteen',14:'Fourteen',\15:'Fifteen',16:'Sixteen',17:'Seventeen',18:'Eighteen',19:'Nineteen'}num2words2=['Twenty','Thirty','Forty','F