使用程式代碼執行 AutoML 實驗
如果您想要在自動化機器學習作業 (ML Ops) 程式中執行 AutoML 實驗,您可以撰寫程式代碼來設定和起始 AutoML 實驗。
AutoML API 提供 Python 連結庫,可讓您用來執行 AutoML 實驗進行分類、回歸和預測。 若要設定 AutoML 實驗的特定詳細數據,您必須撰寫使用 classify
、regress
或 forecast
方法的程式代碼,以符合特定需求的參數。
例如,下列程式代碼會執行分類 AutoML 實驗。
from databricks import automl
# Get the training data
train_df = spark.sql("SELECT * FROM penguins")
# Configure and initiate the AutoML experiment
summary = automl.classify(train_df, target_col="Species",
primary_metric="precision", timeout_minutes=5)
# Get the best model
model_uri = summary.best_trial.model_path
提示
如需使用 AutoML API 的詳細資訊,請參閱 Azure Databricks 檔中的 使用 Azure Databricks AutoML Python API 定型 ML 模型。