ml

이예나·2일 전

y_test = [2, 4, 7, 10]

plt.plot(
    [y_test.min(), y_test.max()],
    [y_test.min(), y_test.max()],
    color="red"
)

max_depth=60 (depth : 트리의 깊이)

          시작                 ← depth 0
         /    \
      조건      조건            ← depth 1
     /  \      /  \
   조건  조건  조건  조건         ← depth 2
  / \
결과 결과                       ← depth 3

min_samples_leaf=40 ()

           Present_Price <= 10?
             /          \
           Yes           No
          /               \
  Vehicle_Age <= 5?       [Leaf]
      /       \
   [Leaf]     [Leaf]
   
  • [Leaf]에 도착하면 더 이상 질문하지 않고 가격을 예측

  • 각 Leaf에는 최소 40개의 학습 데이터가 들어 있어야 함

                  전체 232개
                 /         \
             120개          112개
            /    \          /    \
         50개    70개     52개    60개
         ↓        ↓        ↓       ↓
       Leaf     Leaf     Leaf    Leaf

머신러닝 라이브러리

  • from sklearn.tree import DecisionTreeRegressor
    : 결정 트리 모델
  • from sklearn.linear_model import LinearRegression
    : 선형회귀 모델
  • from sklearn.metrics import root_mean_squared_error
    : RMSE 계산
  • from sklearn.tree import plot_tree
    : 결정 트리 그림으로 표시

0개의 댓글