小编Pet*_*ers的帖子

xgboost ML模型的get_fscore()有什么作用?

有人如何计算数字?在文档中它说这个函数"获取每个特征的特征重要性",但没有解释如何解释结果.

python feature-selection xgboost

9
推荐指数
1
解决办法
7068
查看次数

Pandas TimeSeries重采样产生NaN

我正在重新取样Pandas TimeSeries.时间序列由二进制值(它是一个分类变量)组成,没有缺失值,但在重新采样之后会出现NaN.这怎么可能?

我不能在这里发布任何示例数据,因为它是敏感信息,但我创建并重新采样系列如下:

series = pd.Series(data, ts)
series_rs = series.resample('60T', how='mean')
Run Code Online (Sandbox Code Playgroud)

python time-series resampling pandas

8
推荐指数
2
解决办法
8627
查看次数

mac安装上的python xgboost

我正在尝试在我的Mac上为Python 3.4安装xgboost,但是在"pip3 setup.py install"之后我收到以下错误:

  File "<string>", line 20, in <module>

  File "/private/var/folders/_x/rkkz7tjj42g9n8lqq5r0ry000000gn/T/pip-build-2dc6bwf7/xgboost/setup.py", line 28, in <module>

    execfile(libpath_py, libpath, libpath)

NameError: name 'execfile' is not defined
Run Code Online (Sandbox Code Playgroud)

使用-v选项运行它以获取详细输出时,错误如下所示:

  Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_x/rkkz7tjj42g9n8lqq5r0ry000000gn/T/pip-build-2dc6bwf7/xgboost
Exception information:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/basecommand.py", line 232, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/commands/install.py", line 339, in run
    requirement_set.prepare_files(finder)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/req/req_set.py", line 385, in prepare_files
    req_to_install.run_egg_info()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/req/req_install.py", line 358, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/utils/__init__.py", line …
Run Code Online (Sandbox Code Playgroud)

python macos install xgboost

6
推荐指数
2
解决办法
3889
查看次数

调整一批图像的numpy

我在一个numpy数组(10000 x 480 x 752)中有接近10000个灰度图像,并想使用scipy.misc中的imresize函数调整它们的大小。它与围绕所有图像的for循环构建一起使用,但是需要15分钟。

images_resized = np.zeros([0, newHeight, newWidth], dtype=np.uint8)
for image in range(images.shape[0]):
    temp = imresize(images[image], [newHeight, newWidth], 'bilinear')
    images_resized = np.append(images_resized, np.expand_dims(temp, axis=0), axis=0)
Run Code Online (Sandbox Code Playgroud)

有什么方法可以像Apply这样的函数来更快地做到这一点吗?我研究了apply_along_axis

def resize_image(image):
    return imresize(image, [newHeight, newWidth], 'bilinear')
np.apply_along_axis(lambda x: resize_image(x), 0, images)
Run Code Online (Sandbox Code Playgroud)

但这给了

'arr' does not have a suitable array shape for any mode
Run Code Online (Sandbox Code Playgroud)

错误。

python numpy image-resizing

5
推荐指数
1
解决办法
8338
查看次数