본문 바로가기

전체 글19

python, Jupyter notebook 한글 깨짐 해결, figure 한글 쓰기 주피터를 바로 깔고 나서는 한글이 들어간 그림을 그릴 수 없다. 왜냐면 python matplotlib에 기본 폰트중에 한글 지원 가능한 폰트가 없기 때문이다! 그래서 아래와 같이 된다. import matplotlib.pyplot as plt plt.figure(figsize=(5,5)) x=list(range(10)) y=x plt.scatter(x,y) plt.grid() plt.title('한글을 쓰고싶어!!!') plt.show() 해결은 간단하다. 라이브러리에 한글폰트를 넣어주면 되는것. 1) 우선 한글 폰트를 하나 가져오자. 본인 컴퓨터에 있는걸 가져와도 되고, 적당히 인터넷에서 나눔명조 다운로드를 써서 .~.ttf 파일을 받아온다. 2) 본인 matplotlib에 ttf파일 모아놓은 곳이 .. 2023. 6. 23.
matplot colormap, cmap 사용자 정의 팔렛트 만들기 # 그림용 데이터 프레임 생성 tmp = pd.DataFrame({'팔렛트만들기':list(range(38))}) tmp = tmp.T # 사용할 팔렛트 불러오기 cmap = matplotlib.colors.LinearSegmentedColormap.from_list("", ['#cc3300','#ff9966','#ffcc00','#99cc33','#339900']) # 그림그리기 plt.figure(figsize=(15,1)) ax = sns.heatmap(tmp, cmap=cmap, linewidths=1, linecolor='white') colorbar = ax.collections[0].colorbar ax.set_xticklabels([]) plt.show() 2023. 6. 23.
matplotlib cmap 뒤집기 cmap.reversed() # 그림용 데이터 프레임 생성 tmp = pd.DataFrame({'GnBu':list(range(38))}) tmp = tmp.T # 사용할 팔렛트 불러오기 cmap = plt.cm.get_cmap("GnBu") # 그림그리기 plt.figure(figsize=(15,1)) ax = sns.heatmap(tmp, cmap=cmap, linewidths=1, linecolor='white') colorbar = ax.collections[0].colorbar ax.set_xticklabels([]) plt.show() # 그림용 데이터 프레임 생성 tmp = pd.DataFrame({'reverse_GnBu':list(range(38))}) tmp = tmp.T # 사용할 팔렛트 불러오기 cmap = p.. 2023. 6. 23.
Logistic regression 하이퍼 파라메터 설정하기 https://www.kaggle.com/code/funxexcel/p2-logistic-regression-hyperparameter-tuning P2 : Logistic Regression - hyperparameter tuning Explore and run machine learning code with Kaggle Notebooks | Using data from Breast Cancer Wisconsin (Diagnostic) Data Set www.kaggle.com 요약 1) solver, 비용 함수를 최소화하는 매개변수 가중치를 찾는 모델들 https://towardsdatascience.com/dont-sweat-the-solver-stuff-aea7cddc3451 Don’t Sweat.. 2023. 6. 22.