zoukankan      html  css  js  c++  java
  • 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/

  • 相关阅读:
    sql分页存储过程疑惑:Row_Number与临时表哪个好?
    SQL之剪切
    在sqlserver2005中安装sql server 2000的示例数据库northwind
    安装SQL2005示例数据库
    Firefox浏览器中,Flex的FileReference上传文件,引发IOError
    Java获取方法的调用者
    ABAP screen常见语法
    XPO永久删除记录方法
    XPO的UpCasting
    在ASP.NET项目中使用XPO的最佳准则
  • 原文地址:https://www.cnblogs.com/hdu-2010/p/7908723.html
Copyright © 2011-2022 走看看