### Install Dependencies Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.1/Explore Algorithms/Deep Learning/Quickstart - ONNX Model Inference.md Installs the necessary Python packages for the example. Ensure you have the specified versions. ```python %pip install lightgbm onnxmltools==1.7.0 ``` -------------------------------- ### VowpalWabbitFeaturizer Setup Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.5/Quick Examples/transformers/_VW.md This example demonstrates how to initialize and configure a VowpalWabbitFeaturizer in Python and Scala. ```APIDOC ## VowpalWabbitFeaturizer This example shows how to set parameters for the VowpalWabbitFeaturizer. ### Python Example ```python from synapse.ml.vw import * featurizer = ( VowpalWabbitFeaturizer() .setStringSplitInputCols(["in"]) .setPreserveOrderNumBits(2) .setNumBits(18) .setPrefixStringsWithColumnName(False) .setOutputCol("features") ) ``` ### Scala Example ```scala import com.microsoft.azure.synapse.ml.vw._ val featurizer = ( new VowpalWabbitFeaturizer() .setStringSplitInputCols(Array("in")) .setPreserveOrderNumBits(2) .setNumBits(18) .setPrefixStringsWithColumnName(false) .setOutputCol("features") ) ``` ``` -------------------------------- ### Install SynapseML on Databricks via DBC Archive Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.4/Get Started/Install SynapseML.md Import this Databricks archive to get started with SynapseML example notebooks. ```text https://mmlspark.blob.core.windows.net/dbcs/SynapseMLExamplesv1.0.4.dbc ``` -------------------------------- ### Run E2E Examples and Upload Notebooks Source: https://github.com/microsoft/synapseml/wiki/Release-Procedure Execute end-to-end examples, navigate to the target directory, and upload the resulting notebooks as a .dbc file to blob storage. ```bash ./runme TESTS=none ``` -------------------------------- ### Run SBT Setup Command Source: https://github.com/microsoft/synapseml/blob/master/docs/Reference/Developer Setup.md Execute the 'setup' command in SBT to compile the project and download necessary datasets. ```bash sbt setup ``` -------------------------------- ### Azure Databricks SynapseML Installation and Training Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.3/Reference/R Setup.md Installs SynapseML and performs a regression training example on Azure Databricks. This example uses ml_light_gbmregressor and ml_train_regressor. ```R install.packages("devtools") devtools::install_url("https://mmlspark.azureedge.net/rrr/synapseml-1.0.3.zip") library(sparklyr) library(dplyr) sc <- spark_connect(method = "databricks") faithful_df <- copy_to(sc, faithful) unfit_model = ml_light_gbmregressor(sc, maxDepth=20, featuresCol="waiting", labelCol="eruptions", numIterations=10, unfit.model=TRUE) ml_train_regressor(faithful_df, labelCol="eruptions", unfit_model) ``` -------------------------------- ### Start Local Development Server Source: https://github.com/microsoft/synapseml/blob/master/website/README.md Starts a local development server for live preview. Changes are reflected without restarting. ```bash yarn start ``` -------------------------------- ### Dataset and Setup Commands Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-0.11.4/Reference/Developer Setup.md Commands to download test datasets and perform a full project setup, combining compilation and dataset retrieval. ```bash sbt getDatasets ``` ```bash sbt setup ``` -------------------------------- ### Install Transformers Library Source: https://github.com/microsoft/synapseml/blob/master/docs/Explore Algorithms/Deep Learning/Quickstart - Apply Phi Model with HuggingFace CausalLM.ipynb Install the transformers library to use HuggingFace models. This is a prerequisite for the following code examples. ```python # %pip install --upgrade transformers==4.49.0 -q ``` -------------------------------- ### Spark Serving Hello World Example Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.11/Deploy Models/Overview.md Demonstrates a basic Spark Serving setup for a 'Hello World' style API. It loads data from a server, parses requests, processes them, and sends back replies. Ensure to replace 'file:///path/to/checkpoints' with a valid checkpoint location. ```python import synapse.ml import pyspark from pyspark.sql.functions import udf, col, length from pyspark.sql.types import * df = spark.readStream.server() \ .address("localhost", 8888, "my_api") \ .load() \ .parseRequest(StructType().add("foo", StringType()).add("bar", IntegerType())) replies = df.withColumn("fooLength", length(col("foo"))) .makeReply("fooLength") server = replies\ .writeStream \ .server() \ .replyTo("my_api") \ .queryName("my_query") \ .option("checkpointLocation", "file:///path/to/checkpoints") \ .start() ``` -------------------------------- ### Azure Databricks SynapseML Installation and Connection Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.9/Reference/R Setup.md Installs SynapseML and connects to a Spark context in Azure Databricks. This example uses spark_connect with method = "databricks". ```R install.packages("devtools") devtools::install_url("https://mmlspark.azureedge.net/rrr/synapseml-1.0.9.zip") library(sparklyr) library(dplyr) sc <- spark_connect(method = "databricks") faithful_df <- copy_to(sc, faithful) unfit_model = ml_light_gbmregressor(sc, maxDepth=20, featuresCol="waiting", labelCol="eruptions", numIterations=10, unfit.model=TRUE) ml_train_regressor(faithful_df, labelCol="eruptions", unfit_model) ``` -------------------------------- ### Spark Serving Hello World Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-0.11.4/Deploy Models/Overview.md A basic example demonstrating how to set up a Spark Serving web service. This snippet shows how to read incoming requests, process them with a simple transformation, and send back a reply. ```python import synapse.ml import pyspark from pyspark.sql.functions import udf, col, length from pyspark.sql.types import * df = spark.readStream.server() \ .address("localhost", 8888, "my_api") \ .load() \ .parseRequest(StructType().add("foo", StringType()).add("bar", IntegerType())) replies = df.withColumn("fooLength", length(col("foo"))) .makeReply("fooLength") server = replies .writeStream \ .server() \ .replyTo("my_api") \ .queryName("my_query") \ .option("checkpointLocation", "file:///path/to/checkpoints") \ .start() ``` -------------------------------- ### Spark Serving Hello World Source: https://github.com/microsoft/synapseml/blob/master/docs/Deploy Models/Overview.md A basic example demonstrating how to set up a Spark Serving web service. This snippet shows how to read from a server, parse incoming requests, transform the data, and send back a reply. ```python import synapse.ml import pyspark from pyspark.sql.functions import udf, col, length from pyspark.sql.types import * df = spark.readStream.server() \ .address("localhost", 8888, "my_api") \ .load() \ .parseRequest(StructType().add("foo", StringType()).add("bar", IntegerType())) replies = df.withColumn("fooLength", length(col("foo")))\ .makeReply("fooLength") server = replies\ .writeStream \ .server() \ .replyTo("my_api") \ .queryName("my_query") \ .option("checkpointLocation", "file:///path/to/checkpoints") \ .start() ``` -------------------------------- ### Install SynapseML on Azure Databricks Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.1.0/Reference/R Setup.md Installs SynapseML on Azure Databricks using a zip file and connects to the Databricks Spark environment. This example also demonstrates training a regression model. ```R install.packages("devtools") devtools::install_url("https://mmlspark.azureedge.net/rrr/synapseml-1.1.0.zip") library(sparklyr) library(dplyr) sc <- spark_connect(method = "databricks") faithful_df <- copy_to(sc, faithful) unfit_model = ml_light_gbmregressor(sc, maxDepth=20, featuresCol="waiting", labelCol="eruptions", numIterations=10, unfit.model=TRUE) ml_train_regressor(faithful_df, labelCol="eruptions", unfit_model) ``` -------------------------------- ### Install SynapseML on Azure Databricks Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.14/Reference/R Setup.md Installs SynapseML on Azure Databricks using devtools and spark_connect with method = "databricks". This example also includes training a regression model. ```R install.packages("devtools") devtools::install_url("https://mmlspark.azureedge.net/rrr/synapseml-1.0.14.zip") library(sparklyr) library(dplyr) sc <- spark_connect(method = "databricks") faithful_df <- copy_to(sc, faithful) unfit_model = ml_light_gbmregressor(sc, maxDepth=20, featuresCol="waiting", labelCol="eruptions", numIterations=10, unfit.model=TRUE) ml_train_regressor(faithful_df, labelCol="eruptions", unfit_model) ``` -------------------------------- ### SAR Recommendation Example in Scala Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-0.11.3/Quick Examples/estimators/core/_Recommendation.md This Scala code provides an equivalent implementation to the Python example for generating recommendations using SAR. It covers data setup, indexing, and the recommendation process with RankingAdapter. ```scala import com.microsoft.azure.synapse.ml.recommendation._ import spark.implicits._ val ratings = (Seq( ("11", "Movie 01", 2), ("11", "Movie 03", 1), ("11", "Movie 04", 5), ("11", "Movie 05", 3), ("11", "Movie 06", 4), ("11", "Movie 07", 1), ("11", "Movie 08", 5), ("11", "Movie 09", 3), ("22", "Movie 01", 4), ("22", "Movie 02", 5), ("22", "Movie 03", 1), ("22", "Movie 05", 3), ("22", "Movie 06", 3), ("22", "Movie 07", 5), ("22", "Movie 08", 1), ("22", "Movie 10", 3), ("33", "Movie 01", 4), ("33", "Movie 03", 1), ("33", "Movie 04", 5), ("33", "Movie 05", 3), ("33", "Movie 06", 4), ("33", "Movie 08", 1), ("33", "Movie 09", 5), ("33", "Movie 10", 3), ("44", "Movie 01", 4), ("44", "Movie 02", 5), ("44", "Movie 03", 1), ("44", "Movie 05", 3), ("44", "Movie 06", 4), ("44", "Movie 07", 5), ("44", "Movie 08", 1), ("44", "Movie 10", 3)) .toDF("customerIDOrg", "itemIDOrg", "rating") .dropDuplicates() .cache()) val recommendationIndexer = (new RecommendationIndexer() .setUserInputCol("customerIDOrg") .setUserOutputCol("customerID") .setItemInputCol("itemIDOrg") .setItemOutputCol("itemID") .setRatingCol("rating")) val algo = (new SAR() .setUserCol("customerID") .setItemCol("itemID") .setRatingCol("rating") .setTimeCol("timestamp") .setSupportThreshold(1) .setSimilarityFunction("jacccard") .setActivityTimeFormat("EEE MMM dd HH:mm:ss Z yyyy")) val adapter = (new RankingAdapter() .setK(5) .setRecommender(algo)) val res1 = recommendationIndexer.fit(ratings).transform(ratings).cache() adapter.fit(res1).transform(res1).show() ``` -------------------------------- ### Build SynapseML Docker Image with Example Version Source: https://github.com/microsoft/synapseml/blob/master/tools/docker/demo/README.md Example of building the Docker image for SynapseML version 1.1.3. ```bash docker build . --build-arg SYNAPSEML_VERSION=1.1.3 -f tools/docker/demo/Dockerfile -t synapseml:1.1.3 ``` -------------------------------- ### Install SynapseML using Spark Package Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.1.1/Get Started/Install SynapseML.md Install SynapseML on existing Spark clusters using the --packages option. This example shows usage for spark-shell, pyspark, and spark-submit, specifying version 1.1.1 for Spark 3.5. ```bash # Use 1.1.1 version for spark 3.5 and 1.0.15 version for Spark3.4 spark-shell --packages com.microsoft.azure:synapseml_2.12:1.1.1 pyspark --packages com.microsoft.azure:synapseml_2.12:1.1.1 spark-submit --packages com.microsoft.azure:synapseml_2.12:1.1.1 MyApp.jar ``` -------------------------------- ### Python Recommendation System Example Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.14/Quick Examples/estimators/core/_Recommendation.md Demonstrates how to use RecommendationIndexer to prepare data, ALS for training a recommendation model, RankingEvaluator for evaluation, RankingAdapter for applying the model, and RankingTrainValidationSplit for hyperparameter tuning. ```python from synapse.ml.recommendation import * from pyspark.ml.recommendation import ALS from pyspark.ml.tuning import * ratings = (spark.createDataFrame([ ("11", "Movie 01", 2), ("11", "Movie 03", 1), ("11", "Movie 04", 5), ("11", "Movie 05", 3), ("11", "Movie 06", 4), ("11", "Movie 07", 1), ("11", "Movie 08", 5), ("11", "Movie 09", 3), ("22", "Movie 01", 4), ("22", "Movie 02", 5), ("22", "Movie 03", 1), ("22", "Movie 05", 3), ("22", "Movie 06", 3), ("22", "Movie 07", 5), ("22", "Movie 08", 1), ("22", "Movie 10", 3), ("33", "Movie 01", 4), ("33", "Movie 03", 1), ("33", "Movie 04", 5), ("33", "Movie 05", 3), ("33", "Movie 06", 4), ("33", "Movie 08", 1), ("33", "Movie 09", 5), ("33", "Movie 10", 3), ("44", "Movie 01", 4), ("44", "Movie 02", 5), ("44", "Movie 03", 1), ("44", "Movie 05", 3), ("44", "Movie 06", 4), ("44", "Movie 07", 5), ("44", "Movie 08", 1), ("44", "Movie 10", 3) ], ["customerIDOrg", "itemIDOrg", "rating"]) .dropDuplicates() .cache()) recommendationIndexer = ( RecommendationIndexer() .setUserInputCol("customerIDOrg") .setUserOutputCol("customerID") .setItemInputCol("itemIDOrg") .setItemOutputCol("itemID") .setRatingCol("rating") ) transformedDf = (recommendationIndexer.fit(ratings) .transform(ratings).cache()) als = ( ALS() .setNumUserBlocks(1) .setNumItemBlocks(1) .setUserCol("customerID") .setItemCol("itemID") .setRatingCol("rating") .setSeed(0) ) evaluator = ( RankingEvaluator() .setK(3) .setNItems(10) ) adapter = ( RankingAdapter() .setK(evaluator.getK()) .setRecommender(als) ) adapter.fit(transformedDf).transform(transformedDf).show() paramGrid = (ParamGridBuilder() .addGrid(als.regParam, [1.0]) .build()) tvRecommendationSplit = ( RankingTrainValidationSplit() .setEstimator(als) .setEvaluator(evaluator) .setEstimatorParamMaps(paramGrid) .setTrainRatio(0.8) .setUserCol(recommendationIndexer.getUserOutputCol()) .setItemCol(recommendationIndexer.getItemOutputCol()) .setRatingCol("rating") ) tvRecommendationSplit.fit(transformedDf).transform(transformedDf).show() ``` -------------------------------- ### CustomInputParser Setup Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.12/Quick Examples/transformers/core/_IO.md Configure CustomInputParser for custom input processing. The Scala example demonstrates setting a UDF for more complex transformations. ```python from synapse.ml.io.http import * cip = ( CustomInputParser() .setInputCol("data") .setOutputCol("out")) ``` ```scala import com.microsoft.azure.synapse.ml.io.http._ val cip = (new CustomInputParser() .setInputCol("data") .setOutputCol("out") .setUDF({ x: Int => new HttpPost(s"http://$x") })) ``` -------------------------------- ### DictionaryExamples Example Source: https://github.com/microsoft/synapseml/blob/master/docs/Quick Examples/transformers/cognitive/_Translator.md Retrieves dictionary examples for a given text and its translation. Requires setting subscription key, location, and languages. ```Python from synapse.ml.services import * translatorKey = os.environ.get("TRANSLATOR_KEY", getSecret("translator-key")) df = ( spark.createDataFrame([ ("fly", "volar") ], ["text", "translation"]) .withColumn("textAndTranslation", array(struct(col("text"), col("translation")))) ) dictionaryExamples = ( DictionaryExamples() .setSubscriptionKey(translatorKey) .setLocation("eastus") .setFromLanguage("en") .setToLanguage("es") .setTextAndTranslationCol("textAndTranslation") .setOutputCol("result") ) (dictionaryExamples .transform(df) .withColumn("examples", flatten(col("result.examples"))) .select("examples")).show() ``` -------------------------------- ### Azure Databricks SynapseML Setup and Training Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-0.11.3/Reference/R Setup.md Installs SynapseML on Azure Databricks, connects to the Databricks Spark instance, and demonstrates training a LightGBM regressor. ```r install.packages("devtools") devtools::install_url("https://mmlspark.azureedge.net/rrr/synapseml-0.11.3.zip") library(sparklyr) library(dplyr) sc <- spark_connect(method = "databricks") faithful_df <- copy_to(sc, faithful) unfit_model = ml_light_gbmregressor(sc, maxDepth=20, featuresCol="waiting", labelCol="eruptions", numIterations=10, unfit.model=TRUE) ml_train_regressor(faithful_df, labelCol="eruptions", unfit_model) ``` -------------------------------- ### SBT Build and Publishing Commands Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.10/Reference/Developer Setup.md Commands for building the SynapseML library and publishing artifacts. 'setup' combines compilation and dataset download, 'package' creates a JAR, and various 'publish' commands deploy artifacts. ```bash sbt setup ``` ```bash sbt package ``` ```bash sbt publishBlob ``` ```bash sbt publishLocal ``` ```bash sbt publishDocs ``` ```bash sbt publishSigned ``` ```bash sbt sonatypeRelease ``` -------------------------------- ### Text Sentiment Analysis Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-0.11.3/Quick Examples/transformers/cognitive/_TextAnalytics.md This example shows how to perform sentiment analysis on text data to determine the emotional tone. It includes setup for both Python and Scala. ```APIDOC ## Text Sentiment Analysis ### Description Analyzes the sentiment of text, classifying it as positive, negative, or neutral. ### Method `TextSentiment()` ### Parameters - `subscriptionKey` (string): Your Azure Cognitive Services subscription key. - `location` (string): The Azure region where your Cognitive Services resource is deployed. - `textCol` (string): The name of the column containing the text to analyze. - `outputCol` (string): The name of the output column for sentiment results. - `errorCol` (string): The name of the column for error information. - `languageCol` (string): The name of the column specifying the language of the text. - `modelVersion` (string): Specifies the version of the sentiment analysis model to use (e.g., "latest"). - `showStats` (boolean): If true, displays statistics about the analysis. ### Request Example (Python) ```python from synapse.ml.cognitive import TextSentiment textKey = os.environ.get("COGNITIVE_API_KEY", getSecret("cognitive-api-key")) df = spark.createDataFrame([ ("I am so happy today, its sunny!", "en-US"), ("I am frustrated by this rush hour traffic", "en-US"), ("The cognitive services on spark aint bad", "en-US"), ], ["text", "language"]) sentiment = (TextSentiment() .setSubscriptionKey(textKey) .setLocation("eastus") .setTextCol("text") .setOutputCol("sentiment") .setErrorCol("error") .setLanguageCol("language")) sentiment.transform(df).show() ``` ### Request Example (Scala) ```scala import com.microsoft.azure.synapse.ml.cognitive.text.TextSentiment val textKey = sys.env.getOrElse("COGNITIVE_API_KEY", None) val df = Seq( ("en", "Hello world. This is some input text that I love."), ("fr", "Bonjour tout le monde"), ("es", "La carretera estaba atascada. Había mucho tráfico el día de ayer."), (null, "ich bin ein berliner"), (null, null), ("en", null) ).toDF("lang", "text") val sentiment = (new TextSentiment() .setSubscriptionKey(textKey) .setLocation("eastus") .setLanguageCol("lang") .setModelVersion("latest") .setShowStats(true) .setOutputCol("replies")) sentiment.transform(df).show() ``` ``` -------------------------------- ### DictionaryExamples Example Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-0.11.4/Quick Examples/transformers/cognitive/_Translator.md Retrieves dictionary examples for a given word and its translation. Ensure your TRANSLATOR_KEY environment variable is set. ```python from synapse.ml.cognitive import * translatorKey = os.environ.get("TRANSLATOR_KEY", getSecret("translator-key")) df = ( spark.createDataFrame([ ("fly", "volar") ], ["text", "translation"]) .withColumn("textAndTranslation", array(struct(col("text"), col("translation")))) ) dictionaryExamples = ( DictionaryExamples() .setSubscriptionKey(translatorKey) .setLocation("eastus") .setFromLanguage("en") .setToLanguage("es") .setTextAndTranslationCol("textAndTranslation") .setOutputCol("result") ) (dictionaryExamples .transform(df) .withColumn("examples", flatten(col("result.examples"))) .select("examples")).show() ``` ```scala import com.microsoft.azure.synapse.ml.cognitive.translate.{DictionaryExamples, TextAndTranslation} import spark.implicits._ import org.apache.spark.sql.functions.{col, flatten} val translatorKey = sys.env.getOrElse("TRANSLATOR_KEY", None) val df = Seq(List(TextAndTranslation("fly", "volar"))).toDF("textAndTranslation") val dictionaryExamples = ( new DictionaryExamples() .setSubscriptionKey(translatorKey) .setLocation("eastus") .setFromLanguage("en") .setToLanguage("es") .setTextAndTranslationCol("textAndTranslation") .setOutputCol("result") ) (dictionaryExamples .transform(df) .withColumn("examples", flatten(col("result.examples"))) .select("examples")).show() ``` -------------------------------- ### Run SynapseML Docker Image Source: https://github.com/microsoft/synapseml/blob/master/docs/Reference/Docker Setup.md Installs the SynapseML image and runs it, exposing port 8888 for the Jupyter interface. Accept the EULA in your browser after starting. ```bash docker run -it -p 8888:8888 mcr.microsoft.com/mmlspark/release ``` -------------------------------- ### VectorLIME Scala Example Source: https://github.com/microsoft/synapseml/blob/master/docs/Quick Examples/transformers/core/_Explainers.md Illustrates the setup of VectorLIME in Scala, including generating synthetic data and fitting a LinearRegression model. It configures the explainer with the model and data. ```scala import com.microsoft.azure.synapse.ml.explainers._ import spark.implicits._ import breeze.linalg.{*, DenseMatrix => BDM} import breeze.stats.distributions.Rand import org.apache.spark.ml.linalg.Vectors import org.apache.spark.ml.regression.LinearRegression val d1 = 3 val d2 = 1 val coefficients: BDM[Double] = new BDM(d1, d2, Array(1.0, -1.0, 2.0)) val df = { val nRows = 100 val intercept: Double = math.random() val x: BDM[Double] = BDM.rand(nRows, d1, Rand.gaussian) val y = x * coefficients + intercept val xRows = x(*, ::).iterator.toSeq.map(dv => Vectors.dense(dv.toArray)) val yRows = y(*, ::).iterator.toSeq.map(dv => dv(0)) xRows.zip(yRows).toDF("features", "label") } val model: LinearRegressionModel = new LinearRegression().fit(df) val lime = (new VectorLIME() .setModel(model) .setBackgroundData(df) .setInputCol("features") .setTargetCol(model.getPredictionCol) .setOutputCol("weights") .setNumSamples(1000)) ``` -------------------------------- ### VectorZipper Example in Python Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-0.11.3/Quick Examples/transformers/_VW.md Demonstrates how to use VowpalWabbitFeaturizer to create sequences and then combine them using VectorZipper. Ensure SparkSession is initialized. ```python from synapse.ml.vw import * df = spark.createDataFrame([ ("action1_f", "action2_f"), ("action1_f", "action2_f"), ("action1_f", "action2_f"), ("action1_f", "action2_f") ], ["action1", "action2"]) actionOneFeaturizer = (VowpalWabbitFeaturizer() .setInputCols(["action1"]) .setOutputCol("sequence_one")) actionTwoFeaturizer = (VowpalWabbitFeaturizer() .setInputCols(["action2"]) .setOutputCol("sequence_two")) seqDF = actionTwoFeaturizer.transform(actionOneFeaturizer.transform(df)) vectorZipper = ( VectorZipper() .setInputCols(["sequence_one", "sequence_two"]) .setOutputCol("out")) vectorZipper.transform(seqDF).show() ``` -------------------------------- ### FindSimilarFace Source: https://github.com/microsoft/synapseml/blob/master/website/versioned_docs/version-1.0.14/Quick Examples/transformers/cognitive/_Face.md Finds faces similar to a given face. This example first detects faces to get face IDs, then uses those IDs to find similar faces. ```APIDOC ## FindSimilarFace ### Description Finds faces that are similar to a given target face from a list of candidate faces. ### Method Not applicable (SDK method) ### Endpoint Not applicable (SDK method) ### Parameters - **subscriptionKey** (string) - Required - The subscription key for the Azure Face API. - **location** (string) - Required - The location of the Azure Face API service. - **faceIdCol** (string) - Required - The name of the column containing the face ID to find similar faces for. - **faceIds** (list of strings) - Required - A list of face IDs to compare against. - **outputCol** (string) - Required - The name of the output column for similar face results. ### Request Example ```python findSimilar = ( FindSimilarFace() .setSubscriptionKey(cognitiveKey) .setLocation("eastus") .setOutputCol("similar") .setFaceIdCol("id") .setFaceIds(faceIds) ) ``` ### Response #### Success Response - **similar** (array) - An array of similar face results, each containing a list of similar faces with confidence scores. ```