본문 바로가기
프로그래밍

[Python] 꿀팁 모음!

by sungkee 2022. 1. 30.
반응형

1. 내 PC에 Tensorflow-GPU 설정하기

https://theorydb.github.io/dev/2020/02/14/dev-dl-setting-local-python/

 

[Setup] 딥러닝 개발 환경 구축 한방에 끝내기

개요 딥러닝이라는 긴 여정을 위한 첫 단계. 딥러닝 개발 환경 구축을 위한 포스팅입니다. 환경설정으로 인한 시간낭비를 최소화 하고자 대부분의 내용을 총정리합니다. 목차 사전 확인사항 및

theorydb.github.io

 

2. Colab 사용하기

https://theorydb.github.io/dev/2019/08/23/dev-ml-colab/

 

[Colab] Google Colab (코랩) 환경설정 및 사용법

개요 파이썬을 활용한 머신러닝의 첫 관문! 구글 Colab(코랩)의 환경구성 및 기본 사용법을 다룬 포스트입니다. 목차 Colab이란 무엇인가? Colab 환경설정 Colab을 활용한 간단한 예제 작성 Colab & Markdow

theorydb.github.io

 

3. Python을 빠르게 사용하고 싶다면

1) Groupby 후 특정 컬럼을 String으로 Join하고 싶을 때, transform 보다 apply를 사용하는 것이 빠르다.

# 컬럼1로 Groupby 하면서 컬럼2를 하나의 String으 Join하고 싶을 때 
# apply로 하는 게 transform으로 하는 것보다 빠르다

df.groupby("컬럼1")["컬럼2"].apply(">".join) 
df.groupby("컬럼명")["컬럼2"].transform(lambda x: ">".join(x))

 

4. 자주 쓰는 conda / pip 명령어

conda info --envs
conda create -n [가상환경이름] python=3.x # python 버전을 넣어줘야 pip 명령어를 사용할 수 있음
conda activate [가상환경이름]
conda remove --name [가상환경이름] --all
conda info --envs
[가상환경경로]\Scripts\activate # 가상환경 활성화하기
python -m virtualenv [가상환경이름] # 가상환경 생성하기

rm -r [가상환경이름] # 가상환경 제거하기
deactivate # 현재 가상환경 비활성화하기

 

5. package 관리

pip freeze > requirements.txt
pip install -r requirements.txt

 

6. mlflow 사용하는 법

가상환경 만들고 실행하기
pip install waitress
pip install mlflow
mlflow ui # 반드시 mlruns가 포함된 상위폴더에서 실행해야 함
>> INFO:waitress:Serving on http://127.0.0.1:5000


import mlflow
from random import random, randint
# 로깅하고자 하는 대상들이 저장될 위치를 지정
mlflow.set_tracking_uri("./mlruns")
experiment_id = mlflow.create_experiment('expeirment4') #새로운 실험생성
experiment = mlflow.get_experiment(experiment_id)
run = mlflow.start_run(run_name = "extra_tree1", experiment_id=experiment.experiment_id)

from pycaret.regression import *
model = load_model('No.1_extratree_230411')

mlflow.sklearn.log_model(model, 'extra_tree')
mlflow.log_param("param1", randint(0, 100))
mlflow.log_metric("foo", random())
mlflow.log_artifacts("conf_matrix.png")

mlflow.end_run()

https://pajamacoder.tistory.com/32

 

[mlflow ] mlflow 소개와 사용 이유 (1/3)

이 포스트에서는 mlflow에 대해 무엇을 하는데 쓸 수 있는 툴들인지 간단하게 설명 하고 앞으로 몇몇 포스트를 추가하여 차근 차근 그 사용법을 좀 더 자세히 기록하고자 한다. mlflow doc: https://www.m

pajamacoder.tistory.com

https://pizzathief.oopy.io/mlflow-tracking-tutorial

 

MLFlow Tracking 튜토리얼

MLFlow 로 머신러닝 모델의 실험 Tracking을 처음 해보는 사람을 위한 간단한 튜토리얼입니다. 제가 처음 해보면서 썼습니다.

pizzathief.oopy.io

https://devinlife.com/mlflow/intro-mlflow/

 

MLflow 소개

MLflow는 머신 러닝 모델을 트레이닝, 배포, 관리를 도와주는 오픈 소스 플랫폼이다

devinlife.com

 

6. 엉뚱한 짓해서 시간 날리지 말기

https://acton21.tistory.com/13

 

파이썬 most likely due to a circular import 오류 해결방법

파이선을 초기에 학습할 때 모듈을 import하고 run을 돌려보니까 most likely due to a circular import 라는 에러가 뜨는 경우가 종종 있습니다. (+ 비슷하게 AttributeError: module 'pandas' has no attribute 'read_csv' 같

acton21.tistory.com

https://rswm-ju.tistory.com/2

 

Python 개발 환경 설정 (Visual Studio Code 활용)

Python의 편집기로 다양한 platform이 존재하지만, 최근에는 Visual Studio Code가 가벼워 많이 활용되고 있다. Python을 Visual Studio Code에서 사용하기 위해서는 복잡한 설치 및 설정 과정이 필요하다. 1. Pytho

rswm-ju.tistory.com

https://www.geeksforgeeks.org/how-to-install-pip-on-windows/

 

How to Install PIP on Windows ? - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org

https://spica910.tistory.com/142

 

[python] pip 설치시 에러문구 - 파일에 바이러스 .....

Python 을 사용하면서 pip를 통해 package를 설치하는 과정에서 에러가 나서 답답했던 적이 있었습니다. 원인을 알고보니 Windows Defender에 의한 것입니다. Error 현상 위의 문제를 해결하기 위해 설정 -

spica910.tistory.com

https://medium.com/analytics-vidhya/how-to-install-jupyter-notebook-using-pip-e597b5038bb1

 

How To Install Jupyter Notebook Using PIP

Jupyter notebooks are pretty much necessary to get going with data science using python or R.

medium.com

VS Code에서 자동완성이 안될때

https://parkjh7764.tistory.com/101

 

비주얼스튜디오 코드 자동완성 안 될 때 / VSCode 자동 완성 오류 안 됨

비주얼스튜디오 코드(Visual Studio Code)를 통해서 코드를 작성할 때 '자동완성' 기능을 정말 유용하게 사용한다. 그러나 가끔 자동완성 기능이 안 먹힐 때가 있다. 내가 해결한 해결책을 알려드리고

parkjh7764.tistory.com

 

 

ChatGPT API 사용하기

https://yeko90.tistory.com/entry/how-to-run-chatgpt-api

 

[챗gpt] chatgpt api 사용법 : 따라하며 배우는 초보자용

챗gpt api가 등장했다. 많은 이들이 "api? 그건 개발자들의 전유물 아니야?" 라고 생각한다. 하지만 그렇게 치부해 버리고 API를 사용하지 않는 건 많은 기회들을 발로 차버리는 거다. api를 통해 여러

yeko90.tistory.com

 

반응형

'프로그래밍' 카테고리의 다른 글

웹개발 관련  (0) 2023.06.28
[프로그래밍] 알고리즘 정리  (0) 2023.05.20
[Python] Tensorflow-gpu 쉽게 사용하는 법!  (0) 2022.02.16

댓글