#Python

0 关注者 · 53 帖子

Python 是一种用于通用编程的解释性高级编程语言。Python 由 Guido van Rossum 创建并于 1991 年首次发布,其设计理念强调代码的可读性,特别是使用大量的空白

官方网站

InterSystems Python 绑定

文章 Michael Lei · 七月 29, 2022 3m read

在这篇文章中,我试图找出多个领域来开发我们能够使用python和机器学习的功能。

每家医院都在努力利用技术和服务来提高其服务质量和效率。

医疗保健部门是一个非常大的、可供选择的服务领域,而python是做机器学习的最好技术之一。

在每个医院里,人们都会有一些感觉,如果这种感觉能够被计算机理解,使用技术就有机会提供更好的服务。

在这里,我们可以把这两者结合起来,在医疗部门,我正试图理解/识别各种选择,以提供更好的服务。

首先,我们可以尝试使用python的机器学习来识别人并了解他们目前的感受。比如,在医院信息系统中,每个病人至少有一张照片,使用该照片我们可以识别病人,然后一旦病人到达医院,使用视频监控和机器学习技术需要识别这个人的感觉。

在医院设施中会看到多种类型的感觉。

1)紧张

2)平静和冷静

3)   哭泣

4)  暴力的病人/亲属

5)  生病的病人

6)  高烧鉴定

像上面的情况,我们可以看到多种不同的类型。

如果一个已经登记的病人发高烧,那么使用闭路电视识别这个病人的情况,并捕捉温度热像仪,护理人员可以给予更好的支持,这在接待服务领域是非常大的区别。

如果这个发高烧的人已经是一个登记的病人,如果利用现有的照片识别这个病人,那么我们可以做多件事情。

1)如果该病人今天有预约,我们可以自动到达该病人处。

0
0 150
文章 Lilian Huang · 七月 13, 2022 5m read

InterSystems Native SDK for Python InterSystems IRIS APIs 的轻量级接口,曾经只能通过 ObjectScript 使用。

准确地说,我对调用 ObjectScript 方法、类方法的能力特别感兴趣。它可以工作,而且效果很好,但默认情况下,调用只支持标量参数:字符串、布尔值、整数和浮点数。

但如果你想:

- 传递或返回结构,例如字典或列表

- 传递或返回流

您需要编写一些粘合代码或使用这个project (使用 pip install edpy 安装)。 edpy 包会给你一个简单的签名:

call(iris, class_name, method_name, args)

它允许您调用任何 ObjectScript 方法并返回结果。

像这样导入它:

from edpy import iris

call accepts 4 required arguments:
iris - a reference to an established IRIS object
class_name - IRIS class to call
method_name - IRIS method to call
args - list of 0 or more arguments

参数

每个参数可以是以下其中之一:

0
0 367
文章 Frank Ma · 六月 13, 2022 2m read

这是一个在InterSystems IRIS中用python和objectscript建立的对比测试。

测试目的是比较在python和objectscript中从BP到BO来回发送一千条请求/消息的速度。

更多信息,请访问 https://github.com/LucasEnard/benchmark-python-objectscript

重要提示 : 这里用的是python, graph objectscipt和objectscript从一个BP到一个BO来回发送1000条消息的时间,单位是秒。

字符串信息是由十个字符串变量组成。

对象信息由十个对象变量组成,每个对象都是它自己的int、float、str和List(str)。

消息字符串1000条消息来回的时间 (秒)
Python BP1.8
BPL1.8
ObjectScript1.4
消息对象1000条消息来回的时间 (秒)
Python BP3.2
BPL2.1
ObjectScript1.8

行中函数的时间是列中函数的x倍 :

消息字符串PythonBPLObjectScript
Python111.3
BPL111.3
ObjectScript0.760.761
0
0 106
公告 Jeff Liu · 五月 15, 2022

嗨,开发者们!  

看看你如何用PyODBC和Native API在Python中开发并连接到InterSystems IRIS®数据平台。 

⏯ Using Python to Connect to InterSystems IRIS

<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" scrolling="no" src="//player.bilibili.com/player.html?aid=684120686&bvid=BV1zU4y1m7h7&cid=718939082&page=1" width="560"></iframe>

0
0 124
文章 Michael Lei · 四月 13, 2022 7m read

image

这篇文章是对我的  iris-globals-graphDB 应用的介绍。
在这篇文章中,我将演示如何在Python Flask Web 框架和PYVIS交互式网络可视化库的帮助下,将图形数据保存和抽取到InterSystems Globals中。

建议

第一步 : 通过使用Python 原生SDK建立与IRIS Globals的链接

 #create and establish connection
  if not self.iris_connection:
         self.iris_connection = irisnative.createConnection("localhost", 1972, "USER", "superuser", "SYS")
                                     
  # Create an iris object
  self.iris_native = irisnative.createIris(self.iris_connection)
  return self.iris_native

 

第二步 : 使用 iris_native.set( ) 功能把数据保存到Globals 里     

#import nodes data from csv file
isdefined = self.iris_native.isDefined("^g1nodes")
if isdefined == 0:
    with open("/opt/irisapp/misc/g1nodes.csv", newline='') as csvfile:

reader = csv.DictReader(csvfile) for row in reader: self.iris_native.set(row["name"], "^g1nodes", row["id"])

#import edges data from csv file isdefined = self.iris_native.isDefined("^g1edges") if isdefined == 0: with open("/opt/irisapp/misc/g1edges.csv", newline='') as csvfile: reader = csv.DictReader(csvfile) counter = 0                 for row in reader: counter = counter + 1 #Save data to globals self.iris_native.set(row["source"]+'-'+row["target"], "^g1edges", counter)  

第三步: 使用iris_native.get() 功能把节点和边缘数据从Globals传递给PYVIS

 #Get nodes data for basic graph    
  def get_g1nodes(self):
        iris = self.get_iris_native()
        leverl1_subscript_iter = iris.iterator("^g1nodes")
        result = []
        # Iterate over all nodes forwards
        for level1_subscript, level1_value in leverl1_subscript_iter:
            #Get data from globals
            val = iris.get("^g1nodes",level1_subscript)
            element = {"id": level1_subscript, "label": val, "shape":"circle"}
            result.append(element)            
        return result

    #Get edges data for basic graph       def get_g1edges(self):         iris = self.get_iris_native()         leverl1_subscript_iter = iris.iterator("^g1edges")         result = []         # Iterate over all nodes forwards         for level1_subscript, level1_value in leverl1_subscript_iter: #Get data from globals             val = iris.get("^g1edges",level1_subscript)             element = {"from": int(val.rpartition('-')[0]), "to": int(val.rpartition('-')[2])}             result.append(element)                     return result

 

Step4: Use PYVIS Javascript to generate graph data

<script type="text/javascript">
    // initialize global variables.
    var edges;
    var nodes;
    var network;
    var container;
    var options, data;
  
    // This method is responsible for drawing the graph, returns the drawn network
    function drawGraph() {
        var container = document.getElementById('mynetwork');
        let node = JSON.parse('{{ nodes | tojson }}');
        let edge = JSON.parse('{{ edges | tojson }}');
     
        // parsing and collecting nodes and edges from the python
        nodes = new vis.DataSet(node);
        edges = new vis.DataSet(edge);

        // adding nodes and edges to the graph         data = {nodes: nodes, edges: edges};

        var options = {           "configure": {                 "enabled": true,                 "filter": [                 "physics","nodes"             ]             },             "nodes": {                 "color": {                   "border": "rgba(233,180,56,1)",                   "background": "rgba(252,175,41,1)",                   "highlight": {                     "border": "rgba(38,137,233,1)",                     "background": "rgba(40,138,255,1)"                   },                   "hover": {                   "border": "rgba(42,127,233,1)",                     "background": "rgba(42,126,255,1)"                 }                 },

                "font": {                   "color": "rgba(255,255,255,1)"                 }               },             "edges": {                 "color": {                     "inherit": true                 },                 "smooth": {                     "enabled": false,                     "type": "continuous"                 }             },             "interaction": {               "dragNodes": true,                 "hideEdgesOnDrag": false,               "hideNodesOnDrag": false,                 "navigationButtons": true,                 "hover": true             },

            "physics": {                 "barnesHut": {                     "avoidOverlap": 0,                   "centralGravity": 0.3,                   "damping": 0.09,                     "gravitationalConstant": -80000,                     "springConstant": 0.001,                     "springLength": 250                 },

                "enabled": true,                 "stabilization": {                     "enabled": true,                     "fit": true,                     "iterations": 1000,                     "onlyDynamicEdges": false,                     "updateInterval": 50                 }             }         }         // if this network requires displaying the configure window,         // put it in its div         options.configure["container"] = document.getElementById("config");         network = new vis.Network(container, data, options);       return network;     }     drawGraph(); </script>

 

第五步: 从app.py 主文件调用上面的代码

#Mian route. (index)
@app.route("/")
def index():
    #Establish connection and import data to globals
    irisglobal = IRISGLOBAL()
    irisglobal.import_g1_nodes_edges()
    irisglobal.import_g2_nodes_edges()

    #getting nodes data from globals     nodes = irisglobal.get_g1nodes()     #getting edges data from globals     edges = irisglobal.get_g1edges()

    #To display graph with configuration     pyvis = True     return render_template('index.html', nodes = nodes,edges=edges,pyvis=pyvis)    

下面是关于此项目的 介绍视频:

<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" scrolling="no" src="//player.bilibili.com/player.html?aid=256588464&bvid=BV1LY411w7MU&cid=718938724&page=1" width="560"></iframe>

0
0 258
文章 Frank Ma · 三月 2, 2022 2m read

我们很高兴与你分享有趣的信息,以及告诉你为什么Python是好的,它被用在哪里。

其中使用最多的库是NumPy和Pandas。NumPy(Numerical Python)用来对大型数据集进行分类。它简化了数组上的数学运算及其矢量化。Pandas提供两种数据结构:系列Series(一个元素列表)和数据框架DataFrames(一个有多列的表格)。这个库将数据转换为数据框架,允许你删除和添加新的列,以及执行各种操作。

Python为数据分析项目提供了无数的工具,可以帮助完成任何任务。

0
0 305
公告 Michael Lei · 二月 5, 2022

听IRIS 专家聊IRIS,学技术,练英语听力,尽在Intersystems 系联在线培训广播电台
 https://datapoints.intersystems.com.

21. Embedded Python — Released February 3, 2022

20. The InterSystems Kubernetes Operator — Released July 27, 2021 [Transcript available]

19. What's New in Version 2021.1 of InterSystems IRIS? — Released June 3, 2021

18. The InterSystems IRIS® FHIR® Accelerator Service — Released May 5, 2021

17. The Analytics & AI Landscape — Released April 6, 2021

16. A Cloud DBMS Visionary — Released January 27, 2021

15. Writing ObjectScript in VS Code — Released November 17, 2020

0
0 107
公告 Jeff Liu · 一月 17, 2022

Hi 开发者们, 

New video is already on InterSystems Developers YouTube

⏯ Embedded Python for ObjectScript Developers: Working with Python and ObjectScript Side-By-Side

<iframe src="//player.bilibili.com/player.html?aid=892887041&bvid=BV1fP4y177XF&cid=478516671&page=1" width="400" height="300" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

1
0 138
文章 Michael Lei · 十二月 16, 2021 10m read

Iris-python-template

包含各种Python代码的项目模版,可用于InterSystems IRIS 社区容器版Community Edition with container。

特性 :

  • Notebooks 记事本
    • Embedded Python 内核
    • ObjectScript 内核
    • Vanilla Python 内核
  • Embedded嵌入式 Python
    • Code example代码样例
    • Flask demo
  • IRIS Python Native 原生APIs
    • Code example

2. 目录

0
0 326
文章 Johnny Wang · 十二月 12, 2021 3m read

    您可能已经听说,我们目前正在为所有正在使用 Caché 和 Ensemble 的客户提供限时免费迁移到我们的下一代数据平台 InterSystems IRIS 的机会。

    虽然我们依旧如往常一样全力支持那些正在使用 Caché 数据库和 Ensemble 集成引擎的客户,但我们还是认为 InterSystems IRIS 是未来的关键。它结合了 Caché 和 Ensemble 的所有功能,并添加了大量令人兴奋的强大功能,从机器学习到原生 Python。

    这也正是我们为现有客户提供迁移到 InterSystems IRIS 并使用这些新功能的原因。 我们也通过就地迁移支持轻松迁移,这意味着无需数据库转换、分步迁移指南、教程等。

    听起来挺有趣对吗? 以下是我针对当前 Caché 和 Ensemble 应迁移到 InterSystems IRIS 的五个主要原因。

0
0 310
文章 Michael Lei · 七月 6, 2021 2m read

如果一张图片胜过千言万语,那么一段视频又价值几何? 当然胜过敲一个帖子。

请在 InterSystems Developers YouTube 观看我的“Coding talks”:

1. 使用 Yape 分析 InterSystems IRIS 系统性能。 第 1 部分:安装 Yape

在容器中运行 Yape。

2. Yape 容器 SQLite iostat InterSystems

提取和绘制 pButtons 数据,包括时间范围和 iostat。

0
0 151
文章 Michael Lei · 五月 8, 2021 8m read

关键字:Python,JDBC,SQL,IRIS,Jupyter Notebook,Pandas,Numpy ,机器学习 

1. 目的

这是一个用于演示的 5 分钟快速笔记,通过 Jupyter Notebook 中的 Python 3 调用 IRIS JDBC 驱动程序,以经由 SQL 语法从 IRIS 数据库实例读取数据和向 IRIS 数据库实例写入数据。 

去年,我发表了关于将 Python 绑定到 Cache 数据库的简要笔记(第 4.7 节)。 如何使用 Python 挂入 IRIS 数据库以将其数据读入 Pandas 数据框和 NumPy 数组进行常规分析,然后再将一些经过预处理或标准化的数据写回 IRIS 中,准备进一步用于 ML/DL 管道,现在可能是时候回顾一些选项和讨论了。

一些立即浮现的快速选项

  1.    ODBC:Python 3 和原生 SQL 的 PyODBC?
  2.    JDBC:Pyhton 3 和原生 SQL 的 JayDeBeApi?
  3.    Spark:PySpark 和 SQL?
  4.    Python Native API for IRIS:超越先前的 Python Binding for Cache?
  5.   ** IPtyhon Magic SQL %%sql**?  可以支持 IRIS 了吗?

 这里有漏掉其他选项吗?  我有兴趣尝试任何选项。 

2. 范围 

0
0 416
文章 Hao Ma · 三月 26, 2021 4m read

使用 IRIS 和 Python 创建聊天机器人

本文将展示如何把 InterSystems IRIS 数据库与 Python 集成,以服务于自然语言处理 (NLP) 的机器学习模型。

为什么选择 Python?

随着在世界范围内的广泛采用和使用,Python 拥有了出色的社区,以及许多加速器 | 库用于部署任何类型的应用。 如果您感兴趣,请访问 https://www.python.org/about/apps/

Iris Globals

我接触到 ^globals 后很快就熟悉了,它们可以用作快速获取现成数据模型中数据的方法。 因此,首先,我将使用 ^globals 存储训练数据和对话以记录聊天机器人的行为。

自然语言处理

自然语言处理或 NLP 是 AI 的一个主题,它创造了机器从我们的语言阅读、理解含义的能力。 显然,这并不简单,但是我将展示如何在这个广阔而美丽的领域中迈出您的第一步。

演示 - 来试试吧

我在这里部署了 Chatbot 应用作为演示: http://iris-python-suite.eastus.cloudapp.azure.com:8080

工作原理

机器学习

首先要知道与普通软件开发相比,机器学习具有不同的范式。 很难理解的要点是机器学习模型的开发周期。

浅显解释预警

一个标准的应用开发周期大概是这样:

开发代码 -> 测试(使用开发数据)-> 部署(真实用户数据)

0
0 395
文章 Louis Lu · 一月 8, 2021 3m read

在本篇短文中,我们将讨论如何让 Yape 在 docker 容器中运行,从而避免在本地计算机上安装设置 python。

距离本系列的上一篇文章已经有一段时间了,让我们快速回顾一下。

我们讨论了使用 matplotlib 创建基本图形。 之后我们介绍了使用 bokeh 生成动态图形。 在第三部分中,我们讨论了使用 monlbl 数据生成热图

在通过各种渠道获得的反馈中,有一个相同的难题是设置一个环境来运行上面的例子。 所以我们决定让实现变得更容易一些,我与 Murray 合作为他的优秀工具 Yape 创建了一个 Dockerfile。 Github 页面

当然,您必须在您的计算机上安装并运行 docker

Dockerfile

一个相当简单的基于官方 python 映像的 docker 定义:

FROM python:3

WORKDIR .

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

源码

Requirements.txt 包含运行 yape 所需的包:

0
0 173