Python 데이터 과학 핸드북

Mar 31 2023
.
  1. IPython: 일반 파이썬 너머
  2. 넘파이 소개
  3. Pandas를 사용한 데이터 조작
  4. Matplotlib를 사용한 시각화
  1. 기계 학습 시작하기
  2. 데이터에서 배우기
  3. 선형 회귀
  4. 나이브 베이즈
  5. k-최근접 이웃
  6. Scikit-Learn을 통한 기계 학습 소개
  7. 실제 머신 러닝
  8. 편향-분산 절충
  9. 커널 밀도 추정
  10. 주요 구성 요소 분석
  11. 매니폴드 학습
  12. 클러스터링
  13. 결정 트리 및 랜덤 포레스트
  14. 기울기 기반 최적화
  15. K-평균 클러스터링
  16. 심화: Naive Bayes 분류
  17. 심화: 선형 회귀
  18. 심화: 서포트 벡터 머신
  19. 심화: 결정 트리 및 랜덤 포레스트
  20. 심화: 주성분 분석
  21. 심화: 다양한 학습
  22. 심화: k-평균 클러스터링
  1. 파이썬의 회오리 바람 여행
  2. 파이썬 언어 기초
  3. IPython: 일반 파이썬 너머
  4. 넘파이
  5. IPython 시스템 셸에 대한 추가 정보
  6. Matplotlib
  7. 사이파이
  8. 사이킷런
  9. Scikit-Learn을 사용한 기계 학습
  10. 추가 기계 학습 리소스
  11. 실용적인 기계 학습: 간단한 예
  12. 서지

import numpy as np

# create a 1D array
a = np.array([0, 1, 2, 3, 4])
print(a)

import pandas as pd

# create a Pandas DataFrame
data = {'name': ['Alice', 'Bob', 'Charlie', 'David'],
        'age': [25, 32, 18, 47],
        'gender': ['F', 'M', 'M', 'M']}
df = pd.DataFrame(data)
print(df)

# filter rows based on a condition
df_filtered = df[df['age'] > 30]
print(df_filtered)

# group data by a column and compute statistics
grouped_data = df.groupby('gender')['age'].mean()
print(grouped_data)

import matplotlib.pyplot as plt
import numpy as np

# create some data to plot
x = np.linspace(0, 10, 100)
y = np.sin(x)

# create a line plot
plt.plot(x, y)
plt.title('Sine Wave')
plt.xlabel('x')
plt.ylabel('y')
plt.show()

# create a scatter plot
x = np.random.randn(100)
y = np.random.randn(100)
plt.scatter(x, y)
plt.title('Random Data')
plt.xlabel('x')
plt.ylabel('y')
plt.show()

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

# load the iris dataset
iris = load_iris()

# split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(iris['data'], iris['target'], random_state=0)

# create a K-Nearest Neighbors classifier
knn = KNeighborsClassifier(n_neighbors=1)

# fit the classifier to the training data
knn.fit(X_train, y_train)

# predict the classes of the test data
y_pred = knn.predict(X_test)

# compute the accuracy of the classifier
accuracy = knn.score(X_test, y_test)
print('Accuracy:', accuracy)