xlearn安装

xlearn简介

xLearn is a high performance, easy-to-use, and scalable machine learning package, which can be used to solve large-scale classification and regression problems.

If you are the user of liblinear, libfm, or libffm, now the xLearn is your another better choice. This project comes from the PKU-Cloud lab: homepage

xLearn does not rely on any third-party library, and hence users can just clone the code and compile it by using cmake. Also, xLearn supports very simple python API for users.Apart from this, xLearn supports many useful features that has been widely used in the machine learning competitions like cross-validation, early-stop, etc.

 

 

安装步骤

首先确保g++版本在g++4.8及以上,确保cmake的版本在3.0以上
不是的话,请先升级g++或者cmake
--------------------------------------------------------------------------------
下载cmake安装包:
cd cmake
./configure
make
sudo make instal

 

以下说明解压到~目录

tar -zxvf xlearn-master.zip;  //在解压后的文件中找到CMakeLists.txt, 添加如下的句话,比如加在26行。 

SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11 -pthread")
cd xlearn
-master; mkdir build; cd build cmake .. make -j4

测试

./xlearn_train ./small_train.txt -v ./small_test.txt -s 2 -x f1
./xlearn_predict ./small_test.txt ./small_train.txt.model

没有报错,则动态库安装成功。可以用命令行来运行程序。若想用python调用API,则需要执行以下安装步骤。

 

python 安装

修改.bash_profile文件
添加
export PYTHONPATH=~/xlearn-master/build/python-package/xlearn
source .bash_profile
cd ~/xlearn-master/build/python-package
sh install-python.sh 

在当前目录测试,

# coding: utf-8
# This file test the xlearn python package.
# We create a ffm model for binary classification problem.
# The dataset comes from the criteo CTR.
import xlearn as xl

# Create factorazation machine
ffm_model = xl.create_ffm()

# Set training data and validation data
ffm_model.setTrain("./small_train.txt")
ffm_model.setValidate("./small_test.txt")

# Set hyper-parameters
param = { 'task':'binary',
          'lr' : 0.2,
          'lambda' : 0.002,
          'metric' : 'auc' }

# Tarin model
ffm_model.fit(param, "model.out")

# Predict
ffm_model.setTest("./small_test.txt")
ffm_model.predict("model.out", "output")
testing

 

以上没有报错,即安装成功。

 

其它说明请查看,xlearn-master/doc的文件说明。

 

参考链接

xlearn: https://github.com/aksnzhy/xlearn

cmake:  https://cmake.org/download/

转载于:https://www.cnblogs.com/hdu-2010/p/7908723.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值