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/

  • 相关阅读:
    SignalR Self Host+MVC等多端消息推送服务(3)
    SignalR Self Host+MVC等多端消息推送服务(2)
    [翻译 EF Core in Action 1.9] 掀开EF Core的引擎盖看看EF Core内部是如何工作的
    [翻译 EF Core in Action 1.8] MyFirstEfCoreApp应用程序设置
    [翻译 EF Core in Action 1.7] MyFirstEfCoreApp访问的数据库
    [翻译 EF Core in Action 1.6]你的第一个EF Core应用程序
    [翻译 EF Core in Action] 1.5 关于NoSql
    [翻译] EF Core 概述
    [翻译] 你将在本书中学到什么
    [翻译] 对正在使用EF6x开发人员的一些话
  • 原文地址:https://www.cnblogs.com/hdu-2010/p/7908723.html
Copyright © 2011-2022 走看看