首页 > 解决方案 > 如何针对 openml.org 进行身份验证

问题描述

我正在尝试运行openml基准测试,它正确地要求提供 API 密钥。问题是我在 API 文档中找不到如何提供该密钥。

用户指南说:

import openml
from sklearn import impute, tree, pipeline

# Define a scikit-learn classifier or pipeline
clf = pipeline.Pipeline(
    steps=[
        ('imputer', impute.SimpleImputer()),
        ('estimator', tree.DecisionTreeClassifier())
    ]
)
# Download the OpenML task for the german credit card dataset with 10-fold
# cross-validation.
task = openml.tasks.get_task(31)
# Run the scikit-learn model on the task.
run = openml.runs.run_model_on_task(clf, task)
# Publish the experiment on OpenML (optional, requires an API key.
# You can get your own API key by signing up to OpenML.org)
run.publish()
print(f'View the run online: {openml.config.server}/run/{run.run_id}')

但它没有指定我应该如何提供该密钥。

标签: pythonauthenticationopenml

解决方案


这解释了如何配置 OpenML: https ://openml.github.io/openml-python/master/examples/20_basic/introduction_tutorial.html#sphx-glr-examples-20-basic-introduction-tutorial-py

确实最好将您的密钥存储在本地文件中。您还可以通过编程方式设置它以进行快速测试(但永远不要共享您的 API 密钥!):

openml.config.apikey = 'YOURKEY'

推荐阅读