반응형
https://learn.microsoft.com/en-us/dotnet/machine-learning/tutorials/sales-anomaly-detection
https://github.com/dotnet/samples/tree/main/machine-learning/tutorials/ProductSalesAnomalyDetection
잘은 되는 거 같은데 원하는 지점 찾는 게 힘드네!
Console.WriteLine("Detect temporary changes in pattern");
// STEP 2: Set the training algorithm
// <SnippetAddSpikeTrainer>
var iidSpikeEstimator = mlContext.Transforms.DetectIidSpike(outputColumnName: nameof(ProductSalesPrediction.Prediction), inputColumnName: nameof(ProductSalesData.Given), confidence: 99.949, pvalueHistoryLength: docSize / 4);
// </SnippetAddSpikeTrainer>
// STEP 3: Create the transform
// Create the spike detection transform
Console.WriteLine("=============== Training the model ===============");
// <SnippetTrainModel1>
ITransformer iidSpikeTransform = iidSpikeEstimator.Fit(CreateEmptyDataView(mlContext));
// </SnippetTrainModel1>
Console.WriteLine("=============== End of training process ===============");
//Apply data transformation to create predictions.
// <SnippetTransformData1>
IDataView transformedData = iidSpikeTransform.Transform(productSales);
// </SnippetTransformData1>
// <SnippetCreateEnumerable1>
var predictions = mlContext.Data.CreateEnumerable<ProductSalesPrediction>(transformedData, reuseRowObject: false);
// </SnippetCreateEnumerable1>
// <SnippetDisplayHeader1>
Console.WriteLine("Alert\tScore\tP-Value");
// </SnippetDisplayHeader1>
// <SnippetDisplayResults1>
foreach (var p in predictions)
{
var results = $"{idx++}\t{p.Prediction[0]}\t{p.Prediction[1]:f2}\t{p.Prediction[2]:F2}\t";
if (p.Prediction[0] == 1)
{
Console.WriteLine(results);
}
Console.WriteLine(results);
}
'프로그래밍' 카테고리의 다른 글
Perforce Install in Ubuntu (0) | 2022.10.20 |
---|---|
트랜잭션 문제 (0) | 2022.10.18 |
게임 전투 데이터 AI 치터 판별 팁 (0) | 2022.10.17 |
jetbrains fleet (0) | 2022.10.13 |
Golang How to check if a map contains a key (0) | 2022.10.12 |