大数据,机器学习,人工智能大数据 爬虫Python AI Sql呆鸟的Python数据分析

macOS安装lightgbm排坑

2019-07-04  本文已影响0人  路人乙yh

第一步:安装brew(如果电脑已经有brew可略过)
在终端输入:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

第二步:用brew 安装cmake

brew install cmake
brew install gcc --without-multilib 

第三步:配置

export CXX=g++-7 CC=gcc-7  
cmake ..  
make -j4

在这一步出错Could not find compiler set in environment variable CC: gcc-7,查网上的解决办法都是改为export CXX=g++-8 CC=gcc-8,试了还是不行,思考可能是gcc版本没对上,想重装gcc,brew install gcc,弹出Warning: gcc 9.1.0 is already installed and up-to-date,于是改为export CXX=g++-9 CC=gcc-9,成功。

第四步:安装
切换到LightGBM/python-package, 输入python setup.py install

第五步:测试

import lightgbm as lgb

print(lgb.__version__)

data = np.random.rand(500, 10)  # 500 entities, each contains 10 features
label = np.random.randint(2, size=500)  # binary target

train_data = lgb.Dataset(data, label=label)
param = {'num_leaves': 31, 'objective': 'binary'}
param['metric'] = 'auc'
num_round = 10
bst = lgb.train(param, train_data, num_round)

# 预测
data = np.random.rand(7, 10)
ypred = bst.predict(data)
print(y_pred)
上一篇下一篇

猜你喜欢

热点阅读