python,h2o.import_file()返回空lin

2024-09-28 05:23:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我在水里读文件有点问题

import h2o
from h2o.estimators.deeplearning import H2ODeepLearningEstimator
h2o.init()
train = h2o.import_file("("https://h2o-public-test-data.s3.amazonaws.com/smalldata/iris/iris_wheader.csv"")
splits = train.split_frame(ratios=[0.75], seed=1234)
dl = H2ODeepLearningEstimator(distribution="quantile",quantile_alpha=0.8)
dl.train(x=range(0,2), y="petal_len", training_frame=splits[0])
print(dl.predict(splits[1]))

更新_1,第四行有此表单(抱歉,我从IDE复制错误):

^{pr2}$

我得到了H2OTypeError:参数x应该是一个None | integer | list(string | integer)| set(integer | string),得到了范围范围(0,2)。在

这是因为“火车”是空的。在

In [23]: train

Out[23]: 

我认为在读取、链接和手动下载文件时存在问题。在

train = h2o.import_file("iris_wheader.csv")

但我得到了同样的结果。在

In [26]: train

Out[26]: 

我连接了pandas并在pandas中打开了这个.csv。它打开了,我得到了一个熊猫数据帧,我用的

 train = h2o.H2OFrame(train) 

有一列空火车。在

In [29]: train

Out[29]:

如何解决这个问题?在

当我转到127.0.0.1:54321/flow时更新_2/索引.html,它显示数据帧已加载到集群中。但在Python,我得到的是空火车。我使用Spyder IDE和IPython控制台,它会影响结果吗?在


Tags: 文件csvinimportiristrainintegerout
1条回答
网友
1楼 · 发布于 2024-09-28 05:23:24

这条线有问题:

train = h2o.import_file("("https://h2o-public-test-data.s3.amazonaws.com/smalldata/iris/iris_wheader.csv"")

你应该有额外的(,你应该有:

^{pr2}$

然后您将看到train和{}给出输出:

In [6]: train
Out[6]:   sepal_len    sepal_wid    petal_len    petal_wid  class
     -       -       -       -       -
        5.1          3.5          1.4          0.2  Iris-setosa
        4.9          3            1.4          0.2  Iris-setosa
        4.7          3.2          1.3          0.2  Iris-setosa
        4.6          3.1          1.5          0.2  Iris-setosa
        5            3.6          1.4          0.2  Iris-setosa
        5.4          3.9          1.7          0.4  Iris-setosa
        4.6          3.4          1.4          0.3  Iris-setosa
        5            3.4          1.5          0.2  Iris-setosa
        4.4          2.9          1.4          0.2  Iris-setosa
        4.9          3.1          1.5          0.1  Iris-setosa

[150 rows x 5 columns]


In [7]: train.nrow
Out[7]: 150

In [8]: print(train)
  sepal_len    sepal_wid    petal_len    petal_wid  class
     -       -       -       -       -
        5.1          3.5          1.4          0.2  Iris-setosa
        4.9          3            1.4          0.2  Iris-setosa
        4.7          3.2          1.3          0.2  Iris-setosa
        4.6          3.1          1.5          0.2  Iris-setosa
        5            3.6          1.4          0.2  Iris-setosa
        5.4          3.9          1.7          0.4  Iris-setosa
        4.6          3.4          1.4          0.3  Iris-setosa
        5            3.4          1.5          0.2  Iris-setosa
        4.4          2.9          1.4          0.2  Iris-setosa
        4.9          3.1          1.5          0.1  Iris-setosa

[150 rows x 5 columns]

相关问题 更多 >

    热门问题