当前位置:网站首页>OpenMLDB + Jupyter Notebook: Quickly Build Machine Learning Applications
OpenMLDB + Jupyter Notebook: Quickly Build Machine Learning Applications
2022-08-11 06:33:00 【Fourth Paradigm Developer Community】
OpenMLDB + Jupyter Notebook: Quickly Build Machine Learning Applications
1. Introduction
OpenMLDB is an open source machine learning database that provides a consistent production-grade feature platform both online and offline.Jupyter Notebook provides functions such as data calculation, code development, document editing, code execution, and result display based on browser web pages. It is one of the most popular and easy-to-use development environments.This article introduces the deep integration of OpenMLDB and Notebook, making full use of the powerful features of OpenMLDB and the convenience of Notebook to create a fast and easy-to-use machine learning development environment.
2. Integrated SQL Magic Functions
The first integration point between Notebook and OpenMLDB is the SQL magic function.Magic functions are an extension of Notebook. By registering magic functions, users can directly execute commands in Notebook cells without writing complex Python code, and can customize the output style.OpenMLDB provides a standard SQL magic function. Users can directly write and run SQL statements supported by OpenMLDB on Notebook, and the corresponding statement will be submitted to OpenMLDB for execution, and the results will be previewed and returned in Notebook.
2.1 Registering OpenMLDB SQL Magic Functions In order to support OpenMLDB magic functions in Notebook, you first need to register in the following way:
import openmldb db = openmldb.dbapi.connect('demo_db','0.0.0.0:2181','/openmldb') openmldb.sql_magic.register(db)
2.2 Execute a single-line SQL statement
Developers can use the prompt % to execute a single-line SQL statement, as shown in the following figure.
[image]
2.3 Execute multi-line SQL statements
Developers can also use the prompt %% to write multi-line SQL statements, as shown in the following figure.
[Picture]
Note that it is currently not supported to execute multiple SQL statements in a Notebook cell at the same time, and they need to be executed separately in different cells.
2.4 Magic Function Support Function
The SQL magic functions provided by OpenMLDB can execute all supported SQL syntaxes, including using OpenMLDB's unique offline mode to asynchronously submit complex SQL statements that need to process big data to the offline execution engine for execution, as shown in the following figure.
[Picture]
For details on how to use OpenMLDB magic functions, please refer to the introduction to Magic functions in the official OpenMLDB documentation https://openmldb.ai/docs/zh/main/quickstart/python_sdk.html#notebook-magic-function .
3. Notebook integration with OpenMLDB Python SDK
The second feature of the OpenMLDB and Notebook integration is the integration with the OpenMLDB Python SDK.Notebook supports Python to run the kernel, so various Python libraries can be imported through import. OpenMLDB provides a full-featured Python SDK for calling within Notebook.OpenMLDB not only provides a DBAPI based on the Python PEP249 standard, but also supports the mainstream SQLAlchemy interface in the Python industry. You can connect to an existing OpenMLDB cluster with just one line of code.
3.1 Using OpenMLDB DBAPI
It is very simple to use the DBAPI interface. For the cluster version, you only need to specify the ZooKeeper address and node path to connect. After the connection is successful, there will be corresponding log information; for the stand-alone version, you can use the IP and port as parameters to connect to the stand-alone version of OpenMLDB,As follows.
import openmldb.dbapi db = openmldb.dbapi.connect('demo_db','0.0.0.0:2181','/openmldb')
After the connection is successful, you can call the DBAPI interface of the OpenMLDB Python SDK in Notebook for development. For details, see https://openmldb.ai/docs/zh/main/quickstart/python_sdk.html#openmldb-dbapi.
3.2 Using OpenMLDB SQLAlchemy
If you want to use SQLAlchemy, it is also very simple. For the cluster version, you can complete the connection by specifying the URI of OpenMLDB through the SQLAlchemy library; you can also use the IP and port as parameters to connect to the stand-alone version of the OpenMLDB database, as shown below.
import sqlalchemy as db engine = db.create_engine('openmldb://demo_db?zk=127.0.0.1:2181&zkPath=/openmldb') connection = engine.connect()
After the connection is successful, you can develop through the SQLAlchemy interface of the OpenMLDB Python SDK. For details, see https://openmldb.ai/docs/zh/main/quickstart/python_sdk.html#openmldb-sqlalchemy.
4. References
- OpenMLDB Python SDK: https://openmldb.ai/docs/en/main/quickstart/python_sdk.html
- OpenMLDB usage documentation: https://openmldb.ai/docs/en/main/index.html
边栏推荐
猜你喜欢
Vscode远程连接服务器终端zsh+Oh-my-zsh + Powerlevel10 + Autosuggestions + Autojump + Syntax-highlighting
arduino的esp32环境搭建(不需要翻墙,不需要离线安装)
场景驱动的特征计算方式OpenMLDB,高效实现“现算先用”
OpenMLDB:线上线下一致的生产级特征计算平台
typescript学习日记,从基础到进阶(第二章)
咕咚vs悦跑圈的竞品分析
贡献者任务第三期精彩来袭
10 个超好用的 DataGrip 快捷键,快加入收藏! | 实用技巧
论文解读:GAN与检测网络多任务/SOD-MTGAN: Small Object Detection via Multi-Task Generative Adversarial Network
gerrit 配置SSH Key和账号、邮箱信息
随机推荐
C语言实现简易扫雷(附带源码)
STM32-中断优先级管理NVIC
如何快速转行做产品经理
【调试记录1】提高MC3172浮点运算能力,IQmath库的获取与导入使用教程
Ubuntu下安装mysql笔记
SearchGuard配置
Tinker接入全流程---编译篇
论文解读:GAN与检测网络多任务/SOD-MTGAN: Small Object Detection via Multi-Task Generative Adversarial Network
从概念认识AI
MSP430学习总结(二)——GPIO
自定义形状seekbar学习
珍爱网App竞品分析报告
推出 Space Marketplace 测试版 | 新发布
OpenMLDB:线上线下一致的生产级特征计算平台
vscode插件开发——懒人专用markdown插件开发
OpenMLDB Pulsar Connector:高效打通实时数据到特征工程
智能风控中台设计与落地
CMT2380F32模块开发6-flash例程
STM32F4-正点原子探索者-SYSTEM文件夹下的delay.c文件内延时函数详解
咕咚vs悦跑圈的竞品分析