본문 바로가기
반응형

python338

sklearn을 활용하여 아이리스 데이터 분류 모델 만들기 sklearn을 활용하여 아이리스 데이터 분류 모델 만들기¶ 1. 데이터 불러오기(data road)¶ In [1]: from sklearn.datasets import load_iris iris = load_iris() 2. 데이터 소개(data introduce) 및 학습 데이터 구성¶ 아이리스 데이터 데이터 프레임으로 보여주기 show Iris data as DataFrame ¶ In [2]: import pandas as pd df = pd.DataFrame(iris.data, columns=iris.feature_names) sy = pd.Series(iris.target, dtype="category") sy = sy.cat.rename_categories(iris.target_names) d.. 2023. 6. 25.
Input vector should be 1-D. Input vector should be 1-D. 차원 error 입니다. 입력 데이터 차원을 아래 모양에서 # Define two sequences sequence1 = [1, 2, 3, 4, 5] sequence2 = [2, 3, 4, 5, 6] 아래 모양과 같이 변경해 주세요 ! # Define two sequences sequence1 = np.array([[1, 2, 3, 4, 5]]) sequence2 = np.array([[2, 3, 4, 5, 6]] 2023. 6. 23.
넘파이 최대값 최소값, 넘파이 행별 최대값 넘파이 최대값 최소값, 넘파이 행별 최대값 최대값 np.max import numpy as np arr = np.array( [[5,8,5,3,3], [2,1,3,0,0]] ) np.max(arr) # out: 8 최소값 np.min import numpy as np arr = np.array( [[5,8,5,3,3], [2,1,3,0,0]] ) np.min(arr) # out : 0 행별 최대값 np.max axis=1 import numpy as np arr = np.array( [[5,8,5,3,3], [2,1,3,0,0]] ) np.max(arr, axis=1) # out : array([8, 3]) 열별 최대값 np.max axis=1 import numpy as np arr = np.array.. 2023. 6. 22.
파이썬 리스트 최대값 최소값 파이썬 리스트 최대값 최소값 최대값 max() li = [2, 5, 7, 8, 4, 2, 1] max(li) # out : 8 최소값 min() li = [2, 5, 7, 8, 4, 2, 1] min(li) # min : 1 넘파이 최대값 최소값 최대값 np.max import numpy as np arr = np.array( [[5,8,5,3,3], [2,1,3,0,0]] ) np.max(arr) # out: 8 최소값 np.min import numpy as np arr = np.array( [[5,8,5,3,3], [2,1,3,0,0]] ) np.min(arr) # out : 0 2023. 6. 22.
Python Matplotlib 그래프 크기 조절 방법 (plt.rcParams 활용) Python Matplotlib 그래프 크기 조절 방법 (plt.rcParams 활용) 📌 plt.rcParams["figure.figsize"]란?plt.rcParams["figure.figsize"]는 Matplotlib 전역 설정(Global Configuration) 중 하나로, 그래프의 가로(width) 와 세로(height) 크기를 인치 단위로 지정합니다. 이 설정은 이후 생성되는 모든 플롯에 기본값으로 적용됩니다.Python에서 시각화 라이브러리인 Matplotlib을 사용할 때, 그래프의 크기를 조절하고 싶다면 plt.rcParams["figure.figsize"] 설정을 활용할 수 있습니다. 이 설정을 통해 출력되는 그림(figure)의 크기를 자유롭게 변경할 수 있습니다. import.. 2023. 6. 20.
파이썬 성별, 이름, 성적 랜덤 데이터 생성 성별, 이름, 성적 랜덤 데이터 생성¶ In [1]: # 이름을 랜덤 생성하기 위한 패키지 설치 코드 입니다. #!pip install names In [2]: import names import pandas as pd import numpy as np from random import * In [3]: # 10살 초과 19살 이하 나이 랜덤 생성 age = [randint(10, 18) for i in range(0, 5)] age Out[3]: [16, 18, 16, 15, 16] In [4]: # 성멸 나이 랜덤 생성 gender = [choice(["male", "female"]) for i in range(0, 5)] gender Out[4]: ['female', 'male.. 2023. 6. 15.
반응형