Skip to content

Commit 8029cc1

Browse files
API 2.0 skeleton (dotnet#149)
Incorporating API review feedback
1 parent ad8c28e commit 8029cc1

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading;
6+
using Microsoft.Data.DataView;
7+
using Microsoft.ML.Core.Data;
8+
using Microsoft.ML.Data;
9+
10+
namespace Microsoft.ML.Auto.APINew
11+
{
12+
public static class MLContextExtension
13+
{
14+
public static AutoInfereceCataglog AutoInference(this MLContext mlContext)
15+
{
16+
return new AutoInfereceCataglog();
17+
}
18+
}
19+
20+
public class ExperimentSettings
21+
{
22+
public uint MaxInferenceTimeInSeconds;
23+
public bool EnableCaching;
24+
public CancellationToken CancellationToken;
25+
}
26+
27+
public class RegressionExperimentSettings : ExperimentSettings
28+
{
29+
public IProgress<Data.RegressionMetrics> ProgressCallback;
30+
public Data.RegressionMetrics OptimizingMetrics;
31+
public RegressionTrainer[] WhitelistedTrainers;
32+
}
33+
34+
public enum RegressionMetric
35+
{
36+
RSquared
37+
}
38+
39+
public enum RegressionTrainer
40+
{
41+
LightGbm
42+
}
43+
44+
public class ColumnInfereceResults
45+
{
46+
public TextLoader.Arguments TextLoaderArgs;
47+
public ColumnInformation ColumnInformation;
48+
}
49+
50+
public class ColumnInformation
51+
{
52+
public string LableColumn;
53+
public string WeightColumn;
54+
public IEnumerable<string> CategoricalColumns;
55+
}
56+
57+
public class RegressionExperiment
58+
{
59+
public RunResult<RegressionMetric> Execute(IDataView testData, ColumnInformation columnInformation = null, IEstimator<ITransformer> preFeaturizers = null)
60+
{
61+
throw new NotImplementedException();
62+
}
63+
64+
public RunResult<RegressionMetric> Execute(IDataView testData, IDataView validationData, ColumnInformation columnInformation = null, IEstimator<ITransformer> preFeaturizers = null)
65+
{
66+
throw new NotImplementedException();
67+
}
68+
69+
public RunResult<RegressionMetric> Execute(IDataView testData, uint numberOfCVFolds, ColumnInformation columnInformation = null, IEstimator<ITransformer> preFeaturizers = null)
70+
{
71+
throw new NotImplementedException();
72+
}
73+
}
74+
75+
public class AutoInfereceCataglog
76+
{
77+
RegressionExperiment CreateRegressionExperiment(uint maxInferenceTimeInSeconds)
78+
{
79+
return new RegressionExperiment();
80+
}
81+
82+
RegressionExperiment CreateRegressionExperiment(RegressionExperimentSettings experimentSettings)
83+
{
84+
return new RegressionExperiment();
85+
}
86+
87+
public ColumnInfereceResults InferColumns()
88+
{
89+
throw new NotImplementedException();
90+
}
91+
}
92+
93+
public class RunResult<T>
94+
{
95+
public readonly T Metrics;
96+
public readonly ITransformer Model;
97+
public readonly Exception Exception;
98+
public readonly string TrainerName;
99+
public readonly int RuntimeInSeconds;
100+
101+
internal readonly Pipeline Pipeline;
102+
internal readonly int PipelineInferenceTimeInSeconds;
103+
104+
internal RunResult(
105+
ITransformer model,
106+
T metrics,
107+
Pipeline pipeline,
108+
Exception exception,
109+
int runtimeInSeconds,
110+
int pipelineInferenceTimeInSeconds)
111+
{
112+
Model = model;
113+
Metrics = metrics;
114+
Pipeline = pipeline;
115+
Exception = exception;
116+
RuntimeInSeconds = runtimeInSeconds;
117+
PipelineInferenceTimeInSeconds = pipelineInferenceTimeInSeconds;
118+
119+
TrainerName = pipeline?.Nodes.Where(n => n.NodeType == PipelineNodeType.Trainer).Last().Name;
120+
}
121+
}
122+
}

0 commit comments

Comments
 (0)