CREATE STREAM FROM ANALYZE¶
Syntax:
CREATE STREAM stream_name FROM ANALYZE input_stream
BY MODEL model_name USING method_name [ AS alias ]
Examples:
jubaql> CREATE STREAM clans FROM ANALYZE ds
BY MODEL cls USING classify AS clan
CREATE STREAM
jubaql> CREATE STREAM output FROM ANALYZE nbpds
BY MODEL reco USING complete_row_from_id
CREATE STREAM
Explanation¶
CREATE STREAM FROM ANALYZE uses the specified method to analyze each item in the input stream and defines a new stream that contains the input data and, in a new column, the analysis results.
stream_nameis a user-defined string that will identify this stream later on.input_streamis the stream to use as input. The data source that this stream is derived from must not yet be in process (or done with processing) when the statement is issued.model_nameis the name of a model previously defined usingCREATE MODEL. The items in the input stream will be converted as specified by the rules in theCREATE MODELstatement. (For the returned value to make any sense, that model should have also been trained using theUPDATE MODELstatement.)method_nameis the method to use for analyzing the model:calc_scorefor an ANOMALY model,classifyfor a CLASSIFIER model,complete_row_from_idorcomplete_row_from_datumfor a RECOMMENDER model.
aliasis the name of the column that will hold the analysis result. If it is not given,method_namewill be used.
After a CREATE STREAM FROM SELECT statement has been processed successfully, the user can use the specified stream_name in other statements.
Notes¶
- When using
complete_row_from_idwith theANALYZEstatement, the input value is directly taken asidvalue:ANALYZE '荻野貴司' BY MODEL reco USING complete_row_from_id. In contrast, when usingcomplete_row_from_idwithCREATE STREAM FROM ANALYZE, the value will be taken from theidcolumn as specified in theCREATE MODELstatement of that recommender model. - The results will be added as a structured type corresponding to each method’s return value:
doubleforcalc_score,array[struct{label: string, score: double}]forclassify,struct{string_values: map[string, string], num_values: map[string, double]}forcomplete_row_from_*.