xlearn

xLearn是一款高性能、易用且可扩展的机器学习库,特别适合大规模稀疏数据的机器学习任务,如广告点击率预测和推荐系统。本文介绍了xLearn的安装方法,包括在Ubuntu和Windows上的安装流程,以及如何从源码安装。同时,提供了使用xLearn进行FM模型训练和预测的示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

大家都知道sklearn这玩意,听说过xlearn 吗?

xLearn 是一款高性能的,易用的,并且可扩展的机器学习算法库,你可以用它来解决大规模机器学习问题,尤其是大规模稀疏数据机器学习问题。

官方文档
https://xlearn-doc-cn.readthedocs.io/en/latest/python_api/

在近年来,大规模稀疏数据机器学习算法被广泛应用在各种领域,例如广告点击率预测、推荐系统等。现在 xLearn 将会是你更好的选择,因为 xLearn 几乎囊括了这些系统的全部功能。

安装

https://xlearn-doc-cn.readthedocs.io/en/latest/install/install_windows.html

window 要安装Visual Studio 2017和cmake编译,我赶紧选用ubuntu安装

https://xlearn-doc-cn.readthedocs.io/en/latest/install/index.html

建议通过源码安装

从源码安装 xLearn 分为两个步骤:

首先,我们需要编译 xLearn 得到 xlearn_train 和 xlearn_predict 这两个可执行文件。

从 Github 上 clone 下 xLearn 源代码:

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

cd xlearn
mkdir build
cd build
cmake ../
make
./run_example.sh

之后,你就可以通过 install-python.sh 脚本来安装 xLearn Python 包:

cd python-package
sudo ./install-python.sh

用户可以通过如下命令检测 xLearn Python 库是否安装成功:

cd ../
python run_demo_ctr.py

用户只需要从 Github 上 clone 下 xLearn 源代码:

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

然后通过以下命令进行编译和安装:

cd xlearn
sudo ./build.sh

pip安装

在 Debian/Ubuntu Linux 上, 输入如下命令:

sudo apt-get install gcc binutils

安装 GCC (或者 Clang)

sudo apt-get install clang

在 Debian/Ubuntu Linux 上, 输入以下命令安装 cmake:

sudo apt-get install cmake

在pip安装

pip install xlearn

在这里插入图片描述

从iris快速入门

环境

  • ubuntu jupyter notebook
import xlearn as xl
 
ffm_model = xl.create_fm()
# 训练集
ffm_model.setTrain("./small_train.txt")
# 设置验证集
ffm_model.setValidate("./small_test.txt")
 
# 设置参数
param = {'task':'binary','lr':0.2,'lambda':0.002}
 
 
# 模型保存为model.txt
ffm_model.setTXTModel("./model.txt")
# 训练模型
ffm_model.fit(param, "model.out")
 
# 测试集
ffm_model.setTest("small_test.txt")
# 输出样本预测概率,范围(-1,1)
ffm_model.predict("model.out","output.txt")
 
# 设置预测概率范围为(0,1)
ffm_model.setSigmoid()
ffm_model.predict("model.out","output2.txt")
 

ffm_model.setSign()
ffm_model.predict("model.out","output3.txt")
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小刘要努力。

顺便点一个赞

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值