본문 바로가기

분류 전체보기216

주피터 노트북 가상환경 커널 추가하기 삭제하기 conda activate 가상환경이름 pip install ipykernel python -m ipykernel install --user --name 커널이름 jupyter kernelspec uninstall 커널이름 2021. 5. 16.
ValueError: Setting a random_state has no effect since shuffle is False. You should leave random_state to its default (None), or set shuffle=True. 발생 이유 from sklearn.model_selection import KFold rkf = KFold(n_splits=5, random_state=42) 하이퍼 파라미터 중 random_state를 설정해놓고, shuffle=True 설정을 안 해줘서 그렇다. 랜덤의 여지가 없는데 랜덤하게 하라고 명령한 것이다. 해결방법 from sklearn.model_selection import KFold kf = KFold(n_splits=5, shuffle=True, random_state=42) 하이퍼 파라미터에 shuffle=True를 넣어준다! 해결 완료. 2021. 4. 28.
[프로그래머스] 전화번호 목록 내가 짠 코드 def solution(phone_book): phone_book = list(map(int, phone_book)) phone_book.sort() phone_book = list(map(str, phone_book)) for idx in range(len(phone_book)-1): target = phone_book.pop(0) for number in phone_book: if number[:len(target)] == target: return False return True 문제점: 하나씩 줄어들기 때문에 어느정도 속도가 나오긴 하지만, 그럼에도 불구하고 불필요한 비교를 한다. O(n)의 반복 수행이랄까,,, 사실 n은 1씩 줄어들긴 하지만 어쨋거나 O(n)의 반복. 빠른 해결책.. 2021. 4. 26.
[프로그래머스] 모의고사 내 코드 def solution(answers): s1, s2, s3 = 0,0,0 n = len(answers) c = n//40+1 a1 = [1,2,3,4,5]*(8*c) a2 = [2,1,2,3,2,4,2,5]*(5*c) a3 = [3,3,1,1,2,2,4,4,5,5]*(4*c) for i in range(n): if answers[i] == a1[i]: s1 += 1 if answers[i] == a2[i]: s2 += 1 if answers[i] == a3[i]: s3 += 1 scores = [s1,s2,s3] m = max(scores) winners = [] for i in range(3): if scores[i] == m: winners.append(i+1) return winners .. 2021. 4. 25.