如何在我在 Google 的 AutoML 表中创建的模型上运行批量预测,该模型适用于 gCloud Storage Bucket 中的 7000 (200GB+) csv?



我的问题似乎是CLI 看不到我在 AutoML 表产品下在此项目中创建的模型。非常感谢对此的任何帮助。

我正在尝试使用 CLI,因为我无法一次通过 Web 界面提交 7000+ CSV(Web 界面仅限于一个输入文件。我尝试将 CSV 导入 BigQuery 表,但导入在大约 3M 行后失败。 CSV 大约有 7.3B 行。

我很想将它们全部导入 BigQuery 并将 7.3B 的数字降低到我可以合理认为的非零结果,但我也无法将所有 CSV 都导入 BigQuery。

无论如何,对于 CLI:

我已经在这里阅读了gCloud的文档:https://cloud.google.com/ai-platform/prediction/docs/batch-predict 但这似乎指的是"AI平台",而不是AutoML Tables产品。 当我尝试使用此页面上列出的 CLI 说明时:

gcloud ai-platform jobs submit prediction myJob --model risk_vs_reward_v2 --input-paths "gs://portfolio_ml/test sets/v2 tests/*.csv" --output-path "gs://portfolio_ml/test set results/v2 results" --region us-central1 --data-format text

我得到:

Job [myJob] submitted successfully.
Your job is still active. You may view the status of your job with the command
$ gcloud ai-platform jobs describe myJob
or continue streaming the logs with the command
$ gcloud ai-platform jobs stream-logs myJob
ERROR: (gcloud.ai-platform.jobs.submit.prediction) Project [portfolio-ml] not found: Field: prediction_input.model_name Error: The model resource: "risk_vs_reward_v2" was not found. Please create the model resource first by using 'gcloud ai-platform models create risk_vs_reward_v2'.
- '@type': type.googleapis.com/google.rpc.BadRequest
fieldViolations:
- description: "The model resource: "risk_vs_reward_v2" was not found. Please
 create the model resource first by using 'gcloud ai-platform models create
 risk_vs_reward_v2'."
field: prediction_input.model_name

当我检查 gCloud 是否可以看到我现在在 AutoML 表中拥有的三个模型中的任何一个时:

gcloud ai-platform models list

它回来了 0 个模型?

WARNING: Using endpoint [https://ml.googleapis.com/]
Listed 0 items.

我已经验证我选择了正确的项目:

gcloud config set project portfolio-ml

我最终使用 AutoIT 在云存储桶中循环浏览我的 CSV,并在本地计算机上的云 CLI 命令中使用它们。我很幸运,我的输入 CSV 是有编号的,但万一其他人种子如此类似:

(注意:具有 1M 行的.csv每个 CSV 大约需要 20 秒才能从 Cloud Storage 导入到 BigQuery。

#include <MsgBoxConstants.au3>
; press ESC to stop the script in case something goes crazy and you can't click the AutoIT window
HotKeySet("^{ESC}", "Terminate") ; press ESC to stop script
Func Terminate()
Exit
EndFunc
local $fileStart = 1
local $fileEnd = 1000
local $loadCommand
local $i = $fileStart
local $startTime = TimerInit()
local $avgprocTime = 0
local $remainingTime = 0
while $i <= $fileEnd
; see 'bg load' documentation to customize this for your BigQuery table 
$loadCommand = 'cmd.exe /c bq load --autodetect --noreplace v2.test_criteria "gs://project_ml/test sets/v2 tests/test sets/testset-' & $i & '.csv'
RunWait($loadCommand,"",@SW_HIDE)
; This section is optional, but helpful. If you don't use it, monitor load progress on the BigQuery page or change the @SW_HIDE flag on the RunWait command above so you can see the cmd window and the bg loading status text it shows
$avgprocTime = TimerDiff($startTime)/($i-$fileStart+1)
$remainingTime = ($fileEnd-$i)*$avgProcTime
ConsoleWrite('Loaded file ' & $i & ' of ' & $fileEnd & '. ' & Round((TimerDiff($startTime)/1000)/60,1) & 'm elapsed, ' & Round($remainingTime/1000/60,1) & 'm remaining, ' & Round($avgProcTime/1000,1) & 's per file average.' & @LF)
;this is not optional ;)
$i = $i + 1
WEnd

相关内容

最新更新