반응형

golang을 최소 설치를 했더니 귀찮다.

FROM golang:alpine

WORKDIR /app

COPY . ./

RUN go mod download
RUN go mod tidy
RUN go build -o main .

# TimeZone 설정
RUN apk --no-cache add tzdata && \
    cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \
    echo "Asia/Seoul" > /etc/timezone \
    apk del tzdata

CMD ["./main", "1"]
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /App

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out


# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /App
COPY --from=build-env /App/out .

# TimeZone 설정
ENV TZ Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone


ENTRYPOINT ["dotnet", "AnomalyDetection.dll"]
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /App

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /App
COPY --from=build-env /App/out .

# TimeZone 설정
ENV TZ Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone


ENTRYPOINT ["dotnet", "Aru.dll"]
version: '3.3'
services:
  aru_collector:
    image: 'aru_collector'
    volumes:
    - /mnt/d/Data/Aru:/var/pos
    - /mnt/d/ML/Data:/var/data    
    - /mnt/d/data/AruTrigger:/var/trigger    
    environment:
      ENVIRONMENT: linux
    links:
    - "PostgreSQL"
  aru_anomaly_detection:
    image: 'aru_anomaly_detection'
    volumes:
    - /mnt/d/ML/Data:/var/data    
    - /mnt/d/data/AruTrigger:/var/trigger    
    environment:
      ENVIRONMENT: linux
    links:
    - "PostgreSQL"  
  aru:
    image: 'aru'
    volumes:
    - /mnt/d/ML/Data:/var/data    
    - /mnt/d/data/AruTrigger:/var/trigger    
    environment:
      ENVIRONMENT: linux
    network_mode: "host"
  PostgreSQL:
    image: postgres
    environment:
      POSTGRES_PASSWORD: "test"          
    ports:
    - 5432:5432
    volumes:
    - /home/postgreSQL:/var/lib/postgresql/data
    shm_size: 1g

'프로그래밍' 카테고리의 다른 글

docker network mode  (0) 2022.12.06
Postgresql Last Insert Id 얻기  (0) 2022.12.01
golang docker 말기  (0) 2022.11.24
golang 공유 자원 사용하기  (0) 2022.11.03
golang 간단한 pg 라이브러리  (0) 2022.11.02
반응형
  • 알고리즘
    • 변칙 검색이 좋음
  • Input
    • 파티 전체를 하나의 row 넣고 판단하는 게 좋음
    • 필드는 많은 게 좋음
      • 지금 테스트 중인 데이터의 경우 120개 필드로 구성했음

'프로그래밍' 카테고리의 다른 글

Perforce Install in Ubuntu  (0) 2022.10.20
트랜잭션 문제  (0) 2022.10.18
Detect anomalies in product sales with ML.NET  (0) 2022.10.14
jetbrains fleet  (0) 2022.10.13
Golang How to check if a map contains a key  (0) 2022.10.12
반응형

https://learn.microsoft.com/en-us/dotnet/machine-learning/tutorials/sales-anomaly-detection

 

Tutorial: Detect anomalies in product sales - ML.NET

Learn how to build an anomaly detection application for product sales data. This tutorial creates a .NET Core console application using C# in Visual Studio 2019.

learn.microsoft.com

 

https://github.com/dotnet/samples/tree/main/machine-learning/tutorials/ProductSalesAnomalyDetection

 

GitHub - dotnet/samples: Sample code referenced by the .NET documentation

Sample code referenced by the .NET documentation. Contribute to dotnet/samples development by creating an account on GitHub.

github.com

 

잘은 되는 거 같은데 원하는 지점 찾는 게 힘드네!

 

 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

+ Recent posts