본문 바로가기

코딩코딩81

LinearRegression의 fit_intercept 파라미터 알아보기 fit_intercept를 True로 하면 y절편 값을 구하고, False로 하면 그러지 않는다. 보통 구할 것이므로 디폴트는 fit_intercept=True이다. import numpy as np import matplotlib.pyplot as plt %matplotlib inline np.random.seed(42) # 난수 생성, shape은 100,1 # w0 = 6, w1= 4 X = 2 * np.random.rand(100,1) y = 6 + 4*X + np.random.rand(100,1) plt.scatter(X,y) from sklearn.linear_model import LinearRegression as LR yes_inter = LR(fit_intercept=True) no_i.. 2021. 5. 31.
주피터 노트북 가상환경 커널 추가하기 삭제하기 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(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.