전체 글 87

RandomForest 다중 출력 알고리즘

MultiOutputClassifier : 다중 분류 알고리즘 - 하나의 데이터를 여러 속성으로 분류하고 싶을 때 사용 from sklearn.datasets import make_classification from sklearn.multioutput import MultiOutputClassifier from sklearn.ensemble import RandomForestClassifier from sklearn.utils import shuffle import numpy as np X, y_11 = make_classification(n_samples=10, n_features=20, n_informative=14, n_classes=3, random_state=1) y_2 = shuffle(y1,..

DeepL API 사용하여 번역 코드 생성

설치 pip install deepl 기본 코드 - 텍스트만 넣어서 번역하는 경우와 파일 전체를 번역하는 경우 두 가지 예시 코드 입니다. 텍스트 번역 def text_translation(): auth_key = "deepl API키" translator = deepl.Translator(auth_key) message = 'Dạo này bạn học tiếng Việt không?' result = translator.translate_text(message, target_lang="KO") return result.text 파일 전체 번역 ex 1) def file_context(file_path): with open(file_path, 'r',encoding='UTF8') as f: # file..

PYTHON/번역기 2024.02.29

Googletrans 사용하여 번역 코드 생성

설치 - pip install googletrans로 설치하면 오류 발생 -> 아래 코드 사용하여 설치 pip install googletrans==4.0.0-rc1 googletrans - 무료 파이썬 라이브러리 - google translate ajax api - 기본 도메인 : Google 번역 Google 번역 사용 중인 브라우저에서는 음성 입력이 지원되지 않습니다. translate.google.co.kr - unlimited 라고 되어있으나 하루 할당량이 있음 (정확하진 않으나 50만자로 예상하고 있음) 기본 코드 # -*- coding: utf-8 -*- from googletrans import Translator import pandas as pd import re from datetim..

PYTHON/번역기 2024.02.29

GPT 기본 코드 공유

설치 openai를 설치하지 않은 상태라면 설치하고 코드 실행하시기 바랍니다. (pip install openai로 하면 AttributeError 등의 오류가 뜰 수 있다. 오류 뜨면 uninstall하고 특정 버전(0.28.1)으로 재설치하기) pip install openai==0.28.1 기본 코드 # -*- coding: utf-8 -*- import pandas as pd import openai import os import time import fitz openai.api_key = 'GPT API키' def get_completion(prompt,model="gpt-3.5-turbo"): messages = [{"role": "user", "content": prompt}] respons..

PYTHON/GPT 2024.02.29

Precision, Recall, F1 Score

정밀도(Precision) : True라고 분류한 것 중에서 실제 True인 것의 비율 날씨 예측 모델이 맑다로 예측했는데, 실제 날씨가 맑았는지를 살펴보는 지표 재현율(Recall) : 실제 True인 것 중에서 모델이 True라고 예측한 것의 비율 실제 날씨가 맑은 날 중에서 모델이 맑다고 예측한 비율 실제 정답(data)의 입장에서 정답을 정답이라고 맞춘 경우 F1 Score : Precision과 Recall의 조화평균