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")
以上沒有報錯,即安裝成功。
其它說明請查看,xlearn-master/doc的文件說明。
參考鏈接
xlearn: https://github.com/aksnzhy/xlearn
cmake: https://cmake.org/download/