H2O框架为空

2024-04-29 15:00:42 发布

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

我正在尝试运行一些从下面的链接中找到的示例代码。你知道吗

http://docs.h2o.ai/h2o/latest-stable/h2o-docs/automl.html#automl-interface

我修改了一下代码。我的实际代码如下。你知道吗

import h2o
from h2o.automl import H2OAutoML
import pandas as pd
from sklearn.model_selection import train_test_split

h2o.init()

df = pd.read_csv('C:\\my_path\\taxi.csv', header=0, encoding = 'unicode_escape')
pd.set_option('display.max_columns', None)
df.head(10)

df = df[:100000]

y = df.fare_amount

# create training and testing vars
X_train, X_test, y_train, y_test = train_test_split(df, y, test_size=0.2)

# Identify predictors and response
y = df['fare_amount']
del df['fare_amount']
x = df

# Run AutoML for 20 base models (limited to 1 hour max runtime by default)
train = h2o.H2OFrame(df)

aml = H2OAutoML(max_models=20, seed=1)
aml.train(x=x, y=y, training_frame=train)

# View the AutoML Leaderboard
lb = aml.leaderboard
lb.head(rows=lb.nrows)

我将“fare\u amount”设置为目标变量。当我运行代码时,我得到的只是一条消息:“这个框架是空的。”我可能缺少一些非常基本的东西,但我看不到它是什么。有什么想法吗?你知道吗


Tags: 代码fromtestimportdocsdftrainamount