분류 모델로 예측하기
이제 분류기를 학습했으니, 이를 사용해 새로 수집한 꽃들의 종류(클래스)를 예측해 보겠습니다.
여러 새 꽃의 꽃잎 너비와 길이 정보가 변수 targets에 저장되어 있습니다. 방금 학습한 분류기를 사용해 각 꽃의 종류를 예측하세요.
이 연습은 강의의 일부입니다
Python으로 배우는 시계열 데이터 Machine Learning
연습 안내
- 배열
X_predict를 사용해 꽃의 종류를 예측하세요. - 제공된 코드를 실행해 예측 결과를 시각화하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create input array
X_predict = targets[['petal length (cm)', 'petal width (cm)']]
# Predict with the model
predictions = ____
print(predictions)
# Visualize predictions and actual values
plt.scatter(X_predict['petal length (cm)'], X_predict['petal width (cm)'],
c=predictions, cmap=plt.cm.coolwarm)
plt.title("Predicted class values")
plt.show()