개요 이전 강의에서 출발한다. Connect To Database in Python 테이블 생성 아래 코드를 작성하면 테이블이 생성된다. import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "root", passwd = "evan", database = "mulcampdb" ) print(mydb) my_cursor = mydb.cursor() query = """ CREATE TABLE users ( name VARCHAR(255) , email VARCHAR(255) , age INTEGER(10) , user_id INTEGER AUTO_INCREMENT PRIMARY KEY ); """ my_cursor.execute(query) my_cursor.execute("SHOW TABLES;") for table in my_cursor: print(table[0]) 파일을 실행한다.
개요 Python과 MySQL을 연동하도록 한다. 프로젝트 폴더에 가상환경이 설치가 되어 있는 것으로 가정한다. MySQL은 기 설치가 되어 있는 것으로 가정한다. 라이브러리 설치 Python과 MySQL을 연동해주는 라이브러리 종류는 다양하게 있다. $ pip install mysql-connector mysql-connector-python 파일 작성 간단하게 파일을 작성한다. import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "root", passwd = "evan" ) print(mydb) 파일을 실행한다. $ python database.py <mysql.connector.connection_cext.CMySQLConnection object at 0x000002BF4E606090> (venv) Python 코드 활용하여 DB 생성 이번에는 코드를 활용하여 Schema를 생성한다.
개요 M1에서 MySQL을 설치 하고 Workbench에 접속하는 과정을 설명한다. 데이터 로드 시, ASCII 에러 과정 해결하는 방법도 살펴본다. (임시방편) 사전학습 brew 명령어를 알고 있는 분에 한해 작성을 하였다. 주의 아래 코드 복사할 시, $ 는 제외 후 복사한다. MySQL 실행 확인 후 프로세스 Kill 먼저 MySQL이 실행중인지를 확인한다. $ brew services list Name Status User File mysql started evan ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist 서비스를 강제 종료한다. $ brew services stop mysql Stopping `mysql`... (might take a while) ==> Successfully stopped `mysql` (label: homebrew.
개요 Python Script를 활용하여 Hell World를 출력한다. 강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 이전 게시글 링크 확인 : Github Actions Hello World main.py 작성 간단하게 아래 코드를 작성한다. 코드 작성은 Github에서도 가능하다. import sys print(sys.version) print("Hello, World") Add file > Create new file 버튼을 클릭한다. Python-hello.yml 파일 변경 기존 코드에서 다음 코드를 추가한다. # This is a basic workflow to help you get started with Actions name: Python-CI .
개요 Github Actions 에서 Hello World를 출력하도록 한다. 강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 사전준비 Github에 적당한 Repo를 준비한다. 메뉴선택 아래 그림에서 Actions 메뉴를 선택한다. 아래 그림에서 set up a workflow yourself 선택 YAML 파일 수정 .github/workflows/main.yaml 파일 선택 후 수정 소스코드는 다음과 같이 지정한다. # This is a basic workflow to help you get started with Actions name: CI # Controls when the workflow will run on: # Triggers the workflow on push or pull request events but only for the "main" branch push: branches: [ "main" ] pull_request: branches: [ "main" ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" build: # The type of runner that the job will run on runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 # Runs a single command using the runners shell - name: Run a one-line script run: echo Hello, world!
개요 Kaggle 데이터셋을 활용하여 Streamlit ML Multiclass Classification Model을 배포한다. 각 코드에 대한 자세한 설명은 여기에서는 생략한다. 데이터 수집 이번에 활용하는 캐글 데이터 수집은 아래 대회에서 train 데이터만 가져왔다. Multi-Class Prediction of Obesity Risk : https://www.kaggle.com/competitions/playground-series-s4e2 Dataset Description은 아래에서 확인하도록 한다. 링크 : https://www.kaggle.com/competitions/playground-series-s4e2/data train.csv 파일만 다운로드 받았다. 모델 개발 다음 코드는 모델을 개발하는 코드이다. 주어진 데이터셋에서 종속변수 NObeyesdad을 예측하는 모델을 구성했다. 파일명 : model.py import pandas as pd from sklearn.
강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 개요 tips 데이터셋을 활용하여 Streamlit ML Model을 배포한다. 각 코드에 대한 자세한 설명은 여기에서는 생략한다. 모델 개발 다음 코드는 모델을 개발하는 코드이다. 주어진 데이터셋에서 tip을 예측하는 모델을 구성했다. 파일명 : model.py import streamlit as st import pandas as pd import seaborn as sns from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline from sklearn.
강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 소스 참조 후루카와 히데카즈 저/트랜스메이트 역. (2023). GPT-4, ChatGPT, 라마인덱스, 랭체인을 활용한 인공지능 프로그래밍 한권으로 끝내는 OpenAI API 기반 LLM 애플리케이션 구축. 위키북스, 판매처 : https://www.yes24.com/Product/Goods/122533123 라이브러리 설치 openai 패키지를 설치한다. !pip install openai Collecting openai Obtaining dependency information for openai from https://files.pythonhosted.org/packages/26/a1/75474477af2a1dae3a25f80b72bbaf20e8296191ece7fff2f67984206f33/openai-1.12.0-py3-none-any.whl.metadata Downloading openai-1.12.0-py3-none-any.whl.metadata (18 kB) . . . [notice] A new release of pip is available: 23.2.1 -> 24.
강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 개요 Streamlit 생태계에 기반한 Components를 살펴본다. st-pages 라이브러리를 확인한다. Components Components는 Streamlit Community와 Creators가 직접 개발한 Streamlit 관련 라이브러리를 말한다. 참고 : https://streamlit.io/components 여기에는 다양한 라이브러리들이 존재한다. 활용법 주의 이러한 라이브러리들을 활용할 때는 Github의 최근 개발 이력을 살펴볼 필요가 있다. 예: spacy-streamlit, https://github.com/explosion/spacy-streamlit 확인해야 하는 것은 최근 Releases 날짜다. Release 날짜가 최근 날짜에서 멀면 멀수록 관리가 안되고 있다는 것이며, 이 부분은 향후 프로젝트 유지보수할 때 어려움을 겪을 수도 있다.
강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 개요 OpenAI API 인증키 발급 OpenAI 회원가입을 이미 한 것으로 전제 인증키 발급 다음 사이트에서 로그인을 한다. https://openai.com/blog/openai-api API를 선택한다. 왼쪽 메뉴에서 API Keys를 선택한다. API Key 획득을 위해 Create New Secret Key 버튼을 클릭한다. 인증키 확인 후, 별도로 저장해야 함