[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-combust--mleap":3,"tool-combust--mleap":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},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,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},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 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":80,"owner_email":81,"owner_twitter":80,"owner_website":82,"owner_url":83,"languages":84,"stars":107,"forks":108,"last_commit_at":109,"license":110,"difficulty_score":23,"env_os":111,"env_gpu":112,"env_ram":111,"env_deps":113,"category_tags":125,"github_topics":126,"view_count":23,"oss_zip_url":80,"oss_zip_packed_at":80,"status":16,"created_at":134,"updated_at":135,"faqs":136,"releases":170},3416,"combust\u002Fmleap","mleap","MLeap: Deploy ML Pipelines to Production","MLeap 是一款专为机器学习工程化设计的开源工具，旨在简化从模型训练到生产部署的复杂流程。它核心解决了数据科学家与工程师在将算法落地时面临的“环境依赖重、迁移难度大”痛点。传统模式下，模型往往强依赖于 Spark、Scikit-learn 或庞大的 Python 生态（如 NumPy、Pandas），导致在生产环境中部署笨重且易出错。\n\nMLeap 允许用户直接在 Spark 或 Scikit-learn 中训练模型，并将其序列化为一种轻量级、跨语言的通用格式（Bundle.ML）。随后，通过其高性能运行时引擎，即可在不安装任何原始训练框架依赖的情况下执行预测。这意味着你可以用 Python 训练模型，却在纯 Java 或 Scala 的生产系统中高效运行，彻底解耦了训练环境与推理环境。\n\n该工具非常适合机器学习研究员、数据科学家以及后端开发工程师使用。研究者可以继续使用熟悉的工具链进行实验，而工程师则能获得一个无依赖、低延迟的生产级推理服务。其技术亮点在于基于 JVM 构建的高性能执行内核，支持 JSON 和 Protobuf 两种便携序列化格式，并提供了与 Spark ML 高度","MLeap 是一款专为机器学习工程化设计的开源工具，旨在简化从模型训练到生产部署的复杂流程。它核心解决了数据科学家与工程师在将算法落地时面临的“环境依赖重、迁移难度大”痛点。传统模式下，模型往往强依赖于 Spark、Scikit-learn 或庞大的 Python 生态（如 NumPy、Pandas），导致在生产环境中部署笨重且易出错。\n\nMLeap 允许用户直接在 Spark 或 Scikit-learn 中训练模型，并将其序列化为一种轻量级、跨语言的通用格式（Bundle.ML）。随后，通过其高性能运行时引擎，即可在不安装任何原始训练框架依赖的情况下执行预测。这意味着你可以用 Python 训练模型，却在纯 Java 或 Scala 的生产系统中高效运行，彻底解耦了训练环境与推理环境。\n\n该工具非常适合机器学习研究员、数据科学家以及后端开发工程师使用。研究者可以继续使用熟悉的工具链进行实验，而工程师则能获得一个无依赖、低延迟的生产级推理服务。其技术亮点在于基于 JVM 构建的高性能执行内核，支持 JSON 和 Protobuf 两种便携序列化格式，并提供了与 Spark ML 高度一致的算子覆盖，确保模型在训练与推理阶段的行为完全一致，是构建可靠机器学习流水线的理想选择。","\u003Ca href=\"https:\u002F\u002Fcombust.github.io\u002Fmleap-docs\u002F\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcombust_mleap_readme_dd9f181a871c.png\" alt=\"MLeap Logo\" width=\"176\" height=\"70\" \u002F>\u003C\u002Fa>\n\n[![Gitter](https:\u002F\u002Fbadges.gitter.im\u002Fcombust\u002Fmleap.svg)](https:\u002F\u002Fgitter.im\u002Fcombust\u002Fmleap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002Fcombust\u002Fmleap.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Fcombust\u002Fmleap)\n[![Maven Central](https:\u002F\u002Fmaven-badges.herokuapp.com\u002Fmaven-central\u002Fml.combust.mleap\u002Fmleap-base_2.12\u002Fbadge.svg)](https:\u002F\u002Fmaven-badges.herokuapp.com\u002Fmaven-central\u002Fml.combust.mleap\u002Fmleap-base_2.12)\n\nDeploying machine learning data pipelines and algorithms should not be a time-consuming or difficult task. MLeap allows data scientists and engineers to deploy machine learning pipelines from Spark and Scikit-learn to a portable format and execution engine.\n\n## Documentation\n\nDocumentation is available at [https:\u002F\u002Fcombust.github.io\u002Fmleap-docs\u002F](https:\u002F\u002Fcombust.github.io\u002Fmleap-docs\u002F).\n\nRead [Serializing a Spark ML Pipeline and Scoring with MLeap](https:\u002F\u002Fgithub.com\u002Fcombust-ml\u002Fmleap\u002Fwiki\u002FSerializing-a-Spark-ML-Pipeline-and-Scoring-with-MLeap) to gain a full sense of what is possible.\n\n## Introduction\n\nUsing the MLeap execution engine and serialization format, we provide a performant, portable and easy-to-integrate production library for machine learning data pipelines and algorithms.\n\nFor portability, we build our software on the JVM and only use serialization formats that are widely-adopted.\n\nWe also provide a high level of integration with existing technologies.\n\nOur goals for this project are:\n\n1. Allow Researchers\u002FData Scientists and Engineers to continue to build data pipelines and train algorithms with Spark and Scikit-Learn\n2. Extend Spark\u002FScikit\u002FTensorFlow by providing ML Pipelines serialization\u002Fdeserialization to\u002Ffrom a common framework (Bundle.ML)\n3. Use MLeap Runtime to execute your pipeline and algorithm without dependenices on Spark or Scikit (numpy, pandas, etc)\n\n## Overview\n\n1. Core execution engine implemented in Scala\n2. [Spark](http:\u002F\u002Fspark.apache.org\u002F), PySpark and Scikit-Learn support\n3. Export a model with Scikit-learn or Spark and execute it using the MLeap Runtime (without dependencies on the Spark Context, or sklearn\u002Fnumpy\u002Fpandas\u002Fetc)\n4. Choose from 2 portable serialization formats (JSON, Protobuf)\n5. Implement your own custom data types and transformers for use with MLeap data frames and transformer pipelines\n6. Extensive test coverage with full parity tests for Spark and MLeap pipelines\n7. Optional Spark transformer extension to extend Spark's default transformer offerings\n\n\u003Cimg src=\"assets\u002Fimages\u002Fsingle-runtime.jpg\" alt=\"Unified Runtime\"\u002F>\n\n## Dependency Compatibility Matrix\n\nOther versions besides those listed below may also work (especially more recent Java versions for the JRE), \nbut these are the configurations which are tested by mleap.\n\n| MLeap Version | Spark Version | Scala Version    | Java Version | Python Version | XGBoost Version | Tensorflow Version |\n|---------------|---------------|------------------|--------------|----------------|-----------------|--------------------|\n| 0.24.0        | 4.0.1         | 2.13.16          | 17           | 3.9 - 3.13     | 2.0.3           | 2.10.1             |\n| 0.23.4        | 3.4.4         | 2.12.18          | 11           | 3.7 - 3.12     | 1.7.6           | 2.10.1             |\n| 0.23.3        | 3.4.0         | 2.12.18          | 11           | 3.7, 3.8       | 1.7.6           | 2.10.1             |\n| 0.23.2        | 3.4.0         | 2.12.18          | 11           | 3.7, 3.8       | 1.7.6           | 2.10.1             |\n| 0.23.1        | 3.4.0         | 2.12.18          | 11           | 3.7, 3.8       | 1.7.6           | 2.10.1             |\n| 0.23.0        | 3.4.0         | 2.12.13          | 11           | 3.7, 3.8       | 1.7.3           | 2.10.1             |\n| 0.22.0        | 3.3.0         | 2.12.13          | 11           | 3.7, 3.8       | 1.6.1           | 2.7.0              |\n| 0.21.1        | 3.2.0         | 2.12.13          | 11           | 3.7            | 1.6.1           | 2.7.0              |\n| 0.21.0        | 3.2.0         | 2.12.13          | 11           | 3.6, 3.7       | 1.6.1           | 2.7.0              |\n| 0.20.0        | 3.2.0         | 2.12.13          | 8            | 3.6, 3.7       | 1.5.2           | 2.7.0              |\n| 0.19.0        | 3.0.2         | 2.12.13          | 8            | 3.6, 3.7       | 1.3.1           | 2.4.1              |\n| 0.18.1        | 3.0.2         | 2.12.13          | 8            | 3.6, 3.7       | 1.0.0           | 2.4.1              |\n| 0.18.0        | 3.0.2         | 2.12.13          | 8            | 3.6, 3.7       | 1.0.0           | 2.4.1              |\n| 0.17.0        | 2.4.5         | 2.11.12, 2.12.10 | 8            | 3.6, 3.7       | 1.0.0           | 1.11.0             |\n\n## Setup\n\n### Link with Maven or SBT\n\n#### SBT\n\n```sbt\nlibraryDependencies += \"ml.combust.mleap\" %% \"mleap-runtime\" % \"0.24.0\"\n```\n\n#### Maven\n\n```pom\n\u003Cdependency>\n    \u003CgroupId>ml.combust.mleap\u003C\u002FgroupId>\n    \u003CartifactId>mleap-runtime_2.13\u003C\u002FartifactId>\n    \u003Cversion>0.24.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n### For Spark Integration\n\n#### SBT\n\n```sbt\nlibraryDependencies += \"ml.combust.mleap\" %% \"mleap-spark\" % \"0.24.0\"\n```\n\n#### Maven\n\n```pom\n\u003Cdependency>\n    \u003CgroupId>ml.combust.mleap\u003C\u002FgroupId>\n    \u003CartifactId>mleap-spark_2.13\u003C\u002FartifactId>\n    \u003Cversion>0.24.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n### PySpark Integration\n\nInstall MLeap from [PyPI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fmleap\u002F)\n```bash\n$ pip install mleap\n```\n\n## Using the Library\n\nFor more complete examples, see our other Git repository: [MLeap Demos](https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap-demo)\n\n### Create and Export a Spark Pipeline\n\nThe first step is to create our pipeline in Spark. For our example we will manually build a simple Spark ML pipeline.\n\n\n```scala\nimport ml.combust.bundle.BundleFile\nimport ml.combust.mleap.spark.SparkSupport._\nimport org.apache.spark.ml.Pipeline\nimport org.apache.spark.ml.bundle.SparkBundleContext\nimport org.apache.spark.ml.feature.{Binarizer, StringIndexer}\nimport org.apache.spark.sql._\nimport org.apache.spark.sql.functions._\nimport scala.util.Using\n\n  val datasetName = \".\u002Fexamples\u002Fspark-demo.csv\"\n\n  val dataframe: DataFrame = spark.sqlContext.read.format(\"csv\")\n    .option(\"header\", true)\n    .load(datasetName)\n    .withColumn(\"test_double\", col(\"test_double\").cast(\"double\"))\n\n  \u002F\u002F User out-of-the-box Spark transformers like you normally would\n  val stringIndexer = new StringIndexer().\n    setInputCol(\"test_string\").\n    setOutputCol(\"test_index\")\n\n  val binarizer = new Binarizer().\n    setThreshold(0.5).\n    setInputCol(\"test_double\").\n    setOutputCol(\"test_bin\")\n\n  val pipelineEstimator = new Pipeline()\n    .setStages(Array(stringIndexer, binarizer))\n\n  val pipeline = pipelineEstimator.fit(dataframe)\n\n  \u002F\u002F then serialize pipeline\n  val sbc = SparkBundleContext().withDataset(pipeline.transform(dataframe))\n  Using(BundleFile(\"jar:file:\u002Ftmp\u002Fsimple-spark-pipeline.zip\")) { bf =>\n    pipeline.writeBundle.save(bf)(sbc).get\n  }\n```\n\nThe dataset used for training can be found [here](https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Ftree\u002Fmaster\u002Fexamples\u002Fspark-demo.csv)\n\nSpark pipelines are not meant to be run outside of Spark. They require a DataFrame and therefore a SparkContext to run. These are expensive data structures and libraries to include in a project. With MLeap, there is no dependency on Spark to execute a pipeline. MLeap dependencies are lightweight and we use fast data structures to execute your ML pipelines.\n\n### PySpark Integration\n\nImport the MLeap library in your PySpark job\n\n```python\nimport mleap.pyspark\nfrom mleap.pyspark.spark_support import SimpleSparkSerializer\n```\n\nSee [PySpark Integration of python\u002FREADME.md](python\u002FREADME.md#pyspark-integration) for more.\n\n### Create and Export a Scikit-Learn Pipeline\n\n```python\nimport pandas as pd\n\nfrom mleap.sklearn.pipeline import Pipeline\nfrom mleap.sklearn.preprocessing.data import FeatureExtractor, LabelEncoder, ReshapeArrayToN1\nfrom sklearn.preprocessing import OneHotEncoder\n\ndata = pd.DataFrame(['a', 'b', 'c'], columns=['col_a'])\n\ncategorical_features = ['col_a']\n\nfeature_extractor_tf = FeatureExtractor(input_scalars=categorical_features, \n                                         output_vector='imputed_features', \n                                         output_vector_items=categorical_features)\n\n# Label Encoder for x1 Label \nlabel_encoder_tf = LabelEncoder(input_features=feature_extractor_tf.output_vector_items,\n                               output_features='{}_label_le'.format(categorical_features[0]))\n\n# Reshape the output of the LabelEncoder to N-by-1 array\nreshape_le_tf = ReshapeArrayToN1()\n\n# Vector Assembler for x1 One Hot Encoder\none_hot_encoder_tf = OneHotEncoder(sparse=False)\none_hot_encoder_tf.mlinit(prior_tf = label_encoder_tf, \n                          output_features = '{}_label_one_hot_encoded'.format(categorical_features[0]))\n\none_hot_encoder_pipeline_x0 = Pipeline([\n                                         (feature_extractor_tf.name, feature_extractor_tf),\n                                         (label_encoder_tf.name, label_encoder_tf),\n                                         (reshape_le_tf.name, reshape_le_tf),\n                                         (one_hot_encoder_tf.name, one_hot_encoder_tf)\n                                        ])\n\none_hot_encoder_pipeline_x0.mlinit()\none_hot_encoder_pipeline_x0.fit_transform(data)\none_hot_encoder_pipeline_x0.serialize_to_bundle('\u002Ftmp', 'mleap-scikit-test-pipeline', init=True)\n\n# array([[ 1.,  0.,  0.],\n#        [ 0.,  1.,  0.],\n#        [ 0.,  0.,  1.]])\n```\n\n### Load and Transform Using MLeap\n\nBecause we export Spark and Scikit-learn pipelines to a standard format, we can use either our Spark-trained pipeline or our Scikit-learn pipeline from the previous steps to demonstrate usage of MLeap in this section. The choice is yours!\n\n```scala\nimport ml.combust.bundle.BundleFile\nimport ml.combust.mleap.runtime.MleapSupport._\nimport scala.util.Using\n\u002F\u002F load the Spark pipeline we saved in the previous section\nval bundle = Using(BundleFile(\"jar:file:\u002Ftmp\u002Fsimple-spark-pipeline.zip\"))) { bundleFile =>\n  bundleFile.loadMleapBundle().get\n}).opt.get\n\n\u002F\u002F create a simple LeapFrame to transform\nimport ml.combust.mleap.runtime.frame.{DefaultLeapFrame, Row}\nimport ml.combust.mleap.core.types._\n\n\u002F\u002F MLeap makes extensive use of monadic types like Try\nval schema = StructType(StructField(\"test_string\", ScalarType.String),\n  StructField(\"test_double\", ScalarType.Double)).get\nval data = Seq(Row(\"hello\", 0.6), Row(\"MLeap\", 0.2))\nval frame = DefaultLeapFrame(schema, data)\n\n\u002F\u002F transform the dataframe using our pipeline\nval mleapPipeline = bundle.root\nval frame2 = mleapPipeline.transform(frame).get\nval data2 = frame2.dataset\n\n\u002F\u002F get data from the transformed rows and make some assertions\nassert(data2(0).getDouble(2) == 1.0) \u002F\u002F string indexer output\nassert(data2(0).getDouble(3) == 1.0) \u002F\u002F binarizer output\n\n\u002F\u002F the second row\nassert(data2(1).getDouble(2) == 2.0)\nassert(data2(1).getDouble(3) == 0.0)\n```\n\n## Documentation\n\nFor more documentation, please see our [documentation](https:\u002F\u002Fcombust.github.io\u002Fmleap-docs\u002F), where you can learn to:\n\n1. Implement custom transformers that will work with Spark, MLeap and Scikit-learn\n2. Implement custom data types to transform with Spark and MLeap pipelines\n3. Transform with blazing fast speeds using optimized row-based transformers\n4. Serialize MLeap data frames to various formats like avro, json, and a custom binary format\n5. Implement new serialization formats for MLeap data frames\n6. Work through several demonstration pipelines which use real-world data to create predictive pipelines\n7. Supported Spark transformers\n8. Supported Scikit-learn transformers\n9. Custom transformers provided by MLeap\n\n## Contributing\n\n* Write documentation.\n* Write a tutorial\u002Fwalkthrough for an interesting ML problem\n* Contribute an Estimator\u002FTransformer from Spark\n* Use MLeap at your company and tell us what you think\n* Make a feature request or report a bug in github\n* Make a pull request for an existing feature request or bug report\n* Join the discussion of how to get MLeap into Spark as a dependency. Talk with us on Gitter (see link at top of README.md)\n\n## Building\n\nPlease ensure you have sbt 1.9.3, java 11, scala 2.12.18\n\n1. Initialize the git submodules `git submodule update --init --recursive`\n2. Run `sbt compile`\n\n## Thank You\n\nThank you to [Swoop](https:\u002F\u002Fwww.swoop.com\u002F) for supporting the XGboost\nintegration.\n\n## Contributors Information\n\n* Jason Sleight ([jsleight](https:\u002F\u002Fgithub.com\u002Fjsleight))\n* Talal Riaz ([talalryz](https:\u002F\u002Fgithub.com\u002Ftalalryz))\n* Weichen Xu ([WeichenXu123](https:\u002F\u002Fgithub.com\u002FWeichenXu123))\n\n## Past contributors\n* Hollin Wilkins (hollin@combust.ml)\n* Mikhail Semeniuk (mikhail@combust.ml)\n* Anca Sarb (sarb.anca@gmail.com)\n* Ryan Vogan (rvogan@yelp.com)\n\n\n## License\n\nSee LICENSE and NOTICE file in this repository.\n\nCopyright 20 Combust, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","\u003Ca href=\"https:\u002F\u002Fcombust.github.io\u002Fmleap-docs\u002F\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcombust_mleap_readme_dd9f181a871c.png\" alt=\"MLeap Logo\" width=\"176\" height=\"70\" \u002F>\u003C\u002Fa>\n\n[![Gitter](https:\u002F\u002Fbadges.gitter.im\u002Fcombust\u002Fmleap.svg)](https:\u002F\u002Fgitter.im\u002Fcombust\u002Fmleap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002Fcombust\u002Fmleap.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Fcombust\u002Fmleap)\n[![Maven Central](https:\u002F\u002Fmaven-badges.herokuapp.com\u002Fmaven-central\u002Fml.combust.mleap\u002Fmleap-base_2.12\u002Fbadge.svg)](https:\u002F\u002Fmaven-badges.herokuapp.com\u002Fmaven-central\u002Fml.combust.mleap\u002Fmleap-base_2.12)\n\n部署机器学习数据管道和算法不应是一项耗时或困难的任务。MLeap 使数据科学家和工程师能够将来自 Spark 和 Scikit-learn 的机器学习管道转换为可移植的格式，并在执行引擎中运行。\n\n## 文档\n\n文档可在 [https:\u002F\u002Fcombust.github.io\u002Fmleap-docs\u002F](https:\u002F\u002Fcombust.github.io\u002Fmleap-docs\u002F) 找到。\n\n阅读 [序列化 Spark ML 管道并使用 MLeap 进行评分](https:\u002F\u002Fgithub.com\u002Fcombust-ml\u002Fmleap\u002Fwiki\u002FSerializing-a-Spark-ML-Pipeline-and-Scoring-with-MLeap)，以全面了解其功能。\n\n## 简介\n\n借助 MLeap 执行引擎和序列化格式，我们提供了一个高性能、可移植且易于集成的生产级库，用于机器学习数据管道和算法。\n\n为了实现可移植性，我们的软件基于 JVM 构建，并仅使用广泛采用的序列化格式。\n\n我们还提供了与现有技术的高度集成。\n\n本项目的三个主要目标是：\n\n1. 允许研究人员、数据科学家和工程师继续使用 Spark 和 Scikit-learn 构建数据管道并训练算法。\n2. 通过提供 ML 管道在通用框架（Bundle.ML）之间的序列化和反序列化能力，扩展 Spark、Scikit 和 TensorFlow 的功能。\n3. 使用 MLeap Runtime 执行您的管道和算法，而无需依赖 Spark 或 Scikit（numpy、pandas 等）。\n\n## 概述\n\n1. 核心执行引擎用 Scala 实现。\n2. 支持 Spark、PySpark 和 Scikit-Learn。\n3. 可以使用 Scikit-learn 或 Spark 导出模型，并使用 MLeap Runtime 执行，而无需依赖 Spark 上下文或 sklearn\u002Fnumpy\u002Fpandas 等。\n4. 提供两种可移植的序列化格式（JSON、Protobuf）供选择。\n5. 您可以实现自己的自定义数据类型和转换器，用于 MLeap 数据框和转换器管道。\n6. 测试覆盖率高，对 Spark 和 MLeap 管道进行了完全一致的测试。\n7. 可选的 Spark 转换器扩展，用于扩展 Spark 的默认转换器功能。\n\n\u003Cimg src=\"assets\u002Fimages\u002Fsingle-runtime.jpg\" alt=\"统一运行时\"\u002F>\n\n## 依赖兼容性矩阵\n\n除了以下列出的版本外，其他版本也可能适用（尤其是较新的 Java 版本用于 JRE），但这些是经过 mleap 测试的配置。\n\n| MLeap 版本 | Spark 版本 | Scala 版本 | Java 版本 | Python 版本 | XGBoost 版本 | Tensorflow 版本 |\n|------------|------------|------------|-----------|-------------|--------------|-----------------|\n| 0.24.0     | 4.0.1      | 2.13.16    | 17        | 3.9 - 3.13  | 2.0.3        | 2.10.1          |\n| 0.23.4     | 3.4.4      | 2.12.18    | 11        | 3.7 - 3.12  | 1.7.6        | 2.10.1          |\n| 0.23.3     | 3.4.0      | 2.12.18    | 11        | 3.7, 3.8    | 1.7.6        | 2.10.1          |\n| 0.23.2     | 3.4.0      | 2.12.18    | 11        | 3.7, 3.8    | 1.7.6        | 2.10.1          |\n| 0.23.1     | 3.4.0      | 2.12.18    | 11        | 3.7, 3.8    | 1.7.6        | 2.10.1          |\n| 0.23.0     | 3.4.0      | 2.12.13    | 11        | 3.7, 3.8    | 1.7.3        | 2.10.1          |\n| 0.22.0     | 3.3.0      | 2.12.13    | 11        | 3.7, 3.8    | 1.6.1        | 2.7.0           |\n| 0.21.1     | 3.2.0      | 2.12.13    | 11        | 3.7         | 1.6.1        | 2.7.0           |\n| 0.21.0     | 3.2.0      | 2.12.13    | 11        | 3.6, 3.7    | 1.6.1        | 2.7.0           |\n| 0.20.0     | 3.2.0      | 2.12.13    | 8         | 3.6, 3.7    | 1.5.2        | 2.7.0           |\n| 0.19.0     | 3.0.2      | 2.12.13    | 8         | 3.6, 3.7    | 1.3.1        | 2.4.1           |\n| 0.18.1     | 3.0.2      | 2.12.13    | 8         | 3.6, 3.7    | 1.0.0        | 2.4.1           |\n| 0.18.0     | 3.0.2      | 2.12.13    | 8         | 3.6, 3.7    | 1.0.0        | 2.4.1           |\n| 0.17.0     | 2.4.5      | 2.11.12, 2.12.10 | 8         | 3.6, 3.7    | 1.0.0        | 1.11.0          |\n\n## 设置\n\n### 使用 Maven 或 SBT 链接\n\n#### SBT\n\n```sbt\nlibraryDependencies += \"ml.combust.mleap\" %% \"mleap-runtime\" % \"0.24.0\"\n```\n\n#### Maven\n\n```pom\n\u003Cdependency>\n    \u003CgroupId>ml.combust.mleap\u003C\u002FgroupId>\n    \u003CartifactId>mleap-runtime_2.13\u003C\u002FartifactId>\n    \u003Cversion>0.24.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n### 对于 Spark 集成\n\n#### SBT\n\n```sbt\nlibraryDependencies += \"ml.combust.mleap\" %% \"mleap-spark\" % \"0.24.0\"\n```\n\n#### Maven\n\n```pom\n\u003Cdependency>\n    \u003CgroupId>ml.combust.mleap\u003C\u002FgroupId>\n    \u003CartifactId>mleap-spark_2.13\u003C\u002FartifactId>\n    \u003Cversion>0.24.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n### PySpark 集成\n\n从 [PyPI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fmleap\u002F) 安装 MLeap：\n```bash\n$ pip install mleap\n```\n\n## 使用该库\n\n更多完整示例，请参阅我们的另一个 Git 仓库：[MLeap Demos](https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap-demo)\n\n### 创建并导出 Spark 管道\n\n第一步是在 Spark 中创建我们的管道。在本示例中，我们将手动构建一个简单的 Spark ML 管道。\n\n\n```scala\nimport ml.combust.bundle.BundleFile\nimport ml.combust.mleap.spark.SparkSupport._\nimport org.apache.spark.ml.Pipeline\nimport org.apache.spark.ml.bundle.SparkBundleContext\nimport org.apache.spark.ml.feature.{Binarizer, StringIndexer}\nimport org.apache.spark.sql._\nimport org.apache.spark.sql.functions._\nimport scala.util.Using\n\n  val datasetName = \".\u002Fexamples\u002Fspark-demo.csv\"\n\n  val dataframe: DataFrame = spark.sqlContext.read.format(\"csv\")\n    .option(\"header\", true)\n    .load(datasetName)\n    .withColumn(\"test_double\", col(\"test_double\").cast(\"double\"))\n\n  \u002F\u002F 按照常规方式使用 Spark 自带的转换器\n  val stringIndexer = new StringIndexer().\n    setInputCol(\"test_string\").\n    setOutputCol(\"test_index\")\n\n  val binarizer = new Binarizer().\n    setThreshold(0.5).\n    setInputCol(\"test_double\").\n    setOutputCol(\"test_bin\")\n\n  val pipelineEstimator = new Pipeline()\n    .setStages(Array(stringIndexer, binarizer))\n\n  val pipeline = pipelineEstimator.fit(dataframe)\n\n  \u002F\u002F 然后序列化管道\n  val sbc = SparkBundleContext().withDataset(pipeline.transform(dataframe))\n  Using(BundleFile(\"jar:file:\u002Ftmp\u002Fsimple-spark-pipeline.zip\")) { bf =>\n    pipeline.writeBundle.save(bf)(sbc).get\n  }\n```\n\n用于训练的数据集可以在 [这里](https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Ftree\u002Fmaster\u002Fexamples\u002Fspark-demo.csv) 找到。\n\nSpark 管道并不适合在 Spark 外部运行。它们需要一个 DataFrame 和一个 SparkContext 才能运行。这些数据结构和库在项目中引入时会带来较大的开销。而借助 MLeap，执行管道不再依赖于 Spark。MLeap 的依赖项非常轻量，并且我们使用高效的数据结构来执行您的机器学习管道。\n\n### PySpark 集成\n\n在您的 PySpark 作业中导入 MLeap 库：\n\n```python\nimport mleap.pyspark\nfrom mleap.pyspark.spark_support import SimpleSparkSerializer\n```\n\n更多内容请参阅 [PySpark 集成的 python\u002FREADME.md](python\u002FREADME.md#pyspark-integration)。\n\n### 创建并导出 Scikit-learn 管道\n\n```python\nimport pandas as pd\n\nfrom mleap.sklearn.pipeline import Pipeline\nfrom mleap.sklearn.preprocessing.data import FeatureExtractor, LabelEncoder, ReshapeArrayToN1\nfrom sklearn.preprocessing import OneHotEncoder\n\ndata = pd.DataFrame(['a', 'b', 'c'], columns=['col_a'])\n\ncategorical_features = ['col_a']\n\nfeature_extractor_tf = FeatureExtractor(input_scalars=categorical_features, \n                                         output_vector='imputed_features', \n                                         output_vector_items=categorical_features)\n\n# x1 标签的标签编码器\nlabel_encoder_tf = LabelEncoder(input_features=feature_extractor_tf.output_vector_items,\n                               output_features='{}_label_le'.format(categorical_features[0]))\n\n# 将标签编码器的输出重塑为 N×1 数组\nreshape_le_tf = ReshapeArrayToN1()\n\n# x1 one-hot 编码器的向量组装器\none_hot_encoder_tf = OneHotEncoder(sparse=False)\none_hot_encoder_tf.mlinit(prior_tf = label_encoder_tf, \n                          output_features = '{}_label_one_hot_encoded'.format(categorical_features[0]))\n\none_hot_encoder_pipeline_x0 = Pipeline([\n                                         (feature_extractor_tf.name, feature_extractor_tf),\n                                         (label_encoder_tf.name, label_encoder_tf),\n                                         (reshape_le_tf.name, reshape_le_tf),\n                                         (one_hot_encoder_tf.name, one_hot_encoder_tf)\n                                        ])\n\none_hot_encoder_pipeline_x0.mlinit()\none_hot_encoder_pipeline_x0.fit_transform(data)\none_hot_encoder_pipeline_x0.serialize_to_bundle('\u002Ftmp', 'mleap-scikit-test-pipeline', init=True)\n\n# array([[ 1.,  0.,  0.],\n#        [ 0.,  1.,  0.],\n#        [ 0.,  0.,  1.]])\n```\n\n### 使用 MLeap 加载并转换\n\n由于我们将 Spark 和 Scikit-learn 管道导出为标准格式，因此在本节中，我们可以使用之前步骤中保存的 Spark 训练的管道或 Scikit-learn 管道来演示 MLeap 的用法。选择权在您！\n\n```scala\nimport ml.combust.bundle.BundleFile\nimport ml.combust.mleap.runtime.MleapSupport._\nimport scala.util.Using\n\u002F\u002F 加载我们在上一节中保存的 Spark 管道\nval bundle = Using(BundleFile(\"jar:file:\u002Ftmp\u002Fsimple-spark-pipeline.zip\"))) { bundleFile =>\n  bundleFile.loadMleapBundle().get\n}).opt.get\n\n\u002F\u002F 创建一个简单的 LeapFrame 进行转换\nimport ml.combust.mleap.runtime.frame.{DefaultLeapFrame, Row}\nimport ml.combust.mleap.core.types._\n\n\u002F\u002F MLeap 广泛使用类似 Try 的单子类型\nval schema = StructType(StructField(\"test_string\", ScalarType.String),\n  StructField(\"test_double\", ScalarType.Double)).get\nval data = Seq(Row(\"hello\", 0.6), Row(\"MLeap\", 0.2))\nval frame = DefaultLeapFrame(schema, data)\n\n\u002F\u002F 使用我们的管道转换数据框\nval mleapPipeline = bundle.root\nval frame2 = mleapPipeline.transform(frame).get\nval data2 = frame2.dataset\n\n\u002F\u002F 从转换后的行中获取数据并进行一些断言\nassert(data2(0).getDouble(2) == 1.0) \u002F\u002F 字符串索引器的输出\nassert(data2(0).getDouble(3) == 1.0) \u002F\u002F 二值化器的输出\n\n\u002F\u002F 第二行\nassert(data2(1).getDouble(2) == 2.0)\nassert(data2(1).getDouble(3) == 0.0)\n```\n\n## 文档\n\n如需更多文档，请参阅我们的 [文档](https:\u002F\u002Fcombust.github.io\u002Fmleap-docs\u002F)，您可以在其中学习如何：\n\n1. 实现可与 Spark、MLeap 和 Scikit-learn 兼容的自定义转换器。\n2. 实现可用于 Spark 和 MLeap 管道的自定义数据类型。\n3. 使用优化的基于行的转换器以极快的速度进行转换。\n4. 将 MLeap 数据帧序列化为多种格式，如 avro、json 和自定义二进制格式。\n5. 为 MLeap 数据帧实现新的序列化格式。\n6. 通过多个使用真实世界数据创建预测性管道的演示管道进行实践。\n7. 支持的 Spark 转换器。\n8. 支持的 Scikit-learn 转换器。\n9. MLeap 提供的自定义转换器。\n\n## 贡献\n\n* 编写文档。\n* 为有趣的机器学习问题编写教程或操作指南。\n* 贡献来自 Spark 的估计器或转换器。\n* 在贵公司使用 MLeap，并告诉我们您的想法。\n* 在 GitHub 上提出功能请求或报告 bug。\n* 为现有的功能请求或 bug 报告提交拉取请求。\n* 参与讨论如何将 MLeap 作为依赖项集成到 Spark 中。请在 Gitter 上与我们交流（请参阅 README.md 顶部的链接）。\n\n## 构建\n\n请确保您已安装 sbt 1.9.3、Java 11 和 Scala 2.12.18。\n\n1. 初始化 Git 子模块：`git submodule update --init --recursive`\n2. 运行 `sbt compile`\n\n## 感谢\n\n感谢 [Swoop](https:\u002F\u002Fwww.swoop.com\u002F) 对 XGboost 集成的支持。\n\n## 贡献者信息\n\n* Jason Sleight ([jsleight](https:\u002F\u002Fgithub.com\u002Fjsleight))\n* Talal Riaz ([talalryz](https:\u002F\u002Fgithub.com\u002Ftalalryz))\n* Weichen Xu ([WeichenXu123](https:\u002F\u002Fgithub.com\u002FWeichenXu123))\n\n## 历史贡献者\n* Hollin Wilkins (hollin@combust.ml)\n* Mikhail Semeniuk (mikhail@combust.ml)\n* Anca Sarb (sarb.anca@gmail.com)\n* Ryan Vogan (rvogan@yelp.com)\n\n\n## 许可证\n\n请参阅本仓库中的 LICENSE 和 NOTICE 文件。\n\n版权所有 © 20 Combust, Inc.\n\n本软件依照 Apache License, Version 2.0（“许可证”）授权使用；\n除非符合该许可证的规定，否则不得使用本文件。\n您可以在以下网址获取许可证的副本：\n\nhttp:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\n除非适用法律要求或各方另有书面约定，否则本软件以“AS IS”基础分发，\n不提供任何形式的明示或默示担保或条件。有关具体权限和限制，请参阅许可证文本。","# MLeap 快速上手指南\n\nMLeap 是一个高性能、可移植的机器学习部署库，支持将 Spark ML 和 Scikit-learn 训练的模型序列化为通用格式（Bundle.ML），并在不依赖 Spark 或 Python 环境的生产系统中直接运行。\n\n## 环境准备\n\n### 系统要求\nMLeap 基于 JVM 构建，请确保您的环境满足以下版本兼容性（以最新稳定版 0.24.0 为例）：\n\n| 组件 | 版本要求 |\n| :--- | :--- |\n| **Java (JRE\u002FJDK)** | 17 |\n| **Scala** | 2.13.16 |\n| **Spark** (如需训练) | 4.0.1 |\n| **Python** (如需 PySpark\u002FSklearn) | 3.9 - 3.13 |\n\n> **注意**：如果您使用旧版 Spark (如 3.4.x)，请选择对应的 MLeap 版本 (如 0.23.4)，并搭配 Java 11 和 Scala 2.12。\n\n### 前置依赖\n- **构建工具**：Maven 或 SBT (用于 JVM 项目)\n- **Python 包管理器**：pip (用于 Python 项目)\n\n## 安装步骤\n\n根据您的开发语言选择相应的安装方式。\n\n### 1. JVM 项目 (Scala\u002FJava)\n\n**使用 SBT:**\n在 `build.sbt` 中添加运行时依赖：\n```sbt\nlibraryDependencies += \"ml.combust.mleap\" %% \"mleap-runtime\" % \"0.24.0\"\n```\n\n若需集成 Spark 进行模型导出，还需添加：\n```sbt\nlibraryDependencies += \"ml.combust.mleap\" %% \"mleap-spark\" % \"0.24.0\"\n```\n\n**使用 Maven:**\n在 `pom.xml` 中添加依赖：\n```xml\n\u003Cdependency>\n    \u003CgroupId>ml.combust.mleap\u003C\u002FgroupId>\n    \u003CartifactId>mleap-runtime_2.13\u003C\u002FartifactId>\n    \u003Cversion>0.24.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n若需集成 Spark：\n```xml\n\u003Cdependency>\n    \u003CgroupId>ml.combust.mleap\u003C\u002FgroupId>\n    \u003CartifactId>mleap-spark_2.13\u003C\u002FartifactId>\n    \u003Cversion>0.24.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n### 2. Python 项目 (PySpark \u002F Scikit-learn)\n\n通过 pip 安装：\n```bash\npip install mleap\n```\n\n## 基本使用\n\nMLeap 的核心工作流分为两步：**训练与序列化**（在 Spark\u002FSklearn 环境中） -> **加载与推理**（在轻量级 MLeap Runtime 中）。\n\n### 场景一：导出并运行 Spark 模型 (Scala)\n\n此示例展示如何创建一个简单的 Spark Pipeline，将其序列化，然后在无 Spark 依赖的环境中加载并执行预测。\n\n**1. 训练并序列化模型 (需在 Spark 环境中运行):**\n\n```scala\nimport ml.combust.bundle.BundleFile\nimport ml.combust.mleap.spark.SparkSupport._\nimport org.apache.spark.ml.Pipeline\nimport org.apache.spark.ml.bundle.SparkBundleContext\nimport org.apache.spark.ml.feature.{Binarizer, StringIndexer}\nimport org.apache.spark.sql._\nimport org.apache.spark.sql.functions._\nimport scala.util.Using\n\n\u002F\u002F 假设已有 spark session 和 dataframe\nval dataframe: DataFrame = spark.sqlContext.read.format(\"csv\")\n  .option(\"header\", true)\n  .load(\".\u002Fexamples\u002Fspark-demo.csv\")\n  .withColumn(\"test_double\", col(\"test_double\").cast(\"double\"))\n\n\u002F\u002F 定义转换器\nval stringIndexer = new StringIndexer()\n  .setInputCol(\"test_string\")\n  .setOutputCol(\"test_index\")\n\nval binarizer = new Binarizer()\n  .setThreshold(0.5)\n  .setInputCol(\"test_double\")\n  .setOutputCol(\"test_bin\")\n\n\u002F\u002F 构建并拟合 Pipeline\nval pipelineEstimator = new Pipeline()\n  .setStages(Array(stringIndexer, binarizer))\n\nval pipeline = pipelineEstimator.fit(dataframe)\n\n\u002F\u002F 序列化模型到本地文件 (zip 格式)\nval sbc = SparkBundleContext().withDataset(pipeline.transform(dataframe))\nUsing(BundleFile(\"jar:file:\u002Ftmp\u002Fsimple-spark-pipeline.zip\")) { bf =>\n  pipeline.writeBundle.save(bf)(sbc).get\n}\n```\n\n**2. 加载模型并执行推理 (仅需 MLeap Runtime，无需 Spark):**\n\n```scala\nimport ml.combust.bundle.BundleFile\nimport ml.combust.mleap.runtime.MleapSupport._\nimport ml.combust.mleap.runtime.frame.{DefaultLeapFrame, Row}\nimport ml.combust.mleap.core.types._\nimport scala.util.Using\n\n\u002F\u002F 加载之前保存的 Bundle\nval bundle = Using(BundleFile(\"jar:file:\u002Ftmp\u002Fsimple-spark-pipeline.zip\")) { bundleFile =>\n  bundleFile.loadMleapBundle().get\n}.opt.get\n\n\u002F\u002F 构造输入数据 (LeapFrame)\nval schema = StructType(StructField(\"test_string\", ScalarType.String),\n  StructField(\"test_double\", ScalarType.Double)).get\nval data = Seq(Row(\"hello\", 0.6), Row(\"MLeap\", 0.2))\nval frame = DefaultLeapFrame(schema, data)\n\n\u002F\u002F 执行转换\nval mleapPipeline = bundle.root\nval frame2 = mleapPipeline.transform(frame).get\nval data2 = frame2.dataset\n\n\u002F\u002F 获取结果\nprintln(s\"Row 1 Result: ${data2(0)}\") \nprintln(s\"Row 2 Result: ${data2(1)}\")\n```\n\n### 场景二：导出 Scikit-learn 模型 (Python)\n\nMLeap 同样支持将 Scikit-learn 管道序列化。\n\n```python\nimport pandas as pd\nfrom mleap.sklearn.pipeline import Pipeline\nfrom mleap.sklearn.preprocessing.data import FeatureExtractor, LabelEncoder, ReshapeArrayToN1\nfrom sklearn.preprocessing import OneHotEncoder\n\n# 准备数据\ndata = pd.DataFrame(['a', 'b', 'c'], columns=['col_a'])\ncategorical_features = ['col_a']\n\n# 构建预处理步骤\nfeature_extractor_tf = FeatureExtractor(input_scalars=categorical_features, \n                                         output_vector='imputed_features', \n                                         output_vector_items=categorical_features)\n\nlabel_encoder_tf = LabelEncoder(input_features=feature_extractor_tf.output_vector_items,\n                               output_features='{}_label_le'.format(categorical_features[0]))\n\nreshape_le_tf = ReshapeArrayToN1()\n\n# 配置 OneHotEncoder 以兼容 MLeap\none_hot_encoder_tf = OneHotEncoder(sparse=False)\none_hot_encoder_tf.mlinit(prior_tf=label_encoder_tf, \n                          output_features='{}_label_one_hot_encoded'.format(categorical_features[0]))\n\n# 组装 Pipeline\none_hot_encoder_pipeline_x0 = Pipeline([\n    (feature_extractor_tf.name, feature_extractor_tf),\n    (label_encoder_tf.name, label_encoder_tf),\n    (reshape_le_tf.name, reshape_le_tf),\n    (one_hot_encoder_tf.name, one_hot_encoder_tf)\n])\n\n# 初始化并拟合\none_hot_encoder_pipeline_x0.mlinit()\none_hot_encoder_pipeline_x0.fit_transform(data)\n\n# 序列化模型到本地目录\none_hot_encoder_pipeline_x0.serialize_to_bundle('\u002Ftmp', 'mleap-scikit-test-pipeline', init=True)\n```\n\n序列化后的模型文件夹可在 JVM 环境中通过 `BundleFile` 加载并使用，实现跨语言部署。","某电商公司的数据科学团队利用 Spark 构建了复杂的用户流失预测管道，急需将其部署到高频调用的实时推荐系统中。\n\n### 没有 mleap 时\n- **环境依赖沉重**：生产服务必须安装完整的 Spark 集群或庞大的 Python 科学计算库（如 numpy、pandas），导致容器镜像体积巨大且启动缓慢。\n- **推理延迟过高**：每次预测都需要初始化沉重的 Spark Context 或加载重型解释器，无法满足毫秒级的实时响应需求。\n- **运维一致性风险**：训练环境（Spark\u002FScikit-learn）与推理环境版本难以严格对齐，常因依赖冲突导致“训练正常但上线报错”的诡异问题。\n- **资源浪费严重**：为了运行简单的模型推理，不得不维持高配置的计算节点，造成昂贵的算力闲置与浪费。\n\n### 使用 mleap 后\n- **轻量级独立运行**：通过 mleap 将管道序列化为通用的 Bundle.ML 格式，仅需轻量级的 JVM 运行时即可执行，彻底摆脱对 Spark 和 Python 环境的依赖。\n- **毫秒级低延迟**：mleap 原生执行引擎直接加载序列化模型，去除了框架启动开销，将单次预测耗时从秒级降低至毫秒级。\n- **训练推理强一致**：利用 mleap 提供的奇偶性测试（parity tests），确保生产环境的推理结果与 Spark\u002FScikit-learn 训练结果完全一致，消除上线隐患。\n- **架构灵活解耦**：支持 JSON 或 Protobuf 等多种序列化格式，模型可轻松嵌入现有的微服务架构中，大幅降低基础设施维护成本。\n\nmleap 成功打通了从复杂大数据训练到高性能生产推理的“最后一公里”，让机器学习管道真正实现了便携、高效且一致的落地。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fcombust_mleap_dd9f181a.png","combust","Combust","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fcombust_275e0996.png","Deploy Machine Learning Pipelines Easily",null,"combust@combust.ml","www.combust.ml","https:\u002F\u002Fgithub.com\u002Fcombust",[85,89,93,97,101,104],{"name":86,"color":87,"percentage":88},"Scala","#c22d40",86.6,{"name":90,"color":91,"percentage":92},"Python","#3572A5",11.5,{"name":94,"color":95,"percentage":96},"Java","#b07219",1.6,{"name":98,"color":99,"percentage":100},"Makefile","#427819",0.1,{"name":102,"color":103,"percentage":100},"Shell","#89e051",{"name":105,"color":106,"percentage":100},"Dockerfile","#384d54",1536,316,"2026-04-02T08:34:11","Apache-2.0","未说明","不需要 GPU",{"notes":114,"python":115,"dependencies":116},"MLeap 是一个基于 JVM 的机器学习管道序列化和执行引擎，主要用于将 Spark ML 和 Scikit-learn 模型导出为便携格式并在无需原始框架依赖（如 SparkContext, sklearn 等）的环境下运行。核心执行引擎由 Scala 编写，支持 JSON 和 Protobuf 序列化格式。不同版本的 MLeap 对 Spark、Scala、Java 和 Python 的版本有严格对应关系，部署时需参考兼容性矩阵选择合适版本。","3.9 - 3.13 (对应 MLeap 0.24.0 版本)",[117,118,119,120,121,122,123,124],"Spark 4.0.1","Scala 2.13.16","Java 17","XGBoost 2.0.3","TensorFlow 2.10.1","Scikit-learn","Pandas","Numpy",[13,26,51],[127,128,129,130,131,132,133],"scikit-learn","spark","data-pipelines","transformers","tensorflow","scala","python","2026-03-27T02:49:30.150509","2026-04-06T05:18:02.588776",[137,142,147,151,156,161,166],{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},15687,"在 PySpark 中使用 MLeap 序列化模型时遇到 'JavaPackage object is not callable' 错误，如何解决？","该错误通常意味着 Spark JVM 环境中缺少必要的 MLeap JAR 包。请确保在启动 pyspark 时通过 --packages 参数正确引入了 mleap-spark 依赖，例如：`pyspark --packages ml.combust.mleap:mleap-spark_2.11:0.8.1`。如果是在 Databricks 或其他集群环境中，请检查集群库设置是否已包含对应的 MLeap jar 包。此外，确认代码中导入的是 `mleap.spark` 而非文档中可能过时的 `mleap.pyspark`。","https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fissues\u002F172",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},15688,"MLeap 是否支持 Python 3.8？","是的，MLeap 支持 Python 3.8。相关兼容性修复已经合并，建议查看项目最新的发布版本（Release Notes）或升级到较新的稳定版（如 0.19.0 及以上）以获得完整支持。如果在旧版本中遇到问题，请尝试升级 MLeap 包。","https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fissues\u002F842",{"id":148,"question_zh":149,"answer_zh":150,"source_url":141},15689,"调用 serializeToBundle 时出现 'AttributeError: NoneType object has no attribute _jdf' 错误是什么原因？","这是因为 `serializeToBundle` 方法在某些版本中需要一个非空的 Dataset（DataFrame）作为参数来推断 Schema 或执行验证。解决方法是在调用时传入一个数据集，即使是空数据集也可以。例如：`pipelineModel.serializeToBundle(\"jar:file:\u002Ftmp\u002Fmodel.zip\", predictions.limit(0))`。不要只传入路径，务必提供第二个参数 dataset。",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},15690,"在 AWS EMR 上使用 MLeap 遇到 'NoClassDefFoundError: resource.package$' 错误怎么办？","这通常是由于缺少必要的依赖库导致的。除了基础的 mleap-spark 包外，您可能需要手动添加以下依赖才能正常工作（特别是针对 Spark 2.3\u002F2.4 版本）：\n1. scala-arm_2.11-2.0\n2. spray-json_2.11-1.3.5\n3. protobuf-java-3.8.0\n请确保这些 jar 包存在于 Spark 的 classpath 中，或者通过 --packages 参数一并加载。","https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fissues\u002F343",{"id":157,"question_zh":158,"answer_zh":159,"source_url":160},15691,"编译或使用 MLeap 时遇到 'scala\u002FProduct$class' 相关的 NoClassDefFoundError 错误，如何解决？","这个错误通常表明 MLeap 的 `reference.conf` 配置文件未被正确包含在最终的构建包中。如果您使用 Maven 或 SBT 进行构建，需要配置资源合并策略（merge strategy），确保 `reference.conf` 文件被追加（append）而不是覆盖。在 SBT 中，可以在 build.sbt 中添加相应的 mergeStrategy 设置来解决此问题。","https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fissues\u002F727",{"id":162,"question_zh":163,"answer_zh":164,"source_url":165},15692,"MLeap 是否支持 Scala 2.13？","截至当前讨论，MLeap 对 Scala 2.13 的支持受到第三方依赖（特别是 XGBoost）的限制。虽然社区有推进计划，但在相关依赖（如 XGBoost）完全支持 Scala 2.13 之前，MLeap 可能无法正式发布支持该版本的稳定版。建议暂时使用 Scala 2.12，或关注项目中关于 Spark 4.0 和 Scala 2.13 的最新 PR 进展。","https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fissues\u002F811",{"id":167,"question_zh":168,"answer_zh":169,"source_url":141},15693,"官方文档中关于 PySpark 的导入路径与实际代码不符，应该导入哪个模块？","官方文档中提到的 `import mleap.pyspark` 可能已过时或在某些版本目录结构中不存在。实际使用中，大多数用户成功使用的是 `import mleap.spark`。请尝试修改导入语句为：\n```python\nimport mleap.spark\nfrom mleap.spark.spark_support import SimpleSparkSerializer\n```\n并确保您的 Python 路径包含了安装后的 mleap 目录。",[171,176,181,186,191,196,201,206,211],{"id":172,"version":173,"summary_zh":174,"released_at":175},90367,"v0.24.0","## 变更内容\n* @austinzh 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F889 中添加了对 Python 3.7 至 3.12 的支持\n* @ltrottier-yelp 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F892 中将依赖升级至 Scala 2.13.16、Spark 4.0.1、Java 17 和 XGBoost 2.0.3\n* @Urvashi2303 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F887 中将依赖升级至 Scala 2.13.16、Spark 4.0.1、Java 17 和 XGBoost 2.0.3\n\n## 新贡献者\n* @Urvashi2303 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F887 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.23.3...v0.24.0","2026-03-10T14:17:41",{"id":177,"version":178,"summary_zh":179,"released_at":180},90368,"v0.23.4","## 变更内容\n* @austinzh 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F889 中添加了对 Python 3.7 至 3.12 的支持\n* 本次发布仅发布了 Python 包，因为 Scala 和 Java 没有变更\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.23.3...v0.23.4","2026-01-12T21:34:09",{"id":182,"version":183,"summary_zh":184,"released_at":185},90369,"v0.23.3","## 变更内容\n* 由 @austinzh 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F875 中添加了 MultiInOutTransformer\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.23.2...v0.23.3","2024-11-27T17:24:05",{"id":187,"version":188,"summary_zh":189,"released_at":190},90370,"v0.23.2","## 变更内容\n* 修复了 OneHotEncoderOp 在计算 categorySizes 时的一个问题，由 @ltrottier-yelp 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F873 中完成。\n\n## 新贡献者\n* @ltrottier-yelp 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F873 中完成了他们的首次贡献。\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.23.1...v0.23.2","2024-11-27T15:14:05",{"id":192,"version":193,"summary_zh":194,"released_at":195},90371,"v0.23.1","## 变更内容\n* @ronandoolan2 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F858 中添加了构建说明文档\n* @austinzh 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F816 中为 MleapReflection 添加了 setClassLoader 方法\n* @dotbg 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F864 中开展了使 mleap 兼容 Scala 2.13 的基础工作\n* @David-Fadida 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F866 中修复并添加了 ZIP 滑动漏洞验证\n* 在 \u002Fpython 目录下，@dependabot 将 urllib3 从 1.26.5 升级至 1.26.17，详见 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F868\n\n## 新贡献者\n* @ronandoolan2 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F858 中完成了首次贡献\n* @dotbg 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F864 中完成了首次贡献\n* @David-Fadida 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F866 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.23.0...v0.23.1","2023-11-14T16:59:33",{"id":197,"version":198,"summary_zh":199,"released_at":200},90372,"v0.23.0","## 变更内容\n* 升级至 XGBoost 1.7.3，并由 @harupy 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F847 中为 XGBoostClassificationModel 序列化目标函数\n* Mleap Runtime 对决策树模型使用错误的文件名进行序列化，由 @AllanaEvans 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F843 中修复\n* 允许将大小为 1 的张量转换为标量，由 @praj-0 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F850 中实现\n* 将 tensorflow-java 升级至 0.5.0，对应 TensorFlow 2.10.1，由 @jsleight 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F851 中完成\n* 升级至 Spark 3.4.0，由 @jsleight 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F852 中完成\n\n## 新贡献者\n* @harupy 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F847 中做出了首次贡献\n* @AllanaEvans 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F843 中做出了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.22.0...v0.23.0","2023-06-23T21:51:00",{"id":202,"version":203,"summary_zh":204,"released_at":205},90373,"v0.22.0","## 变更内容\n* 由 @praj-0 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F841 中实现：在 MathBinary 中仅允许使用输入或默认值之一\n* 由 @jsleight 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F836 中完成：将 Python 升级至 3.7\u002F3.8，并将 scikit-learn 升级至 v1.0.0\n* 由 @WeichenXu123 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F824 中完成：将 Spark 依赖升级至 3.3.0\n\n## 新贡献者\n* @praj-0 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F841 中完成了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.21.0...v0.22.0","2023-02-24T19:29:46",{"id":207,"version":208,"summary_zh":209,"released_at":210},90374,"v0.21.1","## 变更内容\n本次发布为 Spark 3.2 用户将修复程序后向移植到 Java 11 类路径中。\n* 修改 jvm_scala_object，以更好地处理嵌套的 Scala 类。由 @jsleight 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F837 中完成。\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.21.0...v0.21.1","2022-12-22T21:54:37",{"id":212,"version":213,"summary_zh":214,"released_at":215},90375,"v0.21.0","## 变更内容\n* 由 @WeichenXu123 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F812 中为 Databricks 的 Fat Jar 隔离 log4j\n* 由 @emitc2h 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F818 中升级 ScalaPB 和 sbt\n* 由 @WeichenXu123 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F822 中将 XGBoost 依赖升级至 1.6.1 版本\n* 由 @shyamsunder00 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F826 中添加了额外的数学一元运算\n* 由 @chaitanya-basava 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F829 中为 XGBoost 模型添加了向后兼容性修复\n* 由 @arthurarj 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F828 中解决了 MathBinary 使用零作为默认值时的问题\n\n## 新贡献者\n* @emitc2h 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F818 中做出了首次贡献\n* @shyamsunder00 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F826 中做出了首次贡献\n* @chaitanya-basava 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F829 中做出了首次贡献\n* @arthurarj 在 https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fpull\u002F828 中做出了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Fcombust\u002Fmleap\u002Fcompare\u002Fv0.20.0...v0.21.0","2022-12-16T21:38:19"]