|
14 | 14 | using Microsoft.Data.Analysis; |
15 | 15 | using Microsoft.Extensions.DependencyInjection; |
16 | 16 | using Microsoft.ML.AutoML.CodeGen; |
17 | | -using Microsoft.ML.Data; |
18 | 17 | using Microsoft.ML.Runtime; |
19 | 18 | using Microsoft.ML.TestFramework; |
20 | 19 | using Microsoft.ML.TestFramework.Attributes; |
21 | | -using Microsoft.ML.TorchSharp; |
22 | 20 | using Xunit; |
23 | 21 | using Xunit.Abstractions; |
24 | 22 |
|
@@ -239,14 +237,13 @@ public async Task AutoMLExperiment_UCI_Adult_CV_5_Test() |
239 | 237 | var experiment = context.Auto().CreateExperiment(); |
240 | 238 | var pipeline = context.Auto().Featurizer(data, "_Features_", excludeColumns: new[] { DatasetUtil.UciAdultLabel }) |
241 | 239 | .Append(context.Auto().BinaryClassification(DatasetUtil.UciAdultLabel, "_Features_", useLgbm: false, useSdcaLogisticRegression: false, useLbfgsLogisticRegression: false)); |
242 | | - var cts = new CancellationTokenSource(); |
243 | | - cts.CancelAfter(50000); |
| 240 | + |
244 | 241 | experiment.SetDataset(data, 5) |
245 | 242 | .SetBinaryClassificationMetric(BinaryClassificationMetric.AreaUnderRocCurve, DatasetUtil.UciAdultLabel) |
246 | 243 | .SetPipeline(pipeline) |
247 | | - .SetTrainingTimeInSeconds(100); |
| 244 | + .SetTrainingTimeInSeconds(10); |
248 | 245 |
|
249 | | - var result = await experiment.RunAsync(cts.Token); |
| 246 | + var result = await experiment.RunAsync(); |
250 | 247 | result.Metric.Should().BeGreaterThan(0.8); |
251 | 248 | } |
252 | 249 |
|
@@ -363,88 +360,6 @@ public void AutoMLExperiment_should_use_seed_from_context_if_provided() |
363 | 360 | settings = experiment.ServiceCollection.BuildServiceProvider().GetRequiredService<AutoMLExperiment.AutoMLExperimentSettings>(); |
364 | 361 | settings.Seed.Should().Be(1); |
365 | 362 | } |
366 | | - |
367 | | - [Fact] |
368 | | - public async Task AutoMLExperiment_should_cancel_text_classification() |
369 | | - { |
370 | | - var context = new MLContext(1); |
371 | | - context.Log += (o, e) => |
372 | | - { |
373 | | - if (e.Message.Contains("AutoMLExperiment") || e.Message.Contains("NasBertTrainer")) |
374 | | - { |
375 | | - this.Output.WriteLine(e.RawMessage); |
376 | | - } |
377 | | - }; |
378 | | - var dataView = context.Data.LoadFromEnumerable( |
379 | | - new List<TestSingleSentenceData>(new TestSingleSentenceData[] { |
380 | | - new TestSingleSentenceData() |
381 | | - { // Testing longer than 512 words. |
382 | | - Sentence1 = "ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community . ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community . ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community . ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .ultimately feels as flat as the scruffy sands of its titular community .", |
383 | | - Sentiment = "Negative" |
384 | | - }, |
385 | | - new TestSingleSentenceData() |
386 | | - { |
387 | | - Sentence1 = "with a sharp script and strong performances", |
388 | | - Sentiment = "Positive" |
389 | | - }, |
390 | | - new TestSingleSentenceData() |
391 | | - { |
392 | | - Sentence1 = "that director m. night shyamalan can weave an eerie spell and", |
393 | | - Sentiment = "Positive" |
394 | | - }, |
395 | | - new TestSingleSentenceData() |
396 | | - { |
397 | | - Sentence1 = "comfortable", |
398 | | - Sentiment = "Positive" |
399 | | - }, |
400 | | - new TestSingleSentenceData() |
401 | | - { |
402 | | - Sentence1 = "does have its charms .", |
403 | | - Sentiment = "Positive" |
404 | | - }, |
405 | | - new TestSingleSentenceData() |
406 | | - { |
407 | | - Sentence1 = "banal as the telling", |
408 | | - Sentiment = "Negative" |
409 | | - }, |
410 | | - new TestSingleSentenceData() |
411 | | - { |
412 | | - Sentence1 = "faithful without being forceful , sad without being shrill , `` a walk to remember '' succeeds through sincerity .", |
413 | | - Sentiment = "Negative" |
414 | | - }, |
415 | | - new TestSingleSentenceData() |
416 | | - { |
417 | | - Sentence1 = "leguizamo 's best movie work so far", |
418 | | - Sentiment = "Negative" |
419 | | - } |
420 | | - })); |
421 | | - |
422 | | - var experiment = context.Auto().CreateExperiment(); |
423 | | - var chain = new EstimatorChain<ITransformer>(); |
424 | | - var pipeline = chain.Append(context.Transforms.Conversion.MapValueToKey("Label", "Sentiment")) |
425 | | - .Append(SweepableEstimatorFactory.CreateTextClassificationMulti(new TextClassificationOption |
426 | | - { |
427 | | - MaxEpochs = 100, |
428 | | - LabelColumnName = "Label", |
429 | | - })) |
430 | | - .Append(SweepableEstimatorFactory.CreateMapKeyToValue(new MapKeyToValueOption |
431 | | - { |
432 | | - InputColumnName = "PredictedLabel", |
433 | | - OutputColumnName = "PredictedLabel", |
434 | | - })); |
435 | | - experiment.SetPipeline(pipeline) |
436 | | - .SetDataset(dataView, dataView) |
437 | | - .SetMulticlassClassificationMetric(MulticlassClassificationMetric.MacroAccuracy, "Label") |
438 | | - .SetMaxModelToExplore(1); |
439 | | - var cts = new CancellationTokenSource(); |
440 | | - cts.CancelAfter(15_000); |
441 | | - await experiment.RunAsync(cts.Token); |
442 | | - } |
443 | | - } |
444 | | - class TestSingleSentenceData |
445 | | - { |
446 | | - public string Sentence1; |
447 | | - public string Sentiment; |
448 | 363 | } |
449 | 364 |
|
450 | 365 | class DummyTrialRunner : ITrialRunner |
|
0 commit comments