본문 바로가기

분류 전체보기

(18)
너비우선탐색문제 www.codingame.com/ide/puzzle/skynet-revolution-episode-1 Coding Games and Programming Challenges to Code Better CodinGame is a challenge-based training platform for programmers where you can play with the hottest programming topics. Solve games, code AI bots, learn from your peers, have fun. www.codingame.com 주어진 그래프에서 Agent가 출구로 나가지 못하도록 노드 사이의 간선을 끊는 것이 이 게임의 목적이다. 즉, Agent에서 출구까지의 경로를 찾고 마지막 ..
4-2. 머신러닝(SVM, Cross Validation, GridSearch) SVM은 머신러닝 방법 중 하나이다. 아래 사이트의 학습 알고리즘들을 제공한다. scikit-learn.org/stable/auto_examples/classification/plot_classifier_comparison.html Classifier comparison — scikit-learn 0.23.2 documentation Note Click here to download the full example code or to run this example in your browser via Binder Classifier comparison A comparison of a several classifiers in scikit-learn on synthetic datasets. The point o..
4-1. 머신러닝 svm을 이용해서 머신러닝을 구현할 수 있다. clf = svm.SVC() clf.fit(data, label)#학습: (데이터배열, 답배열) pre = clf.predict(data)#예측: (예측할 데이터) 1. xor 만들기 from sklearn import svm, metrics #파이썬 머신러닝프레임워크 data = [[0,0], [0,1], [1,0], [1,1]] label = [0,1,1,0] #데이터 학습시키기 clf = svm.SVC() clf.fit(data, label)#학습 #데이터 예측하기 pre = clf.predict(data)#예측 print("예측결과:", pre) #결과 확인 ac_score = metrics.accuracy_score(label, pre)#진짜답, 예..
The gift(그리디 알고리즘) www.codingame.com/training/medium/the-gift Practice Greedy algorithms with the exercise "The Gift" Want to practice coding? Try to solve this puzzle "The Gift" (25+ languages supported). www.codingame.com 문제: 선물의 가격과 n인 의 소지금을 입력하면 가장 공평하게 지불할 수 있는 방법 찾기 경우의 수를 살펴보자 1)선물이 300원이고 3인 각자 120원씩 있다면 -> 모두 100원씩 지불한다 2)선물이 300원이고 3인이 각자 50원, 200원, 200원이 있다면 -> 50원, 125원, 125원씩 지불한다 3)선물이 300원이고 3인이 각자..
Chuck Norris 문제풀이 https://www.codingame.com/training/easy/chuck-norris Practice Strings and Encoding with the exercise "Chuck Norris" Want to practice Strings and encoding? Try to solve the coding challenge "Chuck Norris". www.codingame.com 위 문제는 크게 2가지로 파트로 나눌 수 있다. 1.이진수변환 2.chuck norris 변환 이다. 이 부분들을 함수로 놓고 코딩을 하면 된다. 1. 이진수 변환 이진수를 변환할 때 어떤 방법을 쓸까? 학교에서는 10진수가 있으면 이를 2로 나누어 가면서 나머지를 역순으로 쓰면 된다고 배웠다. 이를 코드로 써보..
2. 스크래이핑 1. 쿠키를 이용한 접근: 한빛출판네트워크에 로그인해서 쇼핑정보 가져오기 F12의 네트워크 탭을 킨 상태로 로그인을 하여 확인해 보면 로그인 데이터가 POST방식으로 login_proc.php로 이동하는 것을 알 수 있다. import requests from bs4 import BeautifulSoup from urllib.parse import urljoin USER=" " PASS = " " session = requests.session() login_info = { "m_id": USER, "m_passwd": PASS } #POST로 데이터 보내기 url_login = "http://hanbit.co.kr/member/login_proc.php" res = session.post(url_log..
[패키지]dlib 설치하기 1. dlib를 다운받는다(좌측메뉴 하단에 있다) dlib.net/ 2. cmake를 설치한다. installer(msi파일)로 설치하는 것이 편하다. cmake.org/download/ 3. 명령프롬프트로 dlib 폴더 내의 src폴더로 이동해서 python setup.py build 를 입력한다. (꽤 오래 걸린다) 4. 위 과정이 끝나면 python setup.py install 을 입력한다. + pip list나 import dlib 해봐서 설치를 확인한다
1. 웹크롤링과 스크레이핑 0. BeautifulSoup, requests 설치 1. 실습 1: 내가 만든 html에서 데이터 가져오기 from bs4 import BeautifulSoup html=""" h1태그의 텍스트 p1태그의 텍스트1 p태그의 텍스트2 span.value").string print("환율=", price) 브라우저에서 궁금한 요소에 대고 우클릭>검사 로 해당 페이지의 html을 볼 수 있다. 이를 활용하여 soup에 해당 요소의 css 선택자를 넣으면 데이터를 가져올 수 있다. +cron을 명령어로 코드(크롤링+저장)를 주기적으로 수행시켜 데이터를 원하는 기간마다 수집할 수 있다.