/// <summary>Snippet for BatchPredict</summary> public void BatchPredict() { // Snippet: BatchPredict(ModelName,BatchPredictInputConfig,BatchPredictOutputConfig,IDictionary<string, string>,CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) ModelName name = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"); BatchPredictInputConfig inputConfig = new BatchPredictInputConfig(); BatchPredictOutputConfig outputConfig = new BatchPredictOutputConfig(); IDictionary <string, string> @params = new Dictionary <string, string>(); // Make the request Operation <BatchPredictResult, OperationMetadata> response = predictionServiceClient.BatchPredict(name, inputConfig, outputConfig, @params); // Poll until the returned long-running operation is complete Operation <BatchPredictResult, OperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result BatchPredictResult result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <BatchPredictResult, OperationMetadata> retrievedResponse = predictionServiceClient.PollOnceBatchPredict(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result BatchPredictResult retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for BatchPredictAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task BatchPredictResourceNamesAsync() { // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) ModelName name = ModelName.FromProjectLocationModel("[PROJECT]", "[LOCATION]", "[MODEL]"); BatchPredictInputConfig inputConfig = new BatchPredictInputConfig(); BatchPredictOutputConfig outputConfig = new BatchPredictOutputConfig(); IDictionary <string, string> @params = new Dictionary <string, string> { { "", "" }, }; // Make the request Operation <BatchPredictResult, OperationMetadata> response = await predictionServiceClient.BatchPredictAsync(name, inputConfig, outputConfig, @params); // Poll until the returned long-running operation is complete Operation <BatchPredictResult, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result BatchPredictResult result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <BatchPredictResult, OperationMetadata> retrievedResponse = await predictionServiceClient.PollOnceBatchPredictAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result BatchPredictResult retrievedResult = retrievedResponse.Result; } }
public async Task Start(string host, string model, string labels, float limit = 0, string certificate = null) { _host = host; _model = model; Limit = limit; if (!string.IsNullOrEmpty(labels)) { _labels = ReadLabels(labels); } if (!string.IsNullOrEmpty(host)) { try { ChannelCredentials channelCredentials = certificate == default ? ChannelCredentials.Insecure : new SslCredentials(certificate); _channel = new Channel(host, channelCredentials); DateTime deadline = DateTime.Now.AddSeconds(5).ToUniversalTime(); await _channel.ConnectAsync(deadline).ConfigureAwait(false); _client = new PredictionServiceClient(_channel); } catch (Exception ex) { string message = $"{ex.Message} ({ex.GetType()})"; Messenger.Default.Send(new NotificationMessage(message)); Log.Error(ex, message); _client = null; } } }
/// <summary>Snippet for BatchPredict</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void BatchPredict() { // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/models/[MODEL]"; BatchPredictInputConfig inputConfig = new BatchPredictInputConfig(); BatchPredictOutputConfig outputConfig = new BatchPredictOutputConfig(); IDictionary <string, string> @params = new Dictionary <string, string> { { "", "" }, }; // Make the request Operation <BatchPredictResult, OperationMetadata> response = predictionServiceClient.BatchPredict(name, inputConfig, outputConfig, @params); // Poll until the returned long-running operation is complete Operation <BatchPredictResult, OperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result BatchPredictResult result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <BatchPredictResult, OperationMetadata> retrievedResponse = predictionServiceClient.PollOnceBatchPredict(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result BatchPredictResult retrievedResult = retrievedResponse.Result; } }
/*public async Task<PredictionResponse> Predict(PredictionRequest predictionRequest) * { * if (predictionRequest?.Items == null || !predictionRequest.Items.Any()) * { * throw new ArgumentException("The request is not correct.", nameof(predictionRequest)); * } * * if (this.serviceConfiguration.PredictionProviderType == PredictionProviderType.ClientExecutable) * { * this.ValidatePredictionExecubablePath(); * } * * var guid = Guid.NewGuid().ToString(); * this.logger.Info($"Generating prediction request guid '{guid}'"); * * this.logger.Info("Inserting requests"); * await this.InsertRequests(predictionRequest, guid); * * if (this.serviceConfiguration.PredictionProviderType == PredictionProviderType.Server) * { * this.logger.Info("Calling prediction service"); * await this.CallPredictionService(guid); * } * else * { * this.logger.Info("Running prediction executable"); * await this.RunPredictionExecutable(guid); * } * * this.logger.Info($"Prediction service has finished."); * * this.logger.Info("Generating response"); * return await this.GenerateResponse(predictionRequest, guid); * }*/ #endregion #region My Methods private async Task CallPredictionService(string guid) { using (PredictionServiceClient client = new PredictionServiceClient(new Uri(this.serviceConfiguration.RServerUrl, UriKind.RelativeOrAbsolute))) { client.HttpClient.Timeout = this.serviceConfiguration.RServerClientTimeout; var loginParameters = new LoginRequest(this.serviceConfiguration.RServerUserName, this.serviceConfiguration.RServerPassword); var loginResult = await client.LoginWithHttpMessagesAsync(loginParameters); if (string.IsNullOrWhiteSpace(loginResult.Body.AccessToken)) { throw new SecurityException("Could not log in to prediction service."); } var headers = client.HttpClient.DefaultRequestHeaders; var accessToken = loginResult.Body.AccessToken; headers.Remove("Authorization"); headers.Add("Authorization", $"Bearer {accessToken}"); var result = await client.PredictWithHttpMessagesAsync(new InputParameters(guid)); if (!string.IsNullOrWhiteSpace(result.Body.ErrorMessage)) { throw new Exception(result.Body.ErrorMessage); } } }
/// <summary>Snippet for BatchPredict</summary> public void BatchPredictRequestObject() { // Snippet: BatchPredict(BatchPredictRequest, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) BatchPredictRequest request = new BatchPredictRequest { ModelName = ModelName.FromProjectLocationModel("[PROJECT]", "[LOCATION]", "[MODEL]"), InputConfig = new BatchPredictInputConfig(), OutputConfig = new BatchPredictOutputConfig(), Params = { { "", "" }, }, }; // Make the request Operation <BatchPredictResult, OperationMetadata> response = predictionServiceClient.BatchPredict(request); // Poll until the returned long-running operation is complete Operation <BatchPredictResult, OperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result BatchPredictResult result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <BatchPredictResult, OperationMetadata> retrievedResponse = predictionServiceClient.PollOnceBatchPredict(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result BatchPredictResult retrievedResult = retrievedResponse.Result; } // End snippet }
public async Task Disconnect() { if (_client != null) { await _channel.ShutdownAsync().ConfigureAwait(false); _client = null; } }
/// <summary>Snippet for RawPredict</summary> public void RawPredictResourceNames() { // Snippet: RawPredict(EndpointName, HttpBody, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) EndpointName endpoint = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); HttpBody httpBody = new HttpBody(); // Make the request HttpBody response = predictionServiceClient.RawPredict(endpoint, httpBody); // End snippet }
/// <summary>Snippet for Predict</summary> public async Task PredictRequestObjectAsync() { // Snippet: PredictAsync(PredictRequest, CallSettings) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) PredictRequest request = new PredictRequest { PlacementName = PlacementName.FromProjectLocationCatalogEventStorePlacement("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]", "[PLACEMENT]"), UserEvent = new UserEvent(), Filter = "", DryRun = false, Params = { { "", new Value() }, }, Labels = { { "", "" }, }, }; // Make the request PagedAsyncEnumerable <PredictResponse, PredictResponse.Types.PredictionResult> response = predictionServiceClient.PredictAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((PredictResponse.Types.PredictionResult item) => { // Do something with each item Console.WriteLine(item); }); // Or iterate over pages (of server-defined size), performing one RPC per page await response.AsRawResponses().ForEachAsync((PredictResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (PredictResponse.Types.PredictionResult item in page) { // Do something with each item Console.WriteLine(item); } }); // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <PredictResponse.Types.PredictionResult> singlePage = await response.ReadPageAsync(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (PredictResponse.Types.PredictionResult item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary>Snippet for RawPredict</summary> public void RawPredict() { // Snippet: RawPredict(string, HttpBody, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) string endpoint = "projects/[PROJECT]/locations/[LOCATION]/endpoints/[ENDPOINT]"; HttpBody httpBody = new HttpBody(); // Make the request HttpBody response = predictionServiceClient.RawPredict(endpoint, httpBody); // End snippet }
/// <summary>Snippet for Predict</summary> public void Predict() { // Snippet: Predict(string, IEnumerable<Value>, Value, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) string endpoint = "projects/[PROJECT]/locations/[LOCATION]/endpoints/[ENDPOINT]"; IEnumerable <Value> instances = new Value[] { new Value(), }; Value parameters = new Value(); // Make the request PredictResponse response = predictionServiceClient.Predict(endpoint, instances, parameters); // End snippet }
/// <summary>Snippet for Predict</summary> public void Predict() { // Snippet: Predict(ModelName,ExamplePayload,IDictionary<string, string>,CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) ModelName name = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"); ExamplePayload payload = new ExamplePayload(); IDictionary <string, string> @params = new Dictionary <string, string>(); // Make the request PredictResponse response = predictionServiceClient.Predict(name, payload, @params); // End snippet }
/// <summary>Snippet for Predict</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void PredictResourceNames() { // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) ModelName name = ModelName.FromProjectLocationModel("[PROJECT]", "[LOCATION]", "[MODEL]"); ExamplePayload payload = new ExamplePayload(); IDictionary <string, string> @params = new Dictionary <string, string> { { "", "" }, }; // Make the request PredictResponse response = predictionServiceClient.Predict(name, payload, @params); }
/// <summary>Snippet for Predict</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void Predict() { // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/models/[MODEL]"; ExamplePayload payload = new ExamplePayload(); IDictionary <string, string> @params = new Dictionary <string, string> { { "", "" }, }; // Make the request PredictResponse response = predictionServiceClient.Predict(name, payload, @params); }
/// <summary>Snippet for Predict</summary> public void PredictResourceNames() { // Snippet: Predict(EndpointName, IEnumerable<Value>, Value, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) EndpointName endpoint = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); IEnumerable <Value> instances = new Value[] { new Value(), }; Value parameters = new Value(); // Make the request PredictResponse response = predictionServiceClient.Predict(endpoint, instances, parameters); // End snippet }
/// <summary>Snippet for Predict</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void PredictRequestObject() { // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) PredictRequest request = new PredictRequest { ModelName = ModelName.FromProjectLocationModel("[PROJECT]", "[LOCATION]", "[MODEL]"), Payload = new ExamplePayload(), Params = { { "", "" }, }, }; // Make the request PredictResponse response = predictionServiceClient.Predict(request); }
/// <summary>Snippet for RawPredictAsync</summary> public async Task RawPredictAsync() { // Snippet: RawPredictAsync(string, HttpBody, CallSettings) // Additional: RawPredictAsync(string, HttpBody, CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) string endpoint = "projects/[PROJECT]/locations/[LOCATION]/endpoints/[ENDPOINT]"; HttpBody httpBody = new HttpBody(); // Make the request HttpBody response = await predictionServiceClient.RawPredictAsync(endpoint, httpBody); // End snippet }
/// <summary>Snippet for RawPredictAsync</summary> public async Task RawPredictResourceNamesAsync() { // Snippet: RawPredictAsync(EndpointName, HttpBody, CallSettings) // Additional: RawPredictAsync(EndpointName, HttpBody, CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) EndpointName endpoint = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); HttpBody httpBody = new HttpBody(); // Make the request HttpBody response = await predictionServiceClient.RawPredictAsync(endpoint, httpBody); // End snippet }
/// <summary>Snippet for RawPredict</summary> public void RawPredictRequestObject() { // Snippet: RawPredict(RawPredictRequest, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) RawPredictRequest request = new RawPredictRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), HttpBody = new HttpBody(), }; // Make the request HttpBody response = predictionServiceClient.RawPredict(request); // End snippet }
/// <summary>Snippet for Predict</summary> public void Predict_RequestObject() { // Snippet: Predict(PredictRequest,CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) PredictRequest request = new PredictRequest { ModelName = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"), Payload = new ExamplePayload(), }; // Make the request PredictResponse response = predictionServiceClient.Predict(request); // End snippet }
/// <summary>Snippet for Predict</summary> public void PredictRequestObject() { // Snippet: Predict(PredictRequest, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) PredictRequest request = new PredictRequest { Name = "", Payload = new ExamplePayload(), Params = { { "", "" }, }, }; // Make the request PredictResponse response = predictionServiceClient.Predict(request); // End snippet }
/// <summary>Snippet for PredictAsync</summary> public async Task PredictAsync() { // Snippet: PredictAsync(ModelName,ExamplePayload,IDictionary<string, string>,CallSettings) // Additional: PredictAsync(ModelName,ExamplePayload,IDictionary<string, string>,CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) ModelName name = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"); ExamplePayload payload = new ExamplePayload(); IDictionary <string, string> @params = new Dictionary <string, string>(); // Make the request PredictResponse response = await predictionServiceClient.PredictAsync(name, payload, @params); // End snippet }
/// <summary>Snippet for Predict</summary> public void PredictRequestObject() { // Snippet: Predict(PredictRequest, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) PredictRequest request = new PredictRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), Instances = { new Value(), }, Parameters = new Value(), }; // Make the request PredictResponse response = predictionServiceClient.Predict(request); // End snippet }
/// <summary>Snippet for Predict</summary> public async Task PredictAsync() { // Snippet: PredictAsync(string, UserEvent, string, int?, CallSettings) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/catalogs/[CATALOG]/eventStores/[EVENT_STORE]/placements/[PLACEMENT]"; UserEvent userEvent = new UserEvent(); // Make the request PagedAsyncEnumerable <PredictResponse, PredictResponse.Types.PredictionResult> response = predictionServiceClient.PredictAsync(name, userEvent); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((PredictResponse.Types.PredictionResult item) => { // Do something with each item Console.WriteLine(item); }); // Or iterate over pages (of server-defined size), performing one RPC per page await response.AsRawResponses().ForEachAsync((PredictResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (PredictResponse.Types.PredictionResult item in page) { // Do something with each item Console.WriteLine(item); } }); // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <PredictResponse.Types.PredictionResult> singlePage = await response.ReadPageAsync(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (PredictResponse.Types.PredictionResult item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary>Snippet for ExplainAsync</summary> public async Task ExplainResourceNamesAsync() { // Snippet: ExplainAsync(EndpointName, IEnumerable<Value>, Value, string, CallSettings) // Additional: ExplainAsync(EndpointName, IEnumerable<Value>, Value, string, CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) EndpointName endpoint = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"); IEnumerable <Value> instances = new Value[] { new Value(), }; Value parameters = new Value(); string deployedModelId = ""; // Make the request ExplainResponse response = await predictionServiceClient.ExplainAsync(endpoint, instances, parameters, deployedModelId); // End snippet }
/// <summary>Snippet for Predict</summary> public void PredictResourceNames() { // Snippet: Predict(PlacementName, UserEvent, string, int?, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) PlacementName name = PlacementName.FromProjectLocationCatalogEventStorePlacement("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]", "[PLACEMENT]"); UserEvent userEvent = new UserEvent(); // Make the request PagedEnumerable <PredictResponse, PredictResponse.Types.PredictionResult> response = predictionServiceClient.Predict(name, userEvent); // Iterate over all response items, lazily performing RPCs as required foreach (PredictResponse.Types.PredictionResult item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (PredictResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (PredictResponse.Types.PredictionResult item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <PredictResponse.Types.PredictionResult> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (PredictResponse.Types.PredictionResult item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary>Snippet for PredictAsync</summary> public async Task PredictAsync_RequestObject() { // Snippet: PredictAsync(PredictRequest,CallSettings) // Additional: PredictAsync(PredictRequest,CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) PredictRequest request = new PredictRequest { ModelName = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"), Payload = new ExamplePayload(), }; // Make the request PredictResponse response = await predictionServiceClient.PredictAsync(request); // End snippet }
/// <summary>Snippet for RawPredictAsync</summary> public async Task RawPredictRequestObjectAsync() { // Snippet: RawPredictAsync(RawPredictRequest, CallSettings) // Additional: RawPredictAsync(RawPredictRequest, CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) RawPredictRequest request = new RawPredictRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), HttpBody = new HttpBody(), }; // Make the request HttpBody response = await predictionServiceClient.RawPredictAsync(request); // End snippet }
/// <summary>Snippet for Explain</summary> public void ExplainRequestObject() { // Snippet: Explain(ExplainRequest, CallSettings) // Create client PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create(); // Initialize request argument(s) ExplainRequest request = new ExplainRequest { EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), Instances = { new Value(), }, DeployedModelId = "", Parameters = new Value(), ExplanationSpecOverride = new ExplanationSpecOverride(), }; // Make the request ExplainResponse response = predictionServiceClient.Explain(request); // End snippet }
/// <summary>Snippet for PredictAsync</summary> public async Task PredictAsync() { // Snippet: PredictAsync(string, ExamplePayload, IDictionary<string,string>, CallSettings) // Additional: PredictAsync(string, ExamplePayload, IDictionary<string,string>, CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/models/[MODEL]"; ExamplePayload payload = new ExamplePayload(); IDictionary <string, string> @params = new Dictionary <string, string> { { "", "" }, }; // Make the request PredictResponse response = await predictionServiceClient.PredictAsync(name, payload, @params); // End snippet }