이미지 압축
·
Machine Learning/Clustering
K Means를 이용한 이미지 압축¶ In [1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt np.random.seed(2021) 1. Data¶ 1.1 Data Load¶ In [2]: from sklearn.datasets import load_sample_image china = load_sample_image("china.jpg") In [3]: plt.imshow(china) Out[3]: 1.2 Data Scaling¶ In [6]: china_flatten = china / 255.0 china_flatten = china_flatten.reshape(-1, 3) china_flatten.shape Out[..
Clustering으로 빈 데이터 채우기
·
Machine Learning/Clustering
Simple Titanic Survival Data¶ In [1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt np.random.seed(2021) 1. Data¶ 이번 실습에서 사용할 데이터는 Titanic호의 사고에서 생존자를 찾는 데이터입니다. In [2]: titanic = pd.read_csv("simple_titanic.csv") 데이터가 갖고 있는 column들은 다음과 같습니다. Survived : 생존 유무 (정답) Pclass : 탑승한 여객 클래스 Sex : 성별 Age : 나이 Fare : 운임료 Embarked: 승선항구 위치 C = Cherbourg; Q = Queenstown; S = South..
Non-Hierarchical Clustering
·
Machine Learning/Clustering
샘플 데이터와 Non-Hierarchical Clustering¶ In [1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt np.random.seed(2021) 1. Data¶ 1.1 Sample Data¶ In [2]: from sklearn.datasets import make_blobs data, label = make_blobs(n_samples=1500, random_state=170) In [3]: plt.scatter(data[:, 0], data[:, 1], c=label) Out[3]: In [52]: pd.DataFrame(label).value_counts Out[52]: In [54]: data Ou..
Hierarchical Clustering
·
Machine Learning/Clustering
샘플 데이터와 Hierarchical Clustering¶ In [1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt np.random.seed(2021) 1. Data¶ 1.1 Sample data¶ 이번 실습에서는 강의에서 예제로 보여드린 데이터를 이용해 진행합니다. In [2]: data = np.array( [ (1, 5), (2, 4), (4, 6), (4, 3), (5, 3), ] ) In [3]: data Out[3]: array([[1, 5], [2, 4], [4, 6], [4, 3], [5, 3]]) 2. Hierarchical Clustering¶ Hierarchical Clustering은 sklearn..