auto sklearn安装(mac版)

需要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()

 

你可能感兴趣的:(算法)