두 용어 모두 개념이 비슷함. 다만 서로 다른 연구 분야에서 기인했음.

여기에 한국어 용어까지 더해지면서 헷갈림의 대환장 파티가 벌어짐.

사실상 기억해야 하는건

1. (진단/실제참거짓) 두가지 요인에 의한 4가지 조합(TP/FP/FN/TN) +연구분야에따른 용어 차이.

2. 각자 조합에 해당하는 한국어 용어(ex. 민감도,위양성율,특이도)

3. 조합간의 상관관계(ex. FPR/TPR은 비례한다) -> 아래 그림, 예시로 이해하면 편함.

4. 사용하는 metric들의 정의

 

1.FAR/FRR

FAR/FRR은 생체인식 부분에서 쓰임

FAR = False Acceptance Rate : 잘못함(우선 답하고 다름) + Acceptance(허용함) -> 허용했는데 잘못함 -> 원래 거절해야하는데 허용함.

FRR = False Rejection Rate : 잘못함(우선 답하고 다름) + Rejection(거절함) -> 거절했는데 잘못함 -> 원래 허용해야하는데 거절

행동/정답 Acceptance Rejection
Acceptance 잘함 True Acceptance  못함 False Acceptance
Rejection 못한 False Rejection 잘함 True Rejection

함.

 

2.False Positive/ False Negative

: IDS(Intrusion Detection System, 침입방지 시스템)에서 기인함.

위 내용과 비슷. 자세히는

False Positive( 알람이 울렸으나 잘못함 -> 공격이 발생하지 않았으나 알람 울림)

False Negative( 알람이 안울렸으나 잘못함 -> 공격이 발생하였으나 알람 안울림)

행동/정답 True False
Positive 잘함 True Positive= 민감도,양성율 못함 False Positive=위양성율
Negative 못함 False Negative 잘함 True Negative = 특이도

3. TPR/FPR(민감도,특이도=TAR/FAR)

:위의 네가지 용어(두 분야라 총 8가지)중 TPR/FPR은 대부분의 classification에서 사용하는 metric인 ROC curve를 그리는데 사용한다. TPR/FPR은 서로 비례하는 관계가 있으므로 curve를 그려 성능을 확인한다. 자세한건 6.단락 확인

-TPR : True Positive Rate(민감도)

-FPR : False Positive Rate(1-특이도)

4.Acc/Precision/Recall/F1

~classfier에는 한 metric으로 무조건 좋다 나쁘다를 판단하기 힘들다. 실제 태스크를 보고 중요한 metric을 골라야 한다.

 보통 쓰는 metric에는 Precision/Recall/F1/Acc이 있다. 

 -Acc = (TP+TN)/(TP+TN+FN+FP)  : 전체중에 옳게 판단한 비율  

 -precision =TP/(TP+FP) : 참이라고 판단한것중 실제로도 참인 비율

 -Recall = TP/(TP+FN) : 실제참인것들중 참이라고 판단한비율  

 -F1 = 2*(Precision*Recall)/(Precision + Recall)

       : Precision과 Recall의 balnce를 찾고싶을때 사용 병의 진단같은경우처럼 다수의 True negative의 수가 많고 중요         한 정보가 아니고 FN과 FP에 좀더 중요성을 싣고 싶을때 사용.(uneven class distribution일때)

 -AUC=ROC curve의 밑면적(Area Under a ROC Curve), [0,1]의 범위, 1에 가까울수록 좋음. 아래 그림 참조.

출처 : https://newsight.tistory.com/53

 

5. 중요한 이슈

생체인식같은경우 -> FAR (다른사람 침입했는데 accept 해줌) ->인증보안 실패

IDS 같은경우 -> False Negative (공격했는데 알람 안울림) -> 공격감지 실패

 

6. 경향성

1,2번 모두 Threshold 에 대한 문제.

출처 : https://en.wikipedia.org/wiki/Sensitivity_and_specificity

-IDS : 알람에 대한 기준을 높이면 False Positive는 줄어들지만 True Positive도 같이줄어듦 or False Negative도 같이 올라감.  -> 민감도를 낮추면 오경보 횟수도 줄어들지만 실제 적이 침입했을때 경보를 안울릴 확률도 올라감.

 

-생체인식 : 보안 기준을 높이면 False acceptance는 줄어들지만 True acceptance도 같이 줆어듦 or False rejection도 같이 올라감

             -> 기준을 높이면 다른사람 침입을 잘 막지만 내가 들어가고싶을때도 막을 확률이 올라감.

 

 

FAR줄임-> TAR줄어듬 의 경향성이 있으므로 성능을 측정하거나 비교할때는 보통 아래와 같은 두가지 방법 사용.

 

1) ROC curve를 그림

출처 : https://en.wikipedia.org/wiki/Receiver_operating_characteristic

2) TAR@FAR=1% 같은 조건을 걸고 성능 측정

출처 : https://www.slideshare.net/ifkakao/ss-115328045

7. 보충

-완벽한 classifier는 TAR1@ FAR 0 -> ROC curve에서 왼쪽 위 = IDS 사진에서 두 분포가 완전히 분리 되어 두분포 사이에 경계 기준을 세울때. 아래 그림 참조

 

-ROC AUC=AUROC

-PR_AUC = Precision과 Recall 의 curve에 대한 면적 , ROC AUC와 개념은 비슷하나 상대적으로 ROC_AUC가 robust한 성능평가가 가능한것으로 알려져있다. 하지만 data imbalnce가 심한경우, PR_AUC를 쓰는것이 좋다.    

 

-micro F1 score= 전체 class에서 한번에 precision, recall을 구해서 f1을 구함 -> Accuracy와 동치.

-macro F1score= class별로 f1구한후 산술평균

 

 

보충부분 출처 : newsight.tistory.com/53

 

ROC curve, ROC_AUC, PR_AUC, 민감도, 특이도

ROC curve (Receiver Operating Characteristic curve) : FPR과 TPR을 각각 x,y축으로 놓은 그래프. ROC curve는 X,Y가 둘다 [0,1]의 범위이고, (0,0) 에서 (1,1)을 잇는 곡선이다. - ROC 커브는 그 면적이 1에..

newsight.tistory.com

틀리거나 궁금한점 있으시면 댓글 남겨주세요!

'인공지능 > 기타' 카테고리의 다른 글

뇌출혈(Intracranial hemorrhage) 정리  (0) 2021.02.01

올해 첫 시작으로 missing semester 를 다 듣는것을 목표로 잡았다.

한 강좌씩 exercise까지 풀이하여 블로그에 정리하려 한다. (~1/15)

는 다른 업무로 실패. 천천히 시간날때 하나씩 올리겠다. 

매번 리눅스 명령어 찾아보는데 시간도 많이들고 자꾸 까먹는것 같아 한번 들어보려 한다.

 

 

 

 

 

 

Motivation : 대부분 gui로 프로그램에 인풋을 넣고 작업할 수 있지만, 프로그램을 완전히 활용하진 못한다.

우리는 버튼만 누를 수 있고 문제점이 있다면 복사 붙여넣기 정도밖에 못한다.  그러므로 그 프로그램들이 어떻게 만들어지는지, 컴퓨터와 어떤관련이 있는지를 알아야한다. 내부에 숨어져있는 연결을 알지 못하면 그저 우리에겐 magical incantation일 뿐이다.

 

Class structure : 1시간짜리 11강의

 

Topic1: The shell

using the shell

-컴퓨터는 명령어를 받기위한 많은 인터페이스가 있다. GUI, voice, AR/VR등... 하지만 대부분들은 유저가 할 수 있는것들이 제한 되어있다.(버튼이 없는곳을 못누른다거나 프로그램 되어있지 않은 명령어를 준다던가) 최대한 활용하기 위해서는 아래 레벨로 내려와서 textual interface인 The shell을 공부해야 한다.

Shell은 종류가 많지만 여기선 Bourne Again SHell, "Bash"를 배운다. 가장 많이 쓰이며 다른 shell과 syntax가 비슷하다.

 

위부터

1)missing: machine name

2)날짜

3)echo라는 프로그램을 hello 라는 argument로 실행

그러면 shell은 어떻게 프로그램(echo)인지 알고 실행하는 걸까?

-> shell은 python같은 programming environment이기 때문에 변수,조건문,루프,함수들이 있다. 만약 내가 command를 입력하면 shell은 이 적은양의 코드를 interpret하는 효과와 같다. 만약 command가 shell의 key word가 아니라면

$PATH 라는 곳에서 있는 프로그램인지 찾아본다. 찾아서 있으면 run 한다

 

위부터

echo $PATH : 프로그램을 찾아보는 directory 위치 

which echo : echo라는 프로그램이 어디있는지, 어디에 있는 프로그램을 실행시켰는지 찾음

/bin/echo $PATH : 어떤 프로그램 쓸지 명확히 정해줌(/bin/echo), argument 건내줌( $PATH)

 

 

Navigating in the shell

shell에서 path는 / 또는 \로 나눠진다.(linux,macOS: '/', windows:'\')

리눅스,맥은 '/'이 root 로 써 모든 directorie가 이 아래 있는 반면에

윈도우는 각 disk partition마다 하나의 루트가 있다. (ex) C:\)

주소중 / 로 시작하는것은 절대경로(absolute path)라고 하고 

다른 path(pwd, '.', '..')을 이용하는것은 Relative path라고 한다.

 

cf) shell prompt는 옆에 뜨는 missing:~$을 의미, 또는 계속 입력을 받는 프로그램

'-', '--'로 시작하는것은 option, ex) -h or --help는 help text를 띄워줌.

drwxr-xr-x 1 중

첫번쨰 d= directory임을 의미

다음 세문자(wxr) : file owner의 permission -> write, excute, read

다음 세문자(-xr): owning group의 permisssion

다음 세문자(-x): everyone else의 permission 

 

cf)이외에 유용한 program : cp, mkdir, mv, man(manual program)

 

Connecting programs

파일에 input, output stream과 관련해서'<' '>' 사용 가능

'>>' : append to a file

'|' : program chain 할때 사용, 한 프로그램의 아웃풋이 다른프로그램의 인풋일때

 

A versatile and powerful tool

sudo : 'super user' or 'root' 로써 파일 실행.

root로써 실행해야 하는 파일중 하나는 /sys.sysfs에 있는 sysfs(filesystem)들이다.

ex) /sys/class/backlight으로 brightness 조절 가능

find로 찾아서 들어가서 brightness에 3 입력 -> sudo 필요

|, >, < 같은 Operation들은 echo 프로그램이 아닌 shell에 의해서 실행된다. 프로그램들은 그저 아웃풋 인풋을 받을 뿐이다.

위같이 sudo echo 3 > brightness 로 치면 shell이 brightness라는 system file을 여는것이므로 권한이 없다(shell은 현재 user 권한만 가지고있다). 그러므로 tee (/sys파일을 열기위한 프로그램)을 이용하여 root 권한으로 설정해야한다.

 

Exercise

  1. For this course, you need to be using a Unix shell like Bash or ZSH. If you are on Linux or macOS, you don’t have to do anything special. If you are on Windows, you need to make sure you are not running cmd.exe or PowerShell; you can use Windows Subsystem for Linux or a Linux virtual machine to use Unix-style command-line tools. To make sure you’re running an appropriate shell, you can try the command echo $SHELL. If it says something like /bin/bash or /usr/bin/zsh, that means you’re running the right program.
  2. Create a new directory called missing under /tmp.
  3. Look up the touch program. The man program is your friend.
  4. Use touch to create a new file called semester in missing.
  5. Write the following into that file, one line at a time:

    #!/bin/sh

    curl --head --silent https://missing.csail.mit.edu

     

    The first line might be tricky to get working. It’s helpful to know that # starts a comment in Bash, and ! has a special meaning even within double-quoted (") strings. Bash treats single-quoted strings (') differently: they will do the trick in this case. See the Bash quoting manual page for more information.
  6. Try to execute the file, i.e. type the path to the script (./semester) into your shell and press enter. Understand why it doesn’t work by consulting the output of ls (hint: look at the permission bits of the file).
  7. Run the command by explicitly starting the sh interpreter, and giving it the file semester as the first argument, i.e. sh semester. Why does this work, while ./semester didn’t?
  8. Look up the chmod program (e.g. use man chmod).
  9. Use chmod to make it possible to run the command ./semester rather than having to type sh semester. How does your shell know that the file is supposed to be interpreted using sh? See this page on the shebang line for more information.
  10. Use | and > to write the “last modified” date output by semester into a file called last-modified.txt in your home directory.
  11. Write a command that reads out your laptop battery’s power level or your desktop machine’s CPU temperature from /sys. Note: if you’re a macOS user, your OS doesn’t have sysfs, so you can skip this exercise.

A:

1. A: $SHELL 결과 /bin/bash 출력됨. 현재 linux18.04.4 LTS에서 작업중

2. mkdir /tmp/missing

3. man touch

4. touch semester(@/tmp/missing)

5. echo -e '#!/bin/sh\ncurl --head --silent https://missing.csail.mit.edu 

6. 7.ls -l로 확인결과 semester file에 x(execute) 권한이 없음

8. chmod + -로 권한을 주고 뺏을 수 있음

9. chmod +xr shemester

10. ./semester | grep -i last | cut -d ' ' -f 2- >/home/last-modified.txt

11. cat /sys/devices/virtual/thermal/thermal_zone0

 

 

The Missing Semester of Your CS Education

The Missing Semester of Your CS Education Classes teach you all about advanced topics within CS, from operating systems to machine learning, but there’s one critical subject that’s rarely covered, and is instead left to students to figure out on their

missing.csail.mit.edu

 

 

 

 

참고 : missing.csail.mit.edu/2020/course-shell/

+ Recent posts