[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-ankane--eps":3,"tool-ankane--eps":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",144730,2,"2026-04-07T23:26:32",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107888,"2026-04-06T11:32:50",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":75,"owner_location":76,"owner_email":77,"owner_twitter":75,"owner_website":78,"owner_url":79,"languages":80,"stars":93,"forks":94,"last_commit_at":95,"license":96,"difficulty_score":32,"env_os":97,"env_gpu":98,"env_ram":99,"env_deps":100,"category_tags":108,"github_topics":109,"view_count":32,"oss_zip_url":75,"oss_zip_packed_at":75,"status":17,"created_at":113,"updated_at":114,"faqs":115,"releases":116},5387,"ankane\u002Feps","eps","Machine learning for Ruby","Eps 是一款专为 Ruby 开发者打造的机器学习工具，旨在让构建和部署预测模型变得简单高效。它解决了 Ruby 生态中缺乏原生、易用机器学习方案的痛点，允许开发者直接在熟悉的 Ruby 环境中完成从数据训练到模型预测的全流程，无需切换至 Python 或 R 等其他语言环境。\n\nEps 特别适合 Ruby 及 Rails 应用开发者，尤其是希望将数据科学能力融入现有 Web 项目的工程师。其核心亮点在于强大的互操作性：不仅支持在 Ruby 中训练模型，还能加载并运行由 Python、R 等语言构建的模型。此外，Eps 采用 PMML（预测模型标记语言）作为标准存储格式，确保了模型在不同平台和语言间的无缝迁移与复用。\n\n在使用体验上，Eps 自动化处理了训练集与验证集的划分，并提供清晰的性能评估指标（如回归任务的 RMSE 或分类任务的准确率）。它还内置了灵活的特征工程能力，能够智能处理数值、类别、文本甚至时间序列数据，帮助开发者轻松提取关键特征以提升模型表现。无论是进行房价预测还是用户分类，Eps 都能让你用简洁的代码快速实现智能化的数据应用。","# Eps\n\nMachine learning for Ruby\n\n- Build predictive models quickly and easily\n- Serve models built in Ruby, Python, R, and more\n\nCheck out [this post](https:\u002F\u002Fankane.org\u002Frails-meet-data-science) for more info on machine learning with Rails\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Factions\u002Fworkflows\u002Fbuild.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Factions)\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"eps\"\n```\n\nOn Mac, also install OpenMP:\n\n```sh\nbrew install libomp\n```\n\n## Getting Started\n\nCreate a model\n\n```ruby\ndata = [\n  {bedrooms: 1, bathrooms: 1, price: 100000},\n  {bedrooms: 2, bathrooms: 1, price: 125000},\n  {bedrooms: 2, bathrooms: 2, price: 135000},\n  {bedrooms: 3, bathrooms: 2, price: 162000}\n]\nmodel = Eps::Model.new(data, target: :price)\nputs model.summary\n```\n\nMake a prediction\n\n```ruby\nmodel.predict(bedrooms: 2, bathrooms: 1)\n```\n\nStore the model\n\n```ruby\nFile.write(\"model.pmml\", model.to_pmml)\n```\n\nLoad the model\n\n```ruby\npmml = File.read(\"model.pmml\")\nmodel = Eps::Model.load_pmml(pmml)\n```\n\nA few notes:\n\n- The target can be numeric (regression) or categorical (classification)\n- Pass an array of hashes to `predict` to make multiple predictions at once\n- Models are stored in [PMML](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FPredictive_Model_Markup_Language), a standard for model storage\n\n## Building Models\n\n### Goal\n\nOften, the goal of building a model is to make good predictions on future data. To help achieve this, Eps splits the data into training and validation sets if you have 30+ data points. It uses the training set to build the model and the validation set to evaluate the performance.\n\nIf your data has a time associated with it, it’s highly recommended to use that field for the split.\n\n```ruby\nEps::Model.new(data, target: :price, split: :listed_at)\n```\n\nOtherwise, the split is random. There are a number of [other options](#validation-options) as well.\n\nPerformance is reported in the summary.\n\n- For regression, it reports validation RMSE (root mean squared error) - lower is better\n- For classification, it reports validation accuracy - higher is better\n\nTypically, the best way to improve performance is feature engineering.\n\n### Feature Engineering\n\nFeatures are extremely important for model performance. Features can be:\n\n1. numeric\n2. categorical\n3. text\n\n#### Numeric\n\nFor numeric features, use any numeric type.\n\n```ruby\n{bedrooms: 4, bathrooms: 2.5}\n```\n\n#### Categorical\n\nFor categorical features, use strings or booleans.\n\n```ruby\n{state: \"CA\", basement: true}\n```\n\nConvert any ids to strings so they’re treated as categorical features.\n\n```ruby\n{city_id: city_id.to_s}\n```\n\nFor dates, create features like day of week and month.\n\n```ruby\n{weekday: sold_on.strftime(\"%a\"), month: sold_on.strftime(\"%b\")}\n```\n\nFor times, create features like day of week and hour of day.\n\n```ruby\n{weekday: listed_at.strftime(\"%a\"), hour: listed_at.hour.to_s}\n```\n\n#### Text\n\nFor text features, use strings with multiple words.\n\n```ruby\n{description: \"a beautiful house on top of a hill\"}\n```\n\nThis creates features based on [word count](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBag-of-words_model).\n\nYou can specify text features explicitly with:\n\n```ruby\nEps::Model.new(data, target: :price, text_features: [:description])\n```\n\nYou can set advanced options with:\n\n```ruby\ntext_features: {\n  description: {\n    min_occurrences: 5,         # min times a word must appear to be included in the model\n    max_features: 1000,         # max number of words to include in the model\n    min_length: 1,              # min length of words to be included\n    case_sensitive: true,       # how to treat words with different case\n    tokenizer: \u002F\\s+\u002F,           # how to tokenize the text, defaults to whitespace\n    stop_words: [\"and\", \"the\"]  # words to exclude from the model\n  }\n}\n```\n\n## Full Example\n\nWe recommend putting all the model code in a single file. This makes it easy to rebuild the model as needed.\n\nIn Rails, we recommend creating a `app\u002Fml_models` directory. Be sure to restart Spring after creating the directory so files are autoloaded.\n\n```sh\nbin\u002Fspring stop\n```\n\nHere’s what a complete model in `app\u002Fml_models\u002Fprice_model.rb` may look like:\n\n```ruby\nclass PriceModel \u003C Eps::Base\n  def build\n    houses = House.all\n\n    # train\n    data = houses.map { |v| features(v) }\n    model = Eps::Model.new(data, target: :price, split: :listed_at)\n    puts model.summary\n\n    # save to file\n    File.write(model_file, model.to_pmml)\n\n    # ensure reloads from file\n    @model = nil\n  end\n\n  def predict(house)\n    model.predict(features(house))\n  end\n\n  private\n\n  def features(house)\n    {\n      bedrooms: house.bedrooms,\n      city_id: house.city_id.to_s,\n      month: house.listed_at.strftime(\"%b\"),\n      listed_at: house.listed_at,\n      price: house.price\n    }\n  end\n\n  def model\n    @model ||= Eps::Model.load_pmml(File.read(model_file))\n  end\n\n  def model_file\n    File.join(__dir__, \"price_model.pmml\")\n  end\nend\n```\n\nBuild the model with:\n\n```ruby\nPriceModel.build\n```\n\nThis saves the model to `price_model.pmml`. Check this into source control or use a tool like [Trove](https:\u002F\u002Fgithub.com\u002Fankane\u002Ftrove) to store it.\n\nPredict with:\n\n```ruby\nPriceModel.predict(house)\n```\n\n## Monitoring\n\nWe recommend monitoring how well your models perform over time. To do this, save your predictions to the database. Then, compare them with:\n\n```ruby\nactual = houses.map(&:price)\npredicted = houses.map(&:predicted_price)\nEps.metrics(actual, predicted)\n```\n\nFor RMSE and MAE, alert if they rise above a certain threshold. For ME, alert if it moves too far away from 0. For accuracy, alert if it drops below a certain threshold.\n\n## Other Languages\n\nEps makes it easy to serve models from other languages. You can build models in Python, R, and others and serve them in Ruby without having to worry about how to deploy or run another language.\n\nEps can serve LightGBM, linear regression, and naive Bayes models. Check out [ONNX Runtime](https:\u002F\u002Fgithub.com\u002Fankane\u002Fonnxruntime) and [Scoruby](https:\u002F\u002Fgithub.com\u002Fasafschers\u002Fscoruby) to serve other models.\n\n### Python\n\nTo create a model in Python, install the [sklearn2pmml](https:\u002F\u002Fgithub.com\u002Fjpmml\u002Fsklearn2pmml) package\n\n```sh\npip install sklearn2pmml\n```\n\nAnd check out the examples:\n\n- [LightGBM Regression](test\u002Fsupport\u002Fpython\u002Flightgbm_regression.py)\n- [LightGBM Classification](test\u002Fsupport\u002Fpython\u002Flightgbm_classification.py)\n- [Linear Regression](test\u002Fsupport\u002Fpython\u002Flinear_regression.py)\n- [Naive Bayes](test\u002Fsupport\u002Fpython\u002Fnaive_bayes.py)\n\n### R\n\nTo create a model in R, install the [pmml](https:\u002F\u002Fcran.r-project.org\u002Fpackage=pmml) package\n\n```r\ninstall.packages(\"pmml\")\n```\n\nAnd check out the examples:\n\n- [Linear Regression](test\u002Fsupport\u002Fr\u002Flinear_regression.R)\n- [Naive Bayes](test\u002Fsupport\u002Fr\u002Fnaive_bayes.R)\n\n### Verifying\n\nIt’s important for features to be implemented consistently when serving models created in other languages. We highly recommend verifying this programmatically. Create a CSV file with ids and predictions from the original model.\n\nhouse_id | prediction\n--- | ---\n1 | 145000\n2 | 123000\n3 | 250000\n\nOnce the model is implemented in Ruby, confirm the predictions match.\n\n```ruby\nmodel = Eps::Model.load_pmml(\"model.pmml\")\n\n# preload houses to prevent n+1\nhouses = House.all.index_by(&:id)\n\nCSV.foreach(\"predictions.csv\", headers: true, converters: :numeric) do |row|\n  house = houses[row[\"house_id\"]]\n  expected = row[\"prediction\"]\n\n  actual = model.predict(bedrooms: house.bedrooms, bathrooms: house.bathrooms)\n\n  success = actual.is_a?(String) ? actual == expected : (actual - expected).abs \u003C 0.001\n  raise \"Bad prediction for house #{house.id} (exp: #{expected}, act: #{actual})\" unless success\n\n  putc \"✓\"\nend\n```\n\n## Data\n\nA number of data formats are supported. You can pass the target variable separately.\n\n```ruby\nx = [{x: 1}, {x: 2}, {x: 3}]\ny = [1, 2, 3]\nEps::Model.new(x, y)\n```\n\nData can be an array of arrays\n\n```ruby\nx = [[1, 2], [2, 0], [3, 1]]\ny = [1, 2, 3]\nEps::Model.new(x, y)\n```\n\nOr Numo arrays\n\n```ruby\nx = Numo::NArray.cast([[1, 2], [2, 0], [3, 1]])\ny = Numo::NArray.cast([1, 2, 3])\nEps::Model.new(x, y)\n```\n\nOr a Rover data frame\n\n```ruby\ndf = Rover.read_csv(\"houses.csv\")\nEps::Model.new(df, target: \"price\")\n```\n\nWhen reading CSV files directly, be sure to convert numeric fields. The `table` method does this automatically.\n\n```ruby\nCSV.table(\"data.csv\").map { |row| row.to_h }\n```\n\n## Algorithms\n\nPass an algorithm with:\n\n```ruby\nEps::Model.new(data, algorithm: :linear_regression)\n```\n\nEps supports:\n\n- LightGBM (default)\n- Linear Regression\n- Naive Bayes\n\n### LightGBM\n\nPass the learning rate with:\n\n```ruby\nEps::Model.new(data, learning_rate: 0.01)\n```\n\n### Linear Regression\n\nBy default, an intercept is included. Disable this with:\n\n```ruby\nEps::Model.new(data, intercept: false)\n```\n\nTo speed up training on large datasets with linear regression, [install GSL](https:\u002F\u002Fgithub.com\u002Fankane\u002Fgslr#gsl-installation). With Homebrew, you can use:\n\n```sh\nbrew install gsl\n```\n\nThen, add this line to your application’s Gemfile:\n\n```ruby\ngem \"gslr\", group: :development\n```\n\nIt only needs to be available in environments used to build the model.\n\n## Probability\n\nTo get the probability of each category for predictions with classification, use:\n\n```ruby\nmodel.predict_probability(data)\n```\n\nNaive Bayes is known to produce poor probability estimates, so stick with LightGBM if you need this.\n\n## Validation Options\n\nPass your own validation set with:\n\n```ruby\nEps::Model.new(data, validation_set: validation_set)\n```\n\nSplit on a specific value\n\n```ruby\nEps::Model.new(data, split: {column: :listed_at, value: Date.parse(\"2025-01-01\")})\n```\n\nSpecify the validation set size (the default is `0.25`, which is 25%)\n\n```ruby\nEps::Model.new(data, split: {validation_size: 0.2})\n```\n\nDisable the validation set completely with:\n\n```ruby\nEps::Model.new(data, split: false)\n```\n\n## Database Storage\n\nThe database is another place you can store models. It’s good if you retrain models automatically.\n\n> We recommend adding monitoring and guardrails as well if you retrain automatically\n\nCreate an Active Record model to store the predictive model.\n\n```sh\nrails generate model Model key:string:uniq data:text\n```\n\nStore the model with:\n\n```ruby\nstore = Model.where(key: \"price\").first_or_initialize\nstore.update(data: model.to_pmml)\n```\n\nLoad the model with:\n\n```ruby\ndata = Model.find_by!(key: \"price\").data\nmodel = Eps::Model.load_pmml(data)\n```\n\n## Jupyter & IRuby\n\nYou can use [IRuby](https:\u002F\u002Fgithub.com\u002FSciRuby\u002Firuby) to run Eps in [Jupyter](https:\u002F\u002Fjupyter.org\u002F) notebooks. Here’s how to get [IRuby working with Rails](https:\u002F\u002Fankane.org\u002Fjupyter-rails).\n\n## Weights\n\nSpecify a weight for each data point\n\n```ruby\nEps::Model.new(data, weight: :weight)\n```\n\nYou can also pass an array\n\n```ruby\nEps::Model.new(data, weight: [1, 2, 3])\n```\n\nWeights are supported for metrics as well\n\n```ruby\nEps.metrics(actual, predicted, weight: weight)\n```\n\nReweighing is one method to [mitigate bias](https:\u002F\u002Ffairlearn.org\u002F) in training data\n\n## History\n\nView the [changelog](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Fblob\u002Fmaster\u002FCHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Fissues)\n- Fix bugs and [submit pull requests](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Fpulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development:\n\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002Fankane\u002Feps.git\ncd eps\nbundle install\nbundle exec rake test\n```\n","# Eps\n\n适用于 Ruby 的机器学习\n\n- 快速且轻松地构建预测模型\n- 提供由 Ruby、Python、R 等语言构建的模型服务\n\n请查看[这篇博文](https:\u002F\u002Fankane.org\u002Frails-meet-data-science)，了解更多关于在 Rails 中使用机器学习的信息。\n\n[![构建状态](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Factions\u002Fworkflows\u002Fbuild.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Factions)\n\n## 安装\n\n将以下行添加到您的应用程序的 Gemfile 中：\n\n```ruby\ngem \"eps\"\n```\n\n在 Mac 上，还需要安装 OpenMP：\n\n```sh\nbrew install libomp\n```\n\n## 入门\n\n创建一个模型\n\n```ruby\ndata = [\n  {bedrooms: 1, bathrooms: 1, price: 100000},\n  {bedrooms: 2, bathrooms: 1, price: 125000},\n  {bedrooms: 2, bathrooms: 2, price: 135000},\n  {bedrooms: 3, bathrooms: 2, price: 162000}\n]\nmodel = Eps::Model.new(data, target: :price)\nputs model.summary\n```\n\n进行预测\n\n```ruby\nmodel.predict(bedrooms: 2, bathrooms: 1)\n```\n\n存储模型\n\n```ruby\nFile.write(\"model.pmml\", model.to_pmml)\n```\n\n加载模型\n\n```ruby\npmml = File.read(\"model.pmml\")\nmodel = Eps::Model.load_pmml(pmml)\n```\n\n几点说明：\n\n- 目标可以是数值型（回归）或分类型（分类）\n- 向 `predict` 方法传递哈希数组，可同时进行多次预测\n- 模型以 [PMML](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FPredictive_Model_Markup_Language) 格式存储，这是一种用于模型存储的标准\n\n## 构建模型\n\n### 目标\n\n通常，构建模型的目标是在未来数据上做出准确的预测。为此，Eps 在数据点达到 30 个及以上时，会将数据拆分为训练集和验证集。它使用训练集来构建模型，并用验证集来评估模型性能。\n\n如果您的数据带有时间信息，强烈建议使用该字段来进行拆分。\n\n```ruby\nEps::Model.new(data，target: :price，split: :listed_at)\n```\n\n否则，拆分会随机进行。此外还有许多[其他选项](#validation-options)可供选择。\n\n性能会在摘要中报告：\n\n- 对于回归问题，会报告验证 RMSE（均方根误差），值越低越好\n- 对于分类问题，会报告验证准确率，值越高越好\n\n通常，提升模型性能的最佳方法是特征工程。\n\n### 特征工程\n\n特征对模型性能至关重要。特征可以是：\n\n1. 数值型\n2. 分类型\n3. 文本型\n\n#### 数值型\n\n对于数值型特征，可以使用任何数值类型。\n\n```ruby\n{bedrooms: 4, bathrooms: 2.5}\n```\n\n#### 分类型\n\n对于分类型特征，可以使用字符串或布尔值。\n\n```ruby\n{state: \"CA\", basement: true}\n```\n\n将所有 ID 转换为字符串，以便将其视为分类特征。\n\n```ruby\n{city_id: city_id.to_s}\n```\n\n对于日期，可以创建诸如星期几和月份之类的特征。\n\n```ruby\n{weekday: sold_on.strftime(\"%a\"), month: sold_on.strftime(\"%b\")}\n```\n\n对于时间，可以创建诸如星期几和一天中的小时之类的特征。\n\n```ruby\n{weekday: listed_at.strftime(\"%a\"), hour: listed_at.hour.to_s}\n```\n\n#### 文本型\n\n对于文本特征，可以使用包含多个单词的字符串。\n\n```ruby\n{description: \"a beautiful house on top of a hill\"}\n```\n\n这会基于[词袋模型](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBag-of-words_model)创建特征。\n\n您可以显式指定文本特征：\n\n```ruby\nEps::Model.new(data, target: :price，text_features: [:description])\n```\n\n您还可以设置高级选项：\n\n```ruby\ntext_features: {\n  description: {\n    min_occurrences: 5,         # 单词至少出现多少次才会被纳入模型\n    max_features: 1000,         # 模型中最多包含多少个单词\n    min_length: 1,              # 要包含的单词的最小长度\n    case_sensitive: true,       # 如何处理大小写不同的单词\n    tokenizer: \u002F\\s+\u002F,           # 如何对文本进行分词，默认为空格\n    stop_words: [\"and\", \"the\"]  # 排除在模型之外的单词\n  }\n}\n```\n\n## 完整示例\n\n我们建议将所有模型代码放在一个文件中，这样可以根据需要轻松重建模型。\n\n在 Rails 中，我们建议创建一个 `app\u002Fml_models` 目录。创建该目录后，请务必重启 Spring，以便自动加载文件。\n\n```sh\nbin\u002Fspring stop\n```\n\n以下是一个完整的模型示例，位于 `app\u002Fml_models\u002Fprice_model.rb` 中：\n\n```ruby\nclass PriceModel \u003C Eps::Base\n  def build\n    houses = House.all\n\n    # 训练\n    data = houses.map { |v| features(v) }\n    model = Eps::Model.new(data, target: :price，split: :listed_at)\n    puts model.summary\n\n    # 保存到文件\n    File.write(model_file，model.to_pmml)\n\n    # 确保从文件重新加载\n    @model = nil\n  end\n\n  def predict(house)\n    model.predict(features(house))\n  end\n\n  private\n\n  def features(house)\n    {\n      bedrooms: house.bedrooms，\n      city_id: house.city_id.to_s，\n      month: house.listed_at.strftime(\"%b\")，\n      listed_at: house.listed_at，\n      price: house.price\n    }\n  end\n\n  def model\n    @model ||= Eps::Model.load_pmml(File.read(model_file))\n  end\n\n  def model_file\n    File.join(__dir__，\"price_model.pmml\")\n  end\nend\n```\n\n通过以下命令构建模型：\n\n```ruby\nPriceModel.build\n```\n\n这会将模型保存到 `price_model.pmml` 文件中。您可以将其提交到版本控制系统，或使用像 [Trove](https:\u002F\u002Fgithub.com\u002Fankane\u002Ftrove) 这样的工具来存储它。\n\n进行预测：\n\n```ruby\nPriceModel.predict(house)\n```\n\n## 监控\n\n我们建议监控模型随时间的表现。为此，可以将预测结果保存到数据库中，然后与实际值进行比较：\n\n```ruby\nactual = houses.map(&:price)\npredicted = houses.map(&:predicted_price)\nEps.metrics(actual，predicted)\n```\n\n对于 RMSE 和 MAE，如果它们超过某个阈值，则发出告警；对于 ME，如果其偏离 0 太远，则发出告警；对于准确率，如果低于某个阈值，则发出告警。\n\n## 其他语言\n\nEps 使从其他语言提供模型服务变得容易。您可以使用 Python、R 等语言构建模型，并在 Ruby 中提供这些模型的服务，而无需担心如何部署或运行其他语言。\n\nEps 可以提供 LightGBM、线性回归和朴素贝叶斯模型。请查看 [ONNX Runtime](https:\u002F\u002Fgithub.com\u002Fankane\u002Fonnxruntime) 和 [Scoruby](https:\u002F\u002Fgithub.com\u002Fasafschers\u002Fscoruby) 来提供其他模型的服务。\n\n### Python\n\n要在 Python 中创建模型，需安装 [sklearn2pmml](https:\u002F\u002Fgithub.com\u002Fjpmml\u002Fsklearn2pmml) 包：\n\n```sh\npip install sklearn2pmml\n```\n\n并查看以下示例：\n\n- [LightGBM 回归](test\u002Fsupport\u002Fpython\u002Flightgbm_regression.py)\n- [LightGBM 分类](test\u002Fsupport\u002Fpython\u002Flightgbm_classification.py)\n- [线性回归](test\u002Fsupport\u002Fpython\u002Flinear_regression.py)\n- [朴素贝叶斯](test\u002Fsupport\u002Fpython\u002Fnaive_bayes.py)\n\n### R\n\n要在 R 中创建模型，需安装 [pmml](https:\u002F\u002Fcran.r-project.org\u002Fpackage=pmml) 包：\n\n```r\ninstall.packages(\"pmml\")\n```\n\n并查看以下示例：\n\n- [线性回归](test\u002Fsupport\u002Fr\u002Flinear_regression.R)\n- [朴素贝叶斯](test\u002Fsupport\u002Fr\u002Fnaive_bayes.R)\n\n### 验证\n\n在为使用其他语言创建的模型提供服务时，确保功能实现的一致性非常重要。我们强烈建议通过编程方式进行验证。创建一个包含原始模型生成的 ID 和预测值的 CSV 文件。\n\nhouse_id | prediction\n--- | ---\n1 | 145000\n2 | 123000\n3 | 250000\n\n当模型用 Ruby 实现后，确认预测结果是否匹配。\n\n```ruby\nmodel = Eps::Model.load_pmml(\"model.pmml\")\n\n# 预加载房屋数据以防止 N+1 查询问题\nhouses = House.all.index_by(&:id)\n\nCSV.foreach(\"predictions.csv\", headers: true, converters: :numeric) do |row|\n  house = houses[row[\"house_id\"]]\n  expected = row[\"prediction\"]\n\n  actual = model.predict(bedrooms: house.bedrooms, bathrooms: house.bathrooms)\n\n  success = actual.is_a?(String) ? actual == expected : (actual - expected).abs \u003C 0.001\n  raise \"房屋 #{house.id} 的预测结果错误（预期：#{expected}, 实际：#{actual})\" unless success\n\n  putc \"✓\"\nend\n```\n\n## 数据\n\n支持多种数据格式。您可以单独传递目标变量。\n\n```ruby\nx = [{x: 1}, {x: 2}, {x: 3}]\ny = [1, 2, 3]\nEps::Model.new(x, y)\n```\n\n数据可以是数组的数组：\n\n```ruby\nx = [[1, 2], [2, 0], [3, 1]]\ny = [1, 2, 3]\nEps::Model.new(x, y)\n```\n\n或者 Numo 数组：\n\n```ruby\nx = Numo::NArray.cast([[1, 2], [2, 0], [3, 1]])\ny = Numo::NArray.cast([1, 2, 3])\nEps::Model.new(x, y)\n```\n\n也可以是 Rover 数据框：\n\n```ruby\ndf = Rover.read_csv(\"houses.csv\")\nEps::Model.new(df, target: \"price\")\n```\n\n直接读取 CSV 文件时，请务必转换数值字段。`table` 方法会自动完成此操作。\n\n```ruby\nCSV.table(\"data.csv\").map { |row| row.to_h }\n```\n\n## 算法\n\n可以通过以下方式传入算法：\n\n```ruby\nEps::Model.new(data, algorithm: :linear_regression)\n```\n\nEps 支持以下算法：\n\n- LightGBM（默认）\n- 线性回归\n- 朴素贝叶斯\n\n### LightGBM\n\n可以通过以下方式传入学习率：\n\n```ruby\nEps::Model.new(data, learning_rate: 0.01)\n```\n\n### 线性回归\n\n默认情况下会包含截距项。如果需要禁用截距项，可以这样设置：\n\n```ruby\nEps::Model.new(data, intercept: false)\n```\n\n为了加快大型数据集上线性回归的训练速度，可以安装 GSL（参见：https:\u002F\u002Fgithub.com\u002Fankane\u002Fgslr#gsl-installation）。使用 Homebrew 时，可以运行以下命令：\n\n```sh\nbrew install gsl\n```\n\n然后在应用程序的 Gemfile 中添加一行：\n\n```ruby\ngem \"gslr\", group: :development\n```\n\n该 gem 只需在用于构建模型的环境中可用即可。\n\n## 概率\n\n对于分类预测，若需获取每个类别的概率，可以使用以下方法：\n\n```ruby\nmodel.predict_probability(data)\n```\n\n需要注意的是，朴素贝叶斯算法通常会产生较差的概率估计，因此如果需要准确的概率值，建议使用 LightGBM。\n\n## 验证选项\n\n可以通过以下方式传入自定义的验证集：\n\n```ruby\nEps::Model.new(data, validation_set: validation_set)\n```\n\n按特定值分割数据集：\n\n```ruby\nEps::Model.new(data, split: {column: :listed_at, value: Date.parse(\"2025-01-01\")})\n```\n\n指定验证集的比例（默认为 25%，即 `0.25`）：\n\n```ruby\nEps::Model.new(data, split: {validation_size: 0.2})\n```\n\n完全禁用验证集：\n\n```ruby\nEps::Model.new(data, split: false)\n```\n\n## 数据库存储\n\n数据库是另一种存储模型的方式。如果您需要自动重新训练模型，这种方式非常合适。\n\n> 我们建议在自动重新训练的情况下，同时添加监控和防护机制。\n\n创建一个 Active Record 模型来存储预测模型：\n\n```sh\nrails generate model Model key:string:uniq data:text\n```\n\n使用以下代码存储模型：\n\n```ruby\nstore = Model.where(key: \"price\").first_or_initialize\nstore.update(data: model.to_pmml)\n```\n\n加载模型时，可以使用以下代码：\n\n```ruby\ndata = Model.find_by!(key: \"price\").data\nmodel = Eps::Model.load_pmml(data)\n```\n\n## Jupyter & IRuby\n\n您可以使用 [IRuby](https:\u002F\u002Fgithub.com\u002FSciRuby\u002Firuby) 在 [Jupyter](https:\u002F\u002Fjupyter.org\u002F) 笔记本中运行 Eps。以下是将 IRuby 与 Rails 集成的方法：[Jupyter 与 Rails 的集成指南](https:\u002F\u002Fankane.org\u002Fjupyter-rails)。\n\n## 权重\n\n可以为每个数据点指定权重：\n\n```ruby\nEps::Model.new(data, weight: :weight)\n```\n\n也可以传入一个数组：\n\n```ruby\nEps::Model.new(data, weight: [1, 2, 3])\n```\n\n权重同样适用于评估指标：\n\n```ruby\nEps.metrics(actual, predicted, weight: weight)\n```\n\n重新加权是缓解训练数据中偏见的一种方法（参见：https:\u002F\u002Ffairlearn.org\u002F）。\n\n## 历史\n\n查看 [变更日志](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Fblob\u002Fmaster\u002FCHANGELOG.md)。\n\n## 贡献\n\n我们鼓励所有人参与改进该项目。以下是一些您可以贡献的方式：\n\n- [报告问题](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Fissues)\n- 修复问题并提交 [拉取请求](https:\u002F\u002Fgithub.com\u002Fankane\u002Feps\u002Fpulls)\n- 编写、澄清或修正文档\n- 提出或添加新功能\n\n开始开发之前，请执行以下步骤：\n\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002Fankane\u002Feps.git\ncd eps\nbundle install\nbundle exec rake test\n```","# Eps 快速上手指南\n\nEps 是一个专为 Ruby 设计的机器学习库，支持快速构建预测模型，并能无缝加载由 Python、R 等语言训练并导出为 PMML 格式的模型。\n\n## 环境准备\n\n- **系统要求**：macOS、Linux 或 Windows（需配置 Ruby 开发环境）\n- **Ruby 版本**：建议 Ruby 2.7+\n- **前置依赖**：\n  - macOS 用户需安装 OpenMP 库以支持并行计算：\n    ```sh\n    brew install libomp\n    ```\n  - （可选）若使用线性回归处理大规模数据，建议安装 GSL：\n    ```sh\n    brew install gsl\n    ```\n    并在 Gemfile 中添加：\n    ```ruby\n    gem \"gslr\", group: :development\n    ```\n\n> 注：国内用户可使用清华或中科大镜像加速 Homebrew 或 gem 源，例如：\n> ```sh\n> gem sources --add https:\u002F\u002Fmirrors.tuna.tsinghua.edu.cn\u002Frubygems\u002F\n> gem sources --remove https:\u002F\u002Frubygems.org\u002F\n> ```\n\n## 安装步骤\n\n1. 在项目的 `Gemfile` 中添加：\n   ```ruby\n   gem \"eps\"\n   ```\n\n2. 执行安装命令：\n   ```sh\n   bundle install\n   ```\n\n## 基本使用\n\n### 1. 创建模型\n\n准备训练数据（数组哈希格式），指定目标字段（如 `:price`）：\n\n```ruby\ndata = [\n  {bedrooms: 1, bathrooms: 1, price: 100000},\n  {bedrooms: 2, bathrooms: 1, price: 125000},\n  {bedrooms: 2, bathrooms: 2, price: 135000},\n  {bedrooms: 3, bathrooms: 2, price: 162000}\n]\n\nmodel = Eps::Model.new(data, target: :price)\nputs model.summary\n```\n\n### 2. 进行预测\n\n传入新数据即可获取预测结果：\n\n```ruby\nprediction = model.predict(bedrooms: 2, bathrooms: 1)\nputs prediction\n```\n\n### 3. 保存与加载模型\n\n模型默认以标准 PMML 格式存储，便于跨语言复用：\n\n```ruby\n# 保存模型\nFile.write(\"model.pmml\", model.to_pmml)\n\n# 加载模型\npmml = File.read(\"model.pmml\")\nloaded_model = Eps::Model.load_pmml(pmml)\n```\n\n> 提示：目标字段可以是数值型（回归任务）或类别型（分类任务）。如需批量预测，可向 `predict` 传入哈希数组。","一家中型房产交易平台的技术团队，希望在其现有的 Ruby on Rails 应用中直接集成房价预测功能，以辅助用户快速评估房源价值。\n\n### 没有 eps 时\n- **架构割裂**：数据科学团队需用 Python 或 R 训练模型，后端团队必须通过复杂的 HTTP API 或消息队列进行跨语言调用，增加了系统延迟和维护成本。\n- **开发门槛高**：Rails 开发者不熟悉外部机器学习栈，每次调整特征或重新训练模型都需要协调多方资源，迭代周期长达数周。\n- **部署繁琐**：模型服务需要单独容器化部署，运维团队需额外监控一套异构基础设施，故障排查难度极大。\n- **特征工程受限**：难以灵活利用 Rails 业务逻辑中已有的时间戳、文本描述等数据进行实时特征转换，导致模型精度受限。\n\n### 使用 eps 后\n- **原生集成**：直接在 Gemfile 引入 eps，Rails 开发者无需离开熟悉的 Ruby 环境即可构建和运行预测模型，实现了“代码即模型”。\n- **敏捷迭代**：利用 eps 自动划分训练\u002F验证集的功能，团队可快速验证新特征（如将房源描述文本转化为词袋模型），将模型优化周期从数周缩短至数小时。\n- **简化运维**：模型被序列化为标准的 PMML 文件存储于本地或数据库，无需额外的模型服务器，彻底消除了跨语言调用的网络开销和运维负担。\n- **灵活特征处理**：轻松处理数值、类别及文本特征，例如直接将 `listed_at` 时间字段转换为“星期几”或“小时”特征，显著提升了预测准确度。\n\neps 让 Ruby 团队能够以原生方式无缝拥抱机器学习，打破了数据科学与 Web 开发之间的技术壁垒。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fankane_eps_90e23688.png","ankane","Andrew Kane","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fankane_502ffadf.jpg",null,"San Francisco, CA","andrew@ankane.org","https:\u002F\u002Fankane.org","https:\u002F\u002Fgithub.com\u002Fankane",[81,85,89],{"name":82,"color":83,"percentage":84},"Ruby","#701516",95.3,{"name":86,"color":87,"percentage":88},"Python","#3572A5",4.2,{"name":90,"color":91,"percentage":92},"R","#198CE7",0.5,687,15,"2026-04-04T22:05:23","MIT","macOS, Linux, Windows","不需要 GPU","未说明",{"notes":101,"python":102,"dependencies":103},"该工具核心是 Ruby 库。在 macOS 上必须通过 Homebrew 安装 OpenMP (libomp)。若需使用 Python 或 R 构建模型，需分别安装 sklearn2pmml 或 pmml 包以生成 PMML 格式文件供本工具加载。对于大型数据集的线性回归训练，建议安装 GSL 库以提升性能。","不需要 (核心为 Ruby 工具，仅在使用 Python 构建模型导出 PMML 时需要)",[82,104,105,106,107],"libomp (macOS 必需)","gsl (可选，用于加速线性回归)","sklearn2pmml (Python 端可选)","pmml (R 端可选)",[14],[110,111,112],"machine-learning","rubyml","automl","2026-03-27T02:49:30.150509","2026-04-08T12:59:51.807704",[],[]]