Ensemble Methods
Original integration-test class: Ensemble in 6.10.ML.Ensemble.cs. This is a direct SDK operation, not a PipelineClient workflow.
198 recorded job or prediction directories matched by module and scenario path. 184 have completed/success status and a saved result. These are API execution records, not confirmed xUnit pass counts. Partition jobs are counted separately.
Prerequisites
Use the original SDK test project, its xUnit dependencies, helper classes and any upstream cache entries referenced in the source. See configuration.
Required environment variable names referenced in the source: PARALLELMODEL_MODEL_ID, PARALLELMODEL_COMPUTE_SIZE, PARALLELMODEL_ENCRYPTION_KEY_1, PARALLELMODEL_REGION, PARALLELMODEL_CLIENT_ID, PARALLELMODEL_CLIENT_SECRET.
SDK calls used
| Client | Methods in the source |
|---|---|
EnsembleClient | DownloadBytesAsync, ExtractAsync, LogAsync, ResultAsync, SendAsync, StatusAsync |
PreprocessingClient | DownloadBytesAsync |
Execution workflow
- Initialise the client and output paths.
- Resolve transformed train/test blobs and their shared input columns.
- Save and send the concrete request once.
- Save each status response until the job reaches a terminal state.
- Retrieve logs once after terminal success.
- Retrieve the original result.
- Extract and download the result and all declared artifacts.
- Replace this case atomically after all downloads succeed.
Recorded operation examples
| Operation | Recorded jobs | Result recorded |
|---|---|---|
| AdaBoostClassifier | 14 | 14 |
| AdaBoostRegressor | 8 | 8 |
| BaggingClassifier | 14 | 14 |
| BaggingRegressor | 8 | 8 |
| ExtraTreesClassifier | 14 | 14 |
| ExtraTreesRegressor | 8 | 8 |
| GradientBoostingClassifier | 14 | 14 |
| GradientBoostingRegressor | 8 | 8 |
| HistGradientBoostingClassifier | 14 | 14 |
| HistGradientBoostingRegressor | 8 | 8 |
| IsolationForest | 14 | 0 |
| RandomForestRegressor | 8 | 8 |
| RandomTreesEmbedding | 22 | 22 |
| StackingClassifier | 14 | 14 |
| StackingRegressor | 8 | 8 |
| VotingClassifier | 14 | 14 |
| VotingRegressor | 8 | 8 |
Run the original integration test
This filter selects the class and its parameterized scenarios; it does not select only a single recorded job.
dotnet test --filter "FullyQualifiedName~ParallelModel.Sdk.UnitTests.Ensemble.Run"
Full C# source
The supplied test logic is preserved. The method signature is:
Run(string dataset, string modelselection, string impute, string preprocessing, string ensembleAlgorithm)
using ParallelModel.Sdk.Authentication;
using ParallelModel.Sdk.Exceptions;
using ParallelModel.Sdk.ML.Ensemble.Models.Requests;
using ParallelModel.Sdk.UnitTests.Attributes;
using ParallelModel.Sdk.UnitTests.Cache;
using ParallelModel.Sdk.UnitTests.Helpers;
using System.Text.Json;
using static ParallelModel.Sdk.UnitTests.Helpers.MLEnsembleHelper;
namespace ParallelModel.Sdk.UnitTests
{
[Collection("Ensemble")]
public sealed class Ensemble
{
private static readonly TimeSpan ApiTimeout = TimeSpan.FromSeconds(300);
private static readonly SharedSendThrottle SendThrottle = new(TimeSpan.FromSeconds(12));
private static readonly string[] Algorithms =
[
"AdaBoostClassifier", "AdaBoostRegressor", "BaggingClassifier",
"BaggingRegressor", "ExtraTreesClassifier", "ExtraTreesRegressor",
"GradientBoostingClassifier", "GradientBoostingRegressor", "HistGradientBoostingClassifier",
"HistGradientBoostingRegressor", "IsolationForest", "RandomForestClassifier",
"RandomForestRegressor", "RandomTreesEmbedding", "StackingClassifier",
"StackingRegressor", "VotingClassifier", "VotingRegressor"
];
private const string WeightedSampleColumn = "sample_weight";
private const bool EnableWeightedRandomForestClassifier = false;
public static TheoryData<string, string, string, string, string> EnsembleRequests =>
PreprocessingAttribute.GetRequests(typeof(Ensemble), nameof(Run), AlgorithmsFor);
private static string[] AlgorithmsFor(string dataset, string preprocessing) => (dataset, preprocessing) switch
{
(_, "label_binarize") => [],
("LoadDiabetes" or "MakeRegression", _) => Algorithms.Where(algorithm =>
algorithm.EndsWith("Regressor", StringComparison.Ordinal) || algorithm == "RandomTreesEmbedding").ToArray(),
("LoadBreastCancer" or "LoadWine" or "MakeClassification", _) => Algorithms.Where(algorithm =>
(algorithm.EndsWith("Classifier", StringComparison.Ordinal) || algorithm is "IsolationForest" or "RandomTreesEmbedding") &&
(EnableWeightedRandomForestClassifier || algorithm != "RandomForestClassifier")).ToArray(),
_ => []
};
[Theory]
[MemberData(nameof(EnsembleRequests))]
[Trait("Category", "Integration")]
[Preprocessing(dataset: "LoadDiabetes", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "StandardScaler")]
[Preprocessing(dataset: "LoadDiabetes", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "KBinsDiscretizer")]
[Preprocessing(dataset: "LoadDiabetes", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "normalize")]
[Preprocessing(dataset: "LoadDiabetes", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "QuantileTransformer")]
[Preprocessing(dataset: "MakeRegression", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "StandardScaler")]
[Preprocessing(dataset: "MakeRegression", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "KBinsDiscretizer")]
[Preprocessing(dataset: "MakeRegression", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "normalize")]
[Preprocessing(dataset: "MakeRegression", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "QuantileTransformer")]
[Preprocessing(dataset: "LoadBreastCancer", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "StandardScaler")]
[Preprocessing(dataset: "LoadBreastCancer", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "FunctionTransformer")]
[Preprocessing(dataset: "LoadBreastCancer", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "KBinsDiscretizer")]
[Preprocessing(dataset: "LoadBreastCancer", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "normalize")]
[Preprocessing(dataset: "LoadBreastCancer", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "QuantileTransformer")]
[Preprocessing(dataset: "LoadWine", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "StandardScaler")]
[Preprocessing(dataset: "LoadWine", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "FunctionTransformer")]
[Preprocessing(dataset: "LoadWine", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "KBinsDiscretizer")]
[Preprocessing(dataset: "LoadWine", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "normalize")]
[Preprocessing(dataset: "LoadWine", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "QuantileTransformer")]
[Preprocessing(dataset: "MakeClassification", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "StandardScaler")]
[Preprocessing(dataset: "MakeClassification", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "KBinsDiscretizer")]
[Preprocessing(dataset: "MakeClassification", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "normalize")]
[Preprocessing(dataset: "MakeClassification", modelselection: "TrainTestSplit", impute: "SimpleImputer", preprocessing: "QuantileTransformer")]
public async Task Run(string dataset, string modelselection, string impute, string preprocessing,
string ensembleAlgorithm)
{
// 1. Initialise the client and output paths.
SharedEnvironmentHelper.LoadEnvIfAvailable();
CancellationToken cancellationToken = TestContext.Current.CancellationToken;
Guid modelId = SharedEnvironmentHelper.RequiredGuid("PARALLELMODEL_MODEL_ID");
string computeSize = SharedEnvironmentHelper.Required("PARALLELMODEL_COMPUTE_SIZE");
string encryptionKey = SharedEnvironmentHelper.Required("PARALLELMODEL_ENCRYPTION_KEY_1");
TimeSpan pollingInterval = TimeSpan.FromSeconds(30);
ParallelModelClient parallelModelClient = new(new DefaultParallelModelAuthenticationOptions
{
Region = SharedEnvironmentHelper.Required("PARALLELMODEL_REGION"),
ClientId = SharedEnvironmentHelper.Required("PARALLELMODEL_CLIENT_ID"),
ClientSecret = SharedEnvironmentHelper.Required("PARALLELMODEL_CLIENT_SECRET"),
Timeout = ApiTimeout,
AutoRefreshToken = true,
RefreshBeforeExpiry = TimeSpan.FromMinutes(2),
RetryOnUnauthorized = true,
MaxRetries = 3
});
string outputRoot = SharedEnvironmentHelper.OutputDirectory;
string runId = Guid.NewGuid().ToString("N");
string outputDirectory = Path.Combine(outputRoot, "ensemble",
$"{dataset}-{modelselection}-{impute}-{preprocessing}", ensembleAlgorithm, runId);
string cacheDirectory = SharedEnvironmentHelper.CacheDirectory;
Directory.CreateDirectory(Path.Combine(outputDirectory, "artifacts"));
int responseFileNumber = 0;
// 2. Resolve transformed train/test blobs and their shared input columns.
(TransformedInput train, TransformedInput test) = await LoadInputsAsync(
cacheDirectory, dataset, modelselection, impute, preprocessing, cancellationToken);
async Task<string[]> ReadColumnsAsync(TransformedInput entry)
{
byte[] bytes = await RequestAsync($"read-{entry.Partition}", () =>
parallelModelClient.PreprocessingClient.DownloadBytesAsync(modelId: modelId, jobId: entry.JobId,
blobId: entry.BlobId, computeSize: computeSize, inputEncryptionKey: encryptionKey,
timeout: ApiTimeout, cancellationToken: cancellationToken),
maximumAttempts: 5, saveJson: false);
return ReadHeader(bytes, entry.Partition);
}
// IsolationForest retains the target required by the supplied request contract.
bool requiresTarget = ensembleAlgorithm != "RandomTreesEmbedding";
bool requiresSampleWeight = ensembleAlgorithm == "RandomForestClassifier";
(string[] features, string? target) = ResolveColumns(await ReadColumnsAsync(train),
await ReadColumnsAsync(test), requiresTarget, requiresSampleWeight, WeightedSampleColumn);
// 3. Save and send the concrete request once.
await SendThrottle.WaitForSendSlotAsync(cancellationToken);
string requestFileName = $"{++responseFileNumber:000}-request.json";
JsonElement sent = await RequestAsync("send", () => SendEnsembleAsync(parallelModelClient, modelId,
computeSize, encryptionKey, train.BlobId, test.BlobId, features, target, dataset,
$"{dataset}-{modelselection}-{impute}-{preprocessing}-{ensembleAlgorithm}.zip",
preprocessing, ensembleAlgorithm, outputDirectory, requestFileName, cancellationToken));
Guid jobId = RequiredProperty(sent, "jobId", "job_id").GetGuid();
// 4. Save each status response until the job reaches a terminal state.
DateTimeOffset statusDeadline = DateTimeOffset.UtcNow.AddMinutes(35);
for (int attempt = 1; ; attempt++)
{
JsonElement statusResponse = await RequestAsync($"status-{attempt:000}", () =>
parallelModelClient.EnsembleClient.StatusAsync(
modelId, jobId, computeSize, ApiTimeout, cancellationToken),
maximumAttempts: 5, retryDeadline: statusDeadline);
JsonElement statusValue = RequiredProperty(statusResponse, "status");
string? jobStatus = statusValue.ValueKind == JsonValueKind.String ? statusValue.GetString() : null;
switch (jobStatus?.ToLowerInvariant())
{
case "success" or "succeeded" or "completed":
break;
case null or "error" or "failed" or "cancelled" or "canceled" or "deadletter"
or "dead-lettered" or "deadlettered" or "dead_letter" or "dead-letter":
try
{
await RequestAsync("logs", GetLogsAsync);
}
catch (Exception) when (!cancellationToken.IsCancellationRequested)
{
// RequestAsync has already attempted to save the log error.
}
throw new InvalidOperationException(
$"Job {jobId} returned a status error or ended with status '{jobStatus}'. See saved responses.");
default:
if (DateTimeOffset.UtcNow >= statusDeadline)
throw new TimeoutException($"Status polling expired for job {jobId}.");
await Task.Delay(pollingInterval, cancellationToken);
continue;
}
break;
}
// 5. Retrieve logs once after terminal success.
try
{
await RequestAsync("logs", GetLogsAsync);
}
catch (Exception exception) when (!cancellationToken.IsCancellationRequested && (exception switch
{
ParallelModelApiException error => (int)error.StatusCode is 408 or 409 or 429 or >= 500 ||
((int)error.StatusCode == 404 && error.Detail?.Contains("job failed", StringComparison.OrdinalIgnoreCase) != true),
HttpRequestException or TimeoutException or TaskCanceledException => true,
_ => false
}))
{ /* The optional log request error was saved. */
}
// 6. Retrieve the original result.
JsonElement result = await RequestAsync("result", () => parallelModelClient.EnsembleClient.ResultAsync(
modelId, jobId, computeSize, encryptionKey, timeout: ApiTimeout, cancellationToken: cancellationToken),
maximumAttempts: int.MaxValue, retryDeadline: DateTimeOffset.UtcNow.AddMinutes(5));
// 7. Extract and download the result and all declared artifacts.
string[] paths = ArtifactPaths(result).Distinct(StringComparer.Ordinal).ToArray();
// The original Ensemble test explicitly extracts these two artifacts.
// Prefer the actual result's declared list whenever it is supplied.
if (paths.Length == 0)
paths = ["model.joblib", "result.json"];
List<EnsembleCacheEntry> outputs = new();
for (int index = 0; index < paths.Length; index++)
{
string path = paths[index];
JsonElement extracted = await RequestAsync("extract", () => parallelModelClient.EnsembleClient.ExtractAsync(
modelId, jobId, path, computeSize, encryptionKey, encryptionKey, timeout: ApiTimeout,
cancellationToken: cancellationToken), maximumAttempts: 5);
Guid blobId = RequiredProperty(extracted, "uploadedBlobId", "uploaded_blob_id").GetGuid();
byte[] bytes = await RequestAsync("download", () => parallelModelClient.EnsembleClient.DownloadBytesAsync(
modelId, jobId, blobId, computeSize, encryptionKey, ApiTimeout, cancellationToken),
maximumAttempts: 5, saveJson: false);
await SharedArtifactHelper.SaveAsync(outputDirectory, index + 1, path, bytes, cancellationToken);
foreach (TransformedInput input in new[] { train, test })
outputs.Add(new(dataset, modelselection, impute, preprocessing, ensembleAlgorithm,
input.Partition, blobId, path, input.BlobId, input.BlobId, input.ImputedBlobId,
train.BlobId, test.BlobId, jobId, runId));
}
// 8. Replace this case atomically after all downloads succeed.
await SharedCacheHelper.UpdateAsync<List<EnsembleCacheEntry>>(cacheDirectory, EnsembleCacheEntry.FileName, current =>
{
current ??= new();
current.RemoveAll(entry => entry.Matches(dataset, modelselection, impute, preprocessing, ensembleAlgorithm));
current.AddRange(outputs);
return current.OrderBy(entry => entry.Dataset, StringComparer.Ordinal)
.ThenBy(entry => entry.Modelselection, StringComparer.Ordinal)
.ThenBy(entry => entry.Impute, StringComparer.Ordinal)
.ThenBy(entry => entry.Preprocessing, StringComparer.Ordinal)
.ThenBy(entry => entry.Ensemblealgo, StringComparer.Ordinal)
.ThenBy(entry => entry.Partition, StringComparer.Ordinal)
.ThenBy(entry => entry.ArtifactPath, StringComparer.Ordinal).ToList();
}, cancellationToken);
Task<JsonElement> GetLogsAsync() => parallelModelClient.EnsembleClient.LogAsync(
modelId, jobId, computeSize, TimeSpan.FromSeconds(30), cancellationToken);
async Task<T> RequestAsync<T>(string stage, Func<Task<T>> request,
int maximumAttempts = 1, bool saveJson = true, DateTimeOffset? retryDeadline = null)
{
for (int attempt = 1; ; attempt++)
{
cancellationToken.ThrowIfCancellationRequested();
T response;
try
{
response = await request();
}
catch (Exception exception) when (!cancellationToken.IsCancellationRequested)
{
await SharedResponseHelper.SaveExceptionAsync(outputDirectory,
$"{++responseFileNumber:000}-{stage}-attempt-{attempt:000}-error.txt",
exception, cancellationToken);
bool transient = exception switch
{
ParallelModelApiException error => (int)error.StatusCode is 408 or 409 or 429 or >= 500 ||
((int)error.StatusCode == 404 && error.Detail?.Contains("job failed", StringComparison.OrdinalIgnoreCase) != true),
HttpRequestException or TimeoutException or TaskCanceledException => true,
_ => false
};
if (attempt >= maximumAttempts || !transient ||
(retryDeadline.HasValue && DateTimeOffset.UtcNow + pollingInterval >= retryDeadline.Value))
throw;
await Task.Delay(pollingInterval, cancellationToken);
continue;
}
if (saveJson)
await SharedResponseHelper.SaveAsync(outputDirectory,
$"{++responseFileNumber:000}-{stage}.json", response, cancellationToken);
return response;
}
}
}
private static async Task<JsonElement> SendEnsembleAsync(ParallelModelClient parallelModelClient, Guid modelId,
string computeSize, string encryptionKey, Guid trainBlobId, Guid testBlobId, string[] featureColumns,
string? trainTarget, string dataset, string outputName, string preprocessing, string ensembleAlgorithm,
string outputDirectory, string requestFileName, CancellationToken cancellationToken)
{
ParallelModelEnsembleOutputModel parallelModelEnsembleOutputModel = new()
{
Name = outputName,
Description = "Ensemble integration test using cached numerical preprocessing outputs",
RecordType = "Generic",
AccessTier = "Hot",
Tags = ["ensemble", dataset, preprocessing, ensembleAlgorithm]
};
async Task<JsonElement> SendTypedAsync<TRequest>(TRequest ensembleJobSendRequestModel)
where TRequest : class, IParallelModelEnsembleSendRequest
{
await SharedResponseHelper.SaveAsync(outputDirectory, requestFileName, ensembleJobSendRequestModel, cancellationToken);
return await parallelModelClient.EnsembleClient.SendAsync(modelId, ensembleJobSendRequestModel,
computeSize, encryptionKey, encryptionKey, encryptionKey, ApiTimeout, cancellationToken);
}
return ensembleAlgorithm switch
{
"AdaBoostClassifier" => await SendTypedAsync(new AdaBoostClassifierJobSendRequestModel
{
Input = new AdaBoostClassifierJobSendRequestModel.AdaBoostClassifierInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "AdaBoostClassifier",
ClassifierParams = new AdaBoostClassifierJobSendRequestModel.AdaBoostClassifierClassifierParamsModel
{
NEstimators = 15,
LearningRate = 0.75,
Estimator = new AdaBoostClassifierJobSendRequestModel.AdaBoostClassifierClassifierParamsEstimatorModel
{
Name = "base_tree",
EstimatorType = "DecisionTreeClassifier",
EstimatorParams = new AdaBoostClassifierJobSendRequestModel.AdaBoostClassifierClassifierParamsEstimatorEstimatorParamsModel
{
MaxDepth = 2
}
}
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"AdaBoostRegressor" => await SendTypedAsync(new AdaBoostRegressorJobSendRequestModel
{
Input = new AdaBoostRegressorJobSendRequestModel.AdaBoostRegressorInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "AdaBoostRegressor",
ClassifierParams = new AdaBoostRegressorJobSendRequestModel.AdaBoostRegressorClassifierParamsModel
{
NEstimators = 15,
LearningRate = 0.75,
Estimator = new AdaBoostRegressorJobSendRequestModel.AdaBoostRegressorClassifierParamsEstimatorModel
{
Name = "base_tree",
EstimatorType = "DecisionTreeRegressor",
EstimatorParams = new AdaBoostRegressorJobSendRequestModel.AdaBoostRegressorClassifierParamsEstimatorEstimatorParamsModel
{
MaxDepth = 3
}
}
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"BaggingClassifier" => await SendTypedAsync(new BaggingClassifierJobSendRequestModel
{
Input = new BaggingClassifierJobSendRequestModel.BaggingClassifierInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "BaggingClassifier",
ClassifierParams = new BaggingClassifierJobSendRequestModel.BaggingClassifierClassifierParamsModel
{
NEstimators = 12,
MaxSamples = 0.8,
Estimator = new BaggingClassifierJobSendRequestModel.BaggingClassifierClassifierParamsEstimatorModel
{
Name = "base_tree",
EstimatorType = "DecisionTreeClassifier",
EstimatorParams = new BaggingClassifierJobSendRequestModel.BaggingClassifierClassifierParamsEstimatorEstimatorParamsModel
{
MaxDepth = 4
}
}
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"BaggingRegressor" => await SendTypedAsync(new BaggingRegressorJobSendRequestModel
{
Input = new BaggingRegressorJobSendRequestModel.BaggingRegressorInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "BaggingRegressor",
ClassifierParams = new BaggingRegressorJobSendRequestModel.BaggingRegressorClassifierParamsModel
{
NEstimators = 12,
MaxSamples = 0.8,
Estimator = new BaggingRegressorJobSendRequestModel.BaggingRegressorClassifierParamsEstimatorModel
{
Name = "base_tree",
EstimatorType = "DecisionTreeRegressor",
EstimatorParams = new BaggingRegressorJobSendRequestModel.BaggingRegressorClassifierParamsEstimatorEstimatorParamsModel
{
MaxDepth = 4
}
}
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"ExtraTreesClassifier" => await SendTypedAsync(new ExtraTreesClassifierJobSendRequestModel
{
Input = new ExtraTreesClassifierJobSendRequestModel.ExtraTreesClassifierInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "ExtraTreesClassifier",
ClassifierParams = new ExtraTreesClassifierJobSendRequestModel.ExtraTreesClassifierClassifierParamsModel
{
NEstimators = 24,
MaxDepth = 7,
MinSamplesLeaf = 2
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"ExtraTreesRegressor" => await SendTypedAsync(new ExtraTreesRegressorJobSendRequestModel
{
Input = new ExtraTreesRegressorJobSendRequestModel.ExtraTreesRegressorInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "ExtraTreesRegressor",
ClassifierParams = new ExtraTreesRegressorJobSendRequestModel.ExtraTreesRegressorClassifierParamsModel
{
NEstimators = 24,
MaxDepth = 7,
MinSamplesLeaf = 2
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"GradientBoostingClassifier" => await SendTypedAsync(new GradientBoostingClassifierJobSendRequestModel
{
Input = new GradientBoostingClassifierJobSendRequestModel.GradientBoostingClassifierInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "GradientBoostingClassifier",
ClassifierParams = new GradientBoostingClassifierJobSendRequestModel.GradientBoostingClassifierClassifierParamsModel
{
NEstimators = 25,
LearningRate = 0.1,
MaxDepth = 3,
Subsample = 0.9
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"GradientBoostingRegressor" => await SendTypedAsync(new GradientBoostingRegressorJobSendRequestModel
{
Input = new GradientBoostingRegressorJobSendRequestModel.GradientBoostingRegressorInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "GradientBoostingRegressor",
ClassifierParams = new GradientBoostingRegressorJobSendRequestModel.GradientBoostingRegressorClassifierParamsModel
{
NEstimators = 25,
LearningRate = 0.1,
MaxDepth = 3,
Subsample = 0.9
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"HistGradientBoostingClassifier" => await SendTypedAsync(new HistGradientBoostingClassifierJobSendRequestModel
{
Input = new HistGradientBoostingClassifierJobSendRequestModel.HistGradientBoostingClassifierInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "HistGradientBoostingClassifier",
ClassifierParams = new HistGradientBoostingClassifierJobSendRequestModel.HistGradientBoostingClassifierClassifierParamsModel
{
MaxIter = 35,
LearningRate = 0.1,
MaxLeafNodes = 15,
MaxBins = 64,
EarlyStopping = false
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"HistGradientBoostingRegressor" => await SendTypedAsync(new HistGradientBoostingRegressorJobSendRequestModel
{
Input = new HistGradientBoostingRegressorJobSendRequestModel.HistGradientBoostingRegressorInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "HistGradientBoostingRegressor",
ClassifierParams = new HistGradientBoostingRegressorJobSendRequestModel.HistGradientBoostingRegressorClassifierParamsModel
{
MaxIter = 35,
LearningRate = 0.1,
MaxLeafNodes = 15,
MaxBins = 64,
EarlyStopping = false
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"IsolationForest" => await SendTypedAsync(new IsolationForestJobSendRequestModel
{
Input = new IsolationForestJobSendRequestModel.IsolationForestInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "IsolationForest",
ClassifierParams = new IsolationForestJobSendRequestModel.IsolationForestClassifierParamsModel
{
NEstimators = 48,
Contamination = 0.1,
MaxSamples = 0.8
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"RandomForestClassifier" => await SendTypedAsync(new RandomForestClassifierJobSendRequestModel
{
Input = new RandomForestClassifierJobSendRequestModel.RandomForestClassifierInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "RandomForestClassifier",
ClassifierParams = new RandomForestClassifierJobSendRequestModel.RandomForestClassifierClassifierParamsModel
{
NEstimators = 28,
MinSamplesLeaf = 2
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
SampleWeightColumn = WeightedSampleColumn,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"RandomForestRegressor" => await SendTypedAsync(new RandomForestRegressorJobSendRequestModel
{
Input = new RandomForestRegressorJobSendRequestModel.RandomForestRegressorInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "RandomForestRegressor",
ClassifierParams = new RandomForestRegressorJobSendRequestModel.RandomForestRegressorClassifierParamsModel
{
NEstimators = 28,
MinSamplesLeaf = 2
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"RandomTreesEmbedding" => await SendTypedAsync(new RandomTreesEmbeddingJobSendRequestModel
{
Input = new RandomTreesEmbeddingJobSendRequestModel.RandomTreesEmbeddingInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "RandomTreesEmbedding",
ClassifierParams = new RandomTreesEmbeddingJobSendRequestModel.RandomTreesEmbeddingClassifierParamsModel
{
NEstimators = 10,
MaxDepth = 3,
SparseOutput = true
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"StackingClassifier" => await SendTypedAsync(new StackingClassifierJobSendRequestModel
{
Input = new StackingClassifierJobSendRequestModel.StackingClassifierInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "StackingClassifier",
ClassifierParams = new StackingClassifierJobSendRequestModel.StackingClassifierClassifierParamsModel
{
Estimators = [
new StackingClassifierJobSendRequestModel.StackingClassifierClassifierParamsEstimatorModel
{
Name = "tree",
EstimatorType = "DecisionTreeClassifier",
EstimatorParams = new StackingClassifierJobSendRequestModel.StackingClassifierClassifierParamsEstimatorParamsModel
{
MaxDepth = 4
}
},
new StackingClassifierJobSendRequestModel.StackingClassifierClassifierParamsEstimatorModel
{
Name = "logistic",
EstimatorType = "LogisticRegression",
EstimatorParams = new StackingClassifierJobSendRequestModel.StackingClassifierClassifierParamsEstimatorParamsModel()
}
],
FinalEstimator = new StackingClassifierJobSendRequestModel.StackingClassifierClassifierParamsEstimatorModel
{
Name = "final",
EstimatorType = "LogisticRegression",
EstimatorParams = new StackingClassifierJobSendRequestModel.StackingClassifierClassifierParamsEstimatorParamsModel()
},
Cv = 3,
Passthrough = false
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"StackingRegressor" => await SendTypedAsync(new StackingRegressorJobSendRequestModel
{
Input = new StackingRegressorJobSendRequestModel.StackingRegressorInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "StackingRegressor",
ClassifierParams = new StackingRegressorJobSendRequestModel.StackingRegressorClassifierParamsModel
{
Estimators = [
new StackingRegressorJobSendRequestModel.StackingRegressorClassifierParamsEstimatorModel
{
Name = "tree",
EstimatorType = "DecisionTreeRegressor",
EstimatorParams = new StackingRegressorJobSendRequestModel.StackingRegressorClassifierParamsEstimatorParamsModel
{
MaxDepth = 4
}
},
new StackingRegressorJobSendRequestModel.StackingRegressorClassifierParamsEstimatorModel
{
Name = "ridge",
EstimatorType = "Ridge",
EstimatorParams = new StackingRegressorJobSendRequestModel.StackingRegressorClassifierParamsEstimatorParamsModel
{
Alpha = 1.0
}
}
],
FinalEstimator = new StackingRegressorJobSendRequestModel.StackingRegressorClassifierParamsEstimatorModel
{
Name = "final",
EstimatorType = "Ridge",
EstimatorParams = new StackingRegressorJobSendRequestModel.StackingRegressorClassifierParamsEstimatorParamsModel
{
Alpha = 1.0
}
},
Cv = 3,
Passthrough = true
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"VotingClassifier" => await SendTypedAsync(new VotingClassifierJobSendRequestModel
{
Input = new VotingClassifierJobSendRequestModel.VotingClassifierInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "VotingClassifier",
ClassifierParams = new VotingClassifierJobSendRequestModel.VotingClassifierClassifierParamsModel
{
Estimators = [
new VotingClassifierJobSendRequestModel.VotingClassifierClassifierParamsEstimatorModel
{
Name = "logistic",
EstimatorType = "LogisticRegression",
EstimatorParams = new VotingClassifierJobSendRequestModel.VotingClassifierClassifierParamsEstimatorParamsModel()
},
new VotingClassifierJobSendRequestModel.VotingClassifierClassifierParamsEstimatorModel
{
Name = "forest",
EstimatorType = "RandomForestClassifier",
EstimatorParams = new VotingClassifierJobSendRequestModel.VotingClassifierClassifierParamsEstimatorParamsModel
{
NEstimators = 18,
MaxDepth = 5
}
}
],
Voting = "soft",
Weights = [1.0, 2.0]
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
"VotingRegressor" => await SendTypedAsync(new VotingRegressorJobSendRequestModel
{
Input = new VotingRegressorJobSendRequestModel.VotingRegressorInputModel
{
TrainBlobId = trainBlobId,
TestBlobId = testBlobId,
ClassifierType = "VotingRegressor",
ClassifierParams = new VotingRegressorJobSendRequestModel.VotingRegressorClassifierParamsModel
{
Estimators = [
new VotingRegressorJobSendRequestModel.VotingRegressorClassifierParamsEstimatorModel
{
Name = "ridge",
EstimatorType = "Ridge",
EstimatorParams = new VotingRegressorJobSendRequestModel.VotingRegressorClassifierParamsEstimatorParamsModel
{
Alpha = 2.0
}
},
new VotingRegressorJobSendRequestModel.VotingRegressorClassifierParamsEstimatorModel
{
Name = "forest",
EstimatorType = "RandomForestRegressor",
EstimatorParams = new VotingRegressorJobSendRequestModel.VotingRegressorClassifierParamsEstimatorParamsModel
{
NEstimators = 18,
MaxDepth = 5
}
}
],
Weights = [1.0, 2.0]
},
FeatureColumns = featureColumns.ToList(),
FileFormat = "csv",
DataType = "numeric_table",
TargetColumn = trainTarget!,
GenerateGraphs = true
},
Output = parallelModelEnsembleOutputModel,
RequestTimeoutSeconds = 1800
}),
_ => throw new NotSupportedException(ensembleAlgorithm)
};
}
}
}