소스 : https://www.kaggle.com/uciml/iris
SepalLength (꽃받침의 길이)
SepalWidth (꽃받침의 폭)
PetalLength (꽃잎의 길이)
PetalWidth (꽃임이 너비)
Name 품종명
Iris-setosa, Iris-versicolor, Iris-virginica 세 품종으로 분류
CSV 파일에는 약 150개의 데이터가 있다
import pandas as pd
from sklearn.model_selection import train_test_split
df_iris = pd.read_csv(os.path.join(base_path, 'iris.csv')
# 원래 인덱스가 숫자인것을 'Id' column으로 세팅
df_iris.set_index('Id', inplace=True)
df_iris.columns
# ['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm', 'Species']
df_data = df_iris[['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']]
df_label = df_iris['Species']
train_data, test_data, train_label, test_label =\
train_test_split(df_data, df_label)
# 1/4로 나눔
# train_size 파라미터를 통해 분할 범위 조절 가능 ex) train_size=0.7
# shuffle=True는 defalut 값이다
clf = svm.SVC()
clf.fit(train_data, train_label)
pre = clf.predict(test_data)
metrics.accuracy_score(test_label, pre)
https://scikit-learn.org/stable/tutorial/basic/tutorial.html#loading-an-example-dataset
from sklearn import datasets
# 붓꽃 데이터
iris = datasets.load_iris()
# type
type(iris) # sklearn.utils.Bunch
# keys()
iris.key()
# dict_keys(['data', 'target', 'frame', 'target_names', 'DESCR', 'feature_names', 'filename', 'data_module'])
이번에도 import가 헷갈린다. import 지옥같다