본문 바로가기

Programming Languages68

Chapter 17. Matplotlib 목차 1. matplotlib Python 프로그래밍 언어 및 Numpy 라이브러리를 활용한 플로팅 라이브러리입니다. 범용 GUI 툴킷을 사용하여 애플리케이션에 플롯을 포함하기 위한 객체 지향 API를 제공합니다. a. linear equation _, axe = plt.subplots() x = np.arange(10) y = x*5+10 axe.plot(x,y) b. quadratic equation _, axe = plt.subplots() x = np.linspace(2,4,10) y = 2*x*x+5 axe.plot(x,y) c. normal distribution _, axe = plt.subplots() x = np.linspace(-5,5,100) mu = 0 sig = 1 pi = np... 2023. 4. 5.
Chapter 16. Numpy Chapter 16. Numpy 1. Numpy ⦁ numpy는 대규모 다차원 배열을 쉽게 처리할 수 있도록 지원하는 파이썬의 라이브러리 ⦁ numpy 명령 프롬프트에서 설치하며, jupyter notebook 내에서는 pip 앞에 !를 붙여 설치 pip install numpy ⦁ numpy를 import하여 사용 가능하며 대부분 np로 사용하기 때문에 as로 사용이름 변경 import numpy as np 2. Numpy array ⦁ np.array(list)를 사용하면 numpy list가 됨 # numpy array a1 = np.array([1,2,3,4,5]) print([1,2,3,4,5]) print(a1) print(type(a1)) # 결과값 [1, 2, 3, 4, 5] [1 2 3 .. 2023. 3. 29.
Chapter 15. Requests Chapter 15. Requests 1. Requests ⦁ requests를 import하여 사용 가능 ⦁ get함수를 사용하여 url을 통해 데이터를 가져옴 a. requests # requests import requests x = requests.get('https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data') print(x.text) # 결과값 5.1,3.5,1.4,0.2,Iris-setosa 4.9,3.0,1.4,0.2,Iris-setosa ...... 6.2,3.4,5.4,2.3,Iris-virginica 5.9,3.0,5.1,1.8,Iris-virginica 2. UCI Machine Learning Reposi.. 2023. 3. 28.
Chapter 14. Math, Test, Sort Chapter 14. Math, Test, Sort 1. Math ⦁ math 라이브러리를 import하여 사용 가능 ⦁ 각 함수를 직접 만들어 사용 가능 ⦁ 주로 평균, 중간값, 편차, 분산, 표준편차 등을 사용 a. math # math import math # 평균 def mean(num_list): return sum(num_list)/len(num_list) # 중간값 def median(num_list): num_list.sort() if len(num_list)%2==1: #//는 몫만 가지고 옴 i = (len(num_list))//2 return num_list[i] else: i = len(num_list)//2 return (num_list[i] + num_list[i-1])/2 # .. 2023. 3. 20.
Chapter 13. 문자열 정리 Chapter 13. 문자열 정리 1. 문자열 정리 ⦁ 직접 함수를 만들어 문자열 정리 ⦁ replacing, my split 총 2가지 경우의 함수를 정의 a. replacing # replacing s = '맞춤형건강클리닉, 건강증진,인천광역시 연수구 함박뫼로 13, 인천광역시 연수구 청학동 465-4, 37.41913159,126.6711606, "치매검진, 당뇨.고혈압 상담 및 검사, 뇌경색.심뇌혈관질환, 정신건강 상담", 09:00,18:00, "일요일, 공휴일", 30,0,5,0,0,0, 검사전날 오후8시 전까지 식사마치고 검사당일 아침 금식, 032-749-8104,맞춤형건강클리닉,032-749-8122,인천광역시 연수구 보건소,2021-10-25,3520000,인천광역시 연수구' # 큰따옴.. 2023. 3. 20.
Chapter 12. 클래스 Chapter 12. 클래스 1. 클래스 ⦁ 클래스는 똑같은 무엇인가를 계속해서 만들어 낼 수 있는 설계 도면 역할을 함 ⦁ 객체는 클래스로 만든 피조물을 말함 ⦁ 동일한 클래스로 만든 각각의 객체들은 서로 영향을 끼치지 않음 ⦁ 인스턴스는 클래스로 만든 객체를 말함 ⦁ 객체와 인스턴스의 차이 - 객체와 인스턴스의 차이는 인스턴스가 특정 객체가 어떤 클래스의 객체인지를 관계 위주로 설명할 때 사용 - 예를 들면 a=Class()를 하면 a는 객체라고 하고, a 객체는 Class의 인스턴스라고 표현함 2. Example a. myclass # myclass class myclass: myvar1 = 10 myvar2 = 'abc' # 생성될 때 실행 def __init__(self, a=0, b='aaa'.. 2023. 3. 17.