auto sklearn安装(mac版)

本文详细介绍如何在Mac环境下安装并使用auto-sklearn自动机器学习工具。从搭建Python3环境开始,逐步指导安装SWIG、XGBoost及pyrfr等依赖库,解决常见错误,并提供运行示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

需要python3的环境

安装swig3

ruby -e "$(curl --insecure -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install swig3

给指定的文件夹赋予写权限:sudo chmode 777 文件夹

brew link swig

 

安装xgboost:

cd ~ git clone --recursive https://github.com/dmlc/xgboost

brew install gcc --without-multilib

cd xgboost; cp make/minimum.mk ./config.mk; make -j4

cd python-package; sudo python setup.py install

安装auto-sklearn

pip install auto-sklearn

如果报错如下:

XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?

List of candidates:

/private/var/folders/xw/cvs2qk9d77vc8fgn7zyvp84sqjlg4_/T/pip-install-25jfq24s/xgboost/xgboost/libxgboost.dylib

/private/var/folders/xw/cvs2qk9d77vc8fgn7zyvp84sqjlg4_/T/pip-install-25jfq24s/xgboost/xgboost/../../lib/libxgboost.dylib

/private/var/folders/xw/cvs2qk9d77vc8fgn7zyvp84sqjlg4_/T/pip-install-25jfq24s/xgboost/xgboost/./lib/libxgboost.dylib

/Users/..../.conda/envs/untitled/xgboost/libxgboost.dylib

然后将xgboost下面的libxgboost.dylib 放入提示的默认目录下:

cp libxgboost.dylib /Users/...../.conda/envs/untitled/xgboost/

 

pip install auto-sklearn

如果报错:

手动安装pyrfr

安装pyrfr注意事项:

pyrfr == 0.6.1, 下载地址https://pypi.python.org/pypi/pyrfr/0.6.1

将上述的包下载下来后解压,解压后修改安装文件setup.py

extra_compile_args = ['-O2', '-std=c++11']

extra_compile_args = ['-O2', '-std=c++11', '-stdlib=libc++', '-mmacosx-version-min=10.7']

 

cd pyrfr-0.6.1/

python setup.py install

brew link pcre

最后再:

pip install auto-sklearn

import sklearn.model_selection
import sklearn.datasets
import sklearn.metrics

import autosklearn.classification


def main():
    X, y = sklearn.datasets.load_digits(return_X_y=True)
    X_train, X_test, y_train, y_test = \
        sklearn.model_selection.train_test_split(X, y, random_state=1)

    automl = autosklearn.classification.AutoSklearnClassifier(
        time_left_for_this_task=120,
        per_run_time_limit=30,
        tmp_folder='/tmp/autosklearn_holdout_example_tmp',
        output_folder='/tmp/autosklearn_holdout_example_out',
        disable_evaluator_output=False,
        # 'holdout' with 'train_size'=0.67 is the default argument setting
        # for AutoSklearnClassifier. It is explicitly specified in this example
        # for demonstrational purpose.
        resampling_strategy='holdout',
        resampling_strategy_arguments={'train_size': 0.67}
    )
    automl.fit(X_train, y_train, dataset_name='digits')

    # Print the final ensemble constructed by auto-sklearn.
    print(automl.show_models())
    predictions = automl.predict(X_test)
    # Print statistics about the auto-sklearn run such as number of
    # iterations, number of models failed with a time out.
    print(automl.sprint_statistics())
    print("Accuracy score", sklearn.metrics.accuracy_score(y_test, predictions))


if __name__ == '__main__':
    main()

 

Auto-sklearn是一个基于scikit-learn构建的自动机器学习工具。它提供了开箱即用的监督型自动机器学习,可以为新的数据集自动搜索学习算法,并优化其超参数。Auto-sklearn的目标是减轻机器学习使用者的负担,让他们能够更专注于实际的问题。因此,使用者不再需要手动选择和调整学习算法和超参数,而是通过调用auto-sklearn来完成这些任务。 Auto-sklearn是基于Python语言的机器学习工具,而且它是基于scikit-learn库构建的。scikit-learn是一个功能非常强大的机器学习库,它封装了常用的机器学习方法,包括回归、降维、分类、聚类等。因此,Auto-sklearn可以自动搜索和选择这些方法中的其中一个或多个来解决特定的学习问题。 Auto-sklearn的能力取决于所选择的学习算法和超参数的搜索空间。它可以自动搜索和选择最佳的学习算法和超参数组合,从而在给定的数据集上获得最佳的性能。但是,由于搜索空间的大小和计算资源的限制,auto-sklearn不能保证找到全局最优解。然而,它通常能够找到接近最佳的解决方案,尤其是对于中小规模的数据集和常见的学习问题。 总之,Auto-sklearn是一个强大的自动机器学习工具,它可以帮助机器学习使用者自动搜索学习算法并优化超参数,从而减轻使用者的负担,并提供更多时间专注于实际问题的解决。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值