Azure流分析:如何使用两个Azure机器学习功能

时间:2018-01-24 09:11:34

标签: tsql azure-stream-analytics

我在Stream Analytics中使用了两个Azure机器学习功能,但似乎每个查询只能使用一个。如何将其拆分为两个查询?

  

流式传输作业失败:Stream Analytics作业存在验证错误:子查询中使用的多个AML Web服务函数。查询步骤只能包含一个AML函数。请将步骤拆分为多个步骤。

WITH subquery as (
    SELECT
        id as id,
        deviceId as deviceId,
        username as username,
        try_cast(localtime as datetime) as localtime,
        AC as AC, FM as FM, UC as UC, 
        DL as DL, DS as DS, DP as DP,
        LB as LB, ASTV as ASTV, MSTV as MSTV,
        ALTV as ALTV, MLTV as MLTV, Width as Width,
        Min as Min, Max as Max, Nmax as Nmax,
        Nzeros as Nzeros, Mode as Mode, Mean as Mean,
        Median as Median, Variance as Variance, Tendency as Tendency,
        rms,fmed,fpeak,sample_entropy,
        EventProcessedUtcTime as EventProcessedUtcTime,
        Distress(AC,FM,UC,DL,DS,DP,1,LB,ASTV,MSTV,ALTV,MLTV,
            Width,Min,Max,Nmax,Nzeros,Mode,Mean,Median,Variance,
            Tendency,1,1,1,1,1,1,1,1,1,1,1,1) as resultFHR,
        Labour("",1,1,1,"",rms,fmed,fpeak,sample_entropy,"","") as resultUC
    FROM
        iot
    )

SELECT
    id as id,
    deviceId as deviceId,
    username as username,
    localtime as localtime,
    AC as AC, FM as FM, UC as UC, 
    DL as DL, DS as DS, DP as DP,
    LB as LB, ASTV as ASTV, MSTV as MSTV,
    ALTV as ALTV, MLTV as MLTV, Width as Width,
    Min as Min, Max as Max, Nmax as Nmax,
    Nzeros as Nzeros, Mode as Mode, Mean as Mean,
    Median as Median, Variance as Variance, Tendency as Tendency,
    EventProcessedUtcTime as EventProcessedUtcTime,
    resultFHR.[classes] as distress,
    resultFHR.[probabilities] as distressProbability,
    resultUC.[classes] as labour,
    resultUC.[probabilities] as labourProbability
INTO
    sql
FROM
    subquery


SELECT
    *
INTO
    c2d
FROM
    subquery 

1 个答案:

答案 0 :(得分:0)

您只需将其拆分为两个单独的步骤即可。例如:

WITH subquery1 as(SELECT id as id,deviceId as deviceId,username as local username,try_cast(localtime as datetime)as localtime,AC as AC,FM作为FM,UC作为UC,DL作为DL,DS作为DS,DP作为DP,LB作为LB,ASTV作为ASTV,MSTV作为MSTV,ALTV作为ALTV,MLTV作为MLTV,宽度作为宽度,Min作为Min,Max作为Max,Nmax作为Nmax,Nzeros作为Nzeros,模式作为模式,均值作为均值,中位数为中位数,方差为方差,趋势为趋势,rms,fmed,fpeak,sample_entropy,EventProcessedUtcTime为EventProcessedUtcTime,遇险(AC,FM,UC,DL,DS,DP,1,LB,ASTV,MSTV, ALTV,MLTV,宽度,最小值,最大值,Nmax,Nzeros,模式,平均值,中值,方差,趋势,1,1,1,1,1,1,1,1,1,1,1,1)作为结果FHR FROM iot)

WITH子查询为(SELECT id为id,deviceId为deviceId,用户名为username,try_cast(localtime as datetime)为localtime,AC为AC,FM为FM,UC为UC,DL为DL,DS为DS,DP作为DP,LB作为LB,ASTV作为ASTV,MSTV作为MSTV,ALTV作为ALTV,MLTV作为MLTV,宽度作为宽度,Min作为Min,Max作为Max,Nmax作为Nmax,Nzeros作为Nzeros,模式作为模式,均值作为均值,中位数为中位数,方差为方差,趋势为趋势,rms,fmed,fpeak,sample_entropy,EventProcessedUtcTime为EventProcessedUtcTime,人工(“”,1,1,1,“”,rms,fmed,fpeak,sample_entropy, “”,“”)作为结果UC FROM iot)

SELECT id为id,deviceId为deviceId,username为localtime,AC为AC,FM为FM,UC为UC,DL为DL,DS为DS,DP为DP,LB为LB,ASTV为ASTV,MSTV作为MSTV,ALTV作为ALTV,MLTV作为MLTV,宽度作为宽度,Min作为Min,Max作为最大,Nmax作为Nmax,Nzeros作为Nzeros,模式作为模式,均值作为平均值,中位数作为中值,方差作为方差,倾向为趋势,EventProcessedUtcTime为EventProcessedUtcTime, resultFHR。[classes] as distress,resultFHR。[概率] as distressProbability INTO sql FROM subquery1

SELECT id为id,deviceId为deviceId,username为localtime,AC为AC,FM为FM,UC为UC,DL为DL,DS为DS,DP为DP,LB为LB,ASTV为ASTV,MSTV作为MSTV,ALTV作为ALTV,MLTV作为MLTV,宽度作为宽度,Min作为Min,Max作为最大,Nmax作为Nmax,Nzeros作为Nzeros,模式作为模式,均值作为平均值,中位数作为中值,方差作为方差,趋势为趋势,EventProcessedUtcTime为EventProcessedUtcTime, resultUC。[classes]为labor,resultUC。[概率]为labourProbability INTO sql FROM subquery2