Pythons

django-web on GCE

개요 django-web을 GCE에 설치 및 배포를 간단하게 진행하도록 한다. 사전준비 Google Cloud Platform 회원가입은 미리 진행했고, GCE 인스턴스를 생성할 줄 아는 상태임을 전제로 한다. Miniconda 설치가 끝난 상황임을 가정한다. Miniconda Linux 설치 : https://docs.anaconda.com/free/miniconda/ Miniconda 설치 mkdir -p ~/miniconda3 wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 rm -rf ~/miniconda3/miniconda.sh 설치 후, 새로 설치한 미니콘다를 초기화합니다. 다음 명령은 bash 및 zsh 셸을 초기화 ~/miniconda3/bin/conda init bash ~/miniconda3/bin/conda init zsh django on GCE GCE Shell에서 django를 설치한다.

Spark Code 실행 예제

강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 개요 현재 러닝 스파크 교재를 배우고 있다. 해당 교재는 주로 00.py에서 실행하는 방법으로 안내하고 있지만, Google Colab에서 어떻게 변환하는지 확인해보고자 한다. Spark 설정 Spark 설치 버전은 아래 링크에서 확인한다. 주소 : https://spark.apache.org/downloads.html Download 버튼을 클릭하면 아래와 같은 화면이 나온다. 주소를 복사한다. https://dlcdn.apache.org/spark/spark-3.5.1/spark-3.5.1-bin-hadoop3.tgz Java 설치 아래 코드를 실행한다. !apt-get install openjdk-8-jdk-headless Spark 설치 아래 코드를 실행한다. !wget -q https://dlcdn.apache.org/spark/spark-3.5.1/spark-3.5.1-bin-hadoop3.tgz !tar -zxf spark-3.

Github Actions Hello World From Python Script

개요 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

개요 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!

Streamlit ML Multiclass Classification Model Prediction Sample (feat. Pipeline)

개요 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 ML Model Prediction Sample (feat. Pipeline)

강의소개 인프런에서 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.

openAI API, Text & Image 생성 예제

강의소개 인프런에서 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.

st-pages 라이브러리 소개

강의소개 인프런에서 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 날짜가 최근 날짜에서 멀면 멀수록 관리가 안되고 있다는 것이며, 이 부분은 향후 프로젝트 유지보수할 때 어려움을 겪을 수도 있다.

OpenAI API 인증키 발급

강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 개요 OpenAI API 인증키 발급 OpenAI 회원가입을 이미 한 것으로 전제 인증키 발급 다음 사이트에서 로그인을 한다. https://openai.com/blog/openai-api API를 선택한다. 왼쪽 메뉴에서 API Keys를 선택한다. API Key 획득을 위해 Create New Secret Key 버튼을 클릭한다. 인증키 확인 후, 별도로 저장해야 함

creating multipages in streamlit web using official docs

강의소개 인프런에서 Streamlit 관련 강의를 진행하고 있습니다. 인프런 : https://inf.run/YPniH 개요 streamli을 활용한 멀티페이지 개념 및 구현에 대한 내용을 다룬다. 공식문서 참고 : Create a multipage app : https://docs.streamlit.io/get-started/tutorials/create-a-multipage-app Multipage apps : https://docs.streamlit.io/library/advanced-features/multipage-apps Streamlit에서 multipage란 무엇인가? 앱의 크기가 커질수록 다중 페이지 구성은 관리와 탐색의 용이성을 제공함. Streamlit은 이를 쉽게 가능하게 하며, 클릭 한 번으로 해당 페이지에 빠르게 이동할 수 있다. 폴더 및 파일 구조 Home.py 파일을 만든 후에는 엔트리포인트 파일과 관련된 pages/about.