๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Study/AI & ML

ํšŒ๊ท€ ์•Œ๊ณ ๋ฆฌ์ฆ˜๊ณผ ๋ชจ๋ธ ๊ทœ์ œ(1) - K-์ตœ๊ทผ์ ‘ ์ด์›ƒ ํšŒ๊ท€

by sumping 2024. 3. 15.

๐Ÿ‘€2์ฃผ์ฐจ 220117 ~ 220123 ๊ณต๋ถ€๊ธฐ๋ก

 

๐Ÿ“ ๋ณธ ํฌ์ŠคํŒ…์€ <ํ˜ผ์ž ๊ณต๋ถ€ํ•˜๋Š” ๋จธ์‹ ๋Ÿฌ๋‹+๋”ฅ๋Ÿฌ๋‹> ์ฑ…์„ ๋ฐ”ํƒ•์œผ๋กœ ์ž‘์„ฑํ•จ์„ ์•Œ๋ฆฝ๋‹ˆ๋‹ค.


โญ Ch. 03(03-1) 2๋ฒˆ ๋ฌธ์ œ ์ถœ๋ ฅ ๊ทธ๋ž˜ํ”„

knr = KNeighborsRegressor()

x = np.arange(5, 45).reshape(-1, 1)

for n in [1, 5, 10]:
  knr.n_neighbors = n
  knr.fit(train_input, train_target)
  prediction = knr.predict(x)

  plt.scatter(train_input, train_target)
  plt.plot(x, prediction)
  plt.title('n_neighbors = {}'.format(n))
  plt.xlabel('length')
  plt.ylabel('weight')
  plt.show()

 

โญ๋ชจ๋ธ ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•˜๊ธฐ

๋ชจ๋ธ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ์„ ํ˜• ํšŒ๊ท€๊ฐ€ ์ฐพ์€ ๊ฐ€์ค‘์น˜์ฒ˜๋Ÿผ ๋จธ์‹ ๋Ÿฌ๋‹ ๋ชจ๋ธ์ด ํŠน์„ฑ์—์„œ ํ•™์Šตํ•œ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋งํ•œ๋‹ค.

์ฆ‰, ๋จธ์‹ ๋Ÿฌ๋‹ ๋ชจ๋ธ์ด ๋ฐ์ดํ„ฐ(ํŠน์„ฑ)์„ ๊ฐ€์ง€๊ณ  ๋‚ด๋ถ€์—์„œ ์ •ํ•˜๋Š” ๋ณ€์ˆ˜๋ฅผ ๋งํ•œ๋‹ค.

A model parameter is a configuration variable that is internal to the model and whose value can be estimated from data. OR A model parameter is a variable of the selected model which can be estimated by fitting the given data to the model. In the above plot, these two parameters(m and c) are estimated by fitting a straight line to the data by minimizing the RMSE. Hence, these parameters are called the model parameters.


โœ…Ch.03-1 K-์ตœ๊ทผ์ ‘ ์ด์›ƒ ํšŒ๊ท€

์ง€๋„ ํ•™์Šต ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ํฌ๊ฒŒ ๋ถ„๋ฅ˜์™€ ํšŒ๊ท€๋กœ ๋‚˜๋‰˜๋Š”๋ฐ, ์˜ค๋Š˜ ๊ณต๋ถ€ํ•  ๊ฒƒ์€ "ํšŒ๊ท€(regression)"์ด๋‹ค.

  • ๋ถ„๋ฅ˜ : ์ƒ˜ํ”Œ์„ ๋ช‡ ๊ฐœ์˜ ํด๋ž˜์Šค ์ค‘ ํ•˜๋‚˜๋กœ ๋ถ„๋ฅ˜ → ์ด์›ƒ์˜ ๋ ˆ์ด๋ธ” ๊ฐœ์ˆ˜๋ฅผ ํ™•์ธ ํ›„ ๋‹ค์ˆ˜๊ฒฐ
  • ํšŒ๊ท€ : ์ž„์˜์˜ ์–ด๋–ค ์ˆซ์ž๋ฅผ ์˜ˆ์ธกํ•˜๋Š” ๋ฌธ์ œ → ์ด์›ƒ๋“ค์˜ ํ‰๊ท 

 

๐Ÿ”ฅ๊ฒฐ์ •๊ณ„์ˆ˜(R²)

๊ฒฐ์ •๊ณ„์ˆ˜(R²)๋Š” ๋Œ€ํ‘œ์ ์ธ ํšŒ๊ท€ ๋ฌธ์ œ์˜ ์„ฑ๋Šฅ ์ธก์ • ๋„๊ตฌ์ด๋‹ค.

(0 ≤ R² ≤ 1) : 1์— ๊ฐ€๊นŒ์šธ์ˆ˜๋ก ์ข‹๊ณ , 0์— ๊ฐ€๊พธ์šธ์ˆ˜๋ก ์„ฑ๋Šฅ์ด ๋‚˜์œ ๋ชจ๋ธ์ด๋‹ค. (์˜ˆ์ธก์ด ํ‰๊ท  ์ •๋„๋ฅผ ์˜ˆ์ธกํ•œ๋‹ค๋ฉด 1์ด ๋˜์–ด์„œ ๊ฒฐ์ •๊ณ„์ˆ˜๋Š” 0์— ๊ฐ€๊นŒ์›Œ์ง„๋‹ค. ๋ฐ˜๋Œ€๋กœ, ์˜ˆ์ธก์ด ํƒ€๊นƒ์— ๊ฐ€๊นŒ์›Œ์งˆ์ˆ˜๋ก ๋ถ„์ž๊ฐ€ 0์— ๊ฐ€๊นŒ์›Œ์ง€๊ธฐ ๋•Œ๋ฌธ์—, ๊ฒฐ์ •๊ณ„์ˆ˜๋Š” 1์— ๊ฐ€๊นŒ์›Œ์ง„๋‹ค.)

#K-์ตœ๊ทผ์ ‘ ์ด์›ƒ ํšŒ๊ท€ ๋ชจ๋ธ ํ›ˆ๋ จ
knr.fit(train_input, train_target)

print(knr.score(test_input, test_target))

#0.992809406101064

KNN ํšŒ๊ท€ ๋ชจ๋ธ์„ ํ›ˆ๋ จ์‹œํ‚จ ํ›„ score๋กœ ํ…Œ์ŠคํŠธ์„ธํŠธ์˜ ์„ฑ๋Šฅ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ถ„๋ฅ˜์˜ ๊ฒฝ์šฐ๋Š” ์ •ํ™•ํ•˜๊ฒŒ ๋ถ„๋ฅ˜ํ•œ ๊ฐœ์ˆ˜์˜ ๋น„์œจ์„ ์ถœ๋ ฅํ•œ๋‹ค. ์ฆ‰, ์ •ํ™•๋„์ด๋‹ค. ํšŒ๊ท€๋Š” ์ž„์˜์˜ ์ˆซ์ž๋ฅผ ์˜ˆ์ธกํ•˜๋Š” ๋ฌธ์ œ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ •ํ™•ํ•˜๊ฒŒ ์ˆซ์ž๋‚˜ ๊ฐœ์ˆ˜๋ฅผ ๋งžํžŒ๋‹ค๋Š” ๊ฒƒ์€ ๊ฑฐ์˜ ๋ถˆ๊ฐ€๋Šฅ์— ๊ฐ€๊น๋‹ค. ๊ฒฐ์ •๊ณ„์ˆ˜๋Š” ํšŒ๊ท€์‹์ด ์–ผ๋งˆ๋‚˜ ์ •ํ™•ํ•œ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ˆซ์ž์ด๋‹ค.

 

๐Ÿ”ฅ๊ณผ๋Œ€์ ํ•ฉ VS ๊ณผ์†Œ์ ํ•ฉ

 

Regression์—์„œ (1)๋ฒˆ ์‚ฌ์ง„์€ ๊ณผ์†Œ์ ํ•ฉ(underfitting)์ด๋‹ค. ๋นจ๊ฐ„์ƒ‰(ํ›ˆ๋ จ)๋ณด๋‹ค ์ดˆ๋ก์ƒ‰(ํ…Œ์ŠคํŠธ)์˜ ์ ์ˆ˜๊ฐ€ ๋†’๊ฑฐ๋‚˜ ๋‘ ์ ์ˆ˜ ๋ชจ๋‘๊ฐ€ ๋„ˆ๋ฌด ๋‚ฎ์€ ๊ฒฝ์šฐ์ด๋‹ค. ๊ณผ์†Œ์ ํ•ฉ์€ ๋ชจ๋ธ์ด ๋„ˆ๋ฌด ๋‹จ์ˆœํ•˜๊ฑฐ๋‚˜ ๋ฐ์ดํ„ฐ์˜ ํฌ๊ธฐ๊ฐ€ ์ž‘์•„์„œ ๋ฐ์ดํ„ฐ์˜ ๋‚ด์žฌ๋œ ๊ตฌ์กฐ๋ฅผ ํ•™์Šตํ•˜์ง€ ๋ชปํ•  ๋•Œ ๋ฐœ์ƒํ•œ๋‹ค. ๋ชจ๋ธ์ด ๋„ˆ๋ฌด ๋‹จ์ˆœํ•˜์—ฌ ํ›ˆ๋ จ ์„ธํŠธ์— ์ ์ ˆํžˆ ํ›ˆ๋ จ๋˜์ง€ ์•Š์Œ์„ ๋œปํ•œ๋‹ค.

 

(3)๋ฒˆ ์‚ฌ์ง„์€ ๊ณผ๋Œ€์ ํ•ฉ(overfitting)์ด๋‹ค. ์ดˆ๋ก์ƒ‰(ํ›ˆ๋ จ)์ด ๋นจ๊ฐ„์ƒ‰(ํ…Œ์ŠคํŠธ)๋ณด๋‹ค ์ ์ˆ˜๊ฐ€ ๋” ์ž˜๋‚˜์˜ค๋Š” ๊ฒฝ์šฐ๋ฅผ ๋งํ•œ๋‹ค. ์ฆ‰ ํ›ˆ๋ จ ์„ธํŠธ์—๋งŒ ์ž˜ ๋งž๋Š” ๋ชจ๋ธ์ด๋ผ์„œ ํ…Œ์ŠคํŠธ ์„ธํŠธ์™€ ํ›„์— ์‹ค์ „์—์„œ๋Š” ์ž˜ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š”๋‹ค. (๋ชจ๋ธ ์ด์ƒ์˜ ๋ณต์žก๋„๊ฐ€ ํ•„์š” ์ด์ƒ์œผ๋กœ ๋†’๋‹ค. ์ฆ‰, ์ง€๋‚˜์น˜๊ฒŒ ์ž˜ ๋งž์•„์„œ ํ…Œ์ŠคํŠธ ์„ธํŠธ์—์„œ ๋†’์€ ์„ฑ๋Šฅ์„ ๋ณด์—ฌ์ฃผ๊ธฐ ์–ด๋ ต๋‹ค.) 

 

๐ŸŽˆ ๊ณผ์†Œ์ ํ•ฉ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

- ๋ชจ๋ธ์ด ๋‹จ์ˆœํ•ด์„œ ์ƒ๊ธด ๋ฌธ์ œ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ชจ๋ธ์„ ์กฐ๊ธˆ ๋” ๋ณต์žกํ•˜๊ฒŒ ๋งŒ๋“ ๋‹ค. (๋ณต์žก๋„๊ฐ€ ๋” ๋†’์€ ๋ชจ๋ธ ์‚ฌ์šฉ)

- (๊ฐ€์ค‘์น˜ ๊ทœ์ œ ์™„ํ™”) K-NN ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ๋ชจ๋ธ์„ ๋” ๋ณต์žกํ•˜๊ฒŒ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์€ ์ด์›ƒ์˜ ๊ฐœ์ˆ˜K๋ฅผ ์ค„์ด๋Š” ๊ฒƒ์ด๋‹ค. (์ด์›ƒ์˜ ๊ฐœ์ˆ˜๋ฅผ ์ค„์ด๋ฉด ํ›ˆ๋ จ ์„ธํŠธ์— ์žˆ๋Š” ๊ตญ์ง€์ ์ธ ํŒจํ„ด์— ๋ฏผ๊ฐํ•ด์ง€๊ณ , ์ด์›ƒ์˜ ๊ฐœ์ˆ˜๋ฅผ ๋Š˜๋ฆฌ๋ฉด ๋ฐ์ดํ„ฐ ์ „๋ฐ˜์— ์žˆ๋Š” ์ผ๋ฐ˜์ ์ธ ํŒจํ„ด์„ ๋”ฐ๋ฅด๊ธฐ ๋•Œ๋ฌธ)

 

๐ŸŽˆ ๊ณผ๋Œ€์ ํ•ฉ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

- ๋ชจ๋ธ์˜ ๋ณต์žก๋„๋ฅผ ๋‚ฎ์ถ˜๋‹ค. (ํ›ˆ๋ จ ์ƒ˜ํ”Œ์„ ๋” ๋ชจ์„ ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ, ๋ชจ๋ธ์ด ํ›ˆ๋ จ ์„ธํŠธ์— ์ง‘์ฐฉํ•˜์ง€ ์•Š๋„๋ก ๊ฐ€์ค‘์น˜๋ฅผ ์ œํ•œ)

- ํ›ˆ๋ จ ๋ฐ์ดํ„ฐ๋ฅผ ๋” ๋งŽ์ด ๋ชจ์€๋‹ค.

- ์ •๊ทœํ™”(์ ๋‹นํ•œ ๋ณต์žก๋„๋ฅผ ๊ฐ€์ง€๋Š” ๋ชจ๋ธ์„ ์ž๋™์ ์œผ๋กœ ์ฐพ์•„์ฃผ๋Š” ๊ธฐ๋ฒ•)

 


๐Ÿ”ฅscikit-learn

- KNeighborsRegrssor : K-์ตœ๊ทผ์ ‘ ์ด์›ƒ ํšŒ๊ท€ ๋ชจ๋ธ์„ ๋งŒ๋“œ๋Š” ์‚ฌ์ดํ‚ท๋Ÿฐ ํด๋ž˜์Šค์ด๋‹ค. (๋ถ„๋ฅ˜๋ชจ๋ธ์€ KNeighborsClassfier)

from sklearn.neighbors import KNeighborsRegressor

knr = KNeighborsRegressor()

- mean_absolute_error : ํšŒ๊ท€ ๋ชจ๋ธ์˜ ํ‰๊ท  ์ ˆ๋Œ“๊ฐ’ ์˜ค์ฐจ๋ฅผ ๊ณ„์‚ฐํ•œ๋‹ค. ๊ฒฐ์ •๊ณ„์ˆ˜๋ฅผ ๊ตฌํ•  ๋•Œ, ์ถ”๊ฐ€์ ์œผ๋กœ ํƒ€๊นƒ๊ณผ ์˜ˆ์ธกํ•œ ๊ฐ’ ์‚ฌ์ด์˜ ์ฐจ์ด๋ฅผ ๊ตฌํ•˜๋ฉด ์–ด๋Š ์ •๋„ ์˜ˆ์ธก์ด ๋ฒ—์–ด๋‚ฌ๋Š”์ง€ ๊ฐ€๋Š ์ด ์‰ฝ๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉ. mean_absolute_error๋Š” ํƒ€๊นƒ๊ณผ ์˜ˆ์ธก์˜ ์ ˆ๋Œ“๊ฐ’ ์˜ค์ฐจ๋ฅผ ํ‰๊ท ํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

from sklearn.metrics import mean_absolute_error

#ํ…Œ์ŠคํŠธ ์„ธํŠธ์— ๋Œ€ํ•œ ์˜ˆ์ธก ๋งŒ๋“ค๊ธฐ
test_prediction = knr.predict(test_input)

#ํ…Œ์ŠคํŠธ ์„ธํŠธ์— ๋Œ€ํ•œ ํ‰๊ท  ์ ˆ๋Œ“๊ฐ’ ์˜ค์ฐจ๋ฅผ ๊ณ„์‚ฐ
mae = mean_absolute_error(test_target, test_prediction)
print(mae)

 

* ์‚ฌ์ดํ‚ท๋Ÿฐ์— ์‚ฌ์šฉํ•  ํ›ˆ๋ จ ์„ธํŠธ๋Š” 2์ฐจ์› ๋ฐฐ์—ด์ด์–ด์•ผ ํ•œ๋‹ค. ๊ทธ ์ด์œ ๋Š” ์‚ฌ์ดํ‚ท๋Ÿฐ์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ž์‹ ์˜ ์ธํ’‹ X๊ฐ€ 2d๋กœ ๋“ค์–ด์˜ฌ ๊ฒƒ์„ ์ƒ์ •ํ•˜๊ณ  ์žˆ๋‹ค.

X : {array-like, sparse matrix}, shape (n_samples, n_features)
Input data, where n_samples is the number of samples and n_features is the number of features.

 

๐Ÿ”ฅnumpy

- reshape : ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋ฐ”๊พธ๋Š” ๋ฉ”์„œ๋“œ์ด๋‹ค. ๋ฐ”๊พธ๊ณ ์ž ํ•˜๋Š” ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌํ•œ๋‹ค. (๋‹จ, ๋ฐ”๊พธ๊ธฐ ์ „ํ›„์˜ ๋ฐฐ์—ด ์›์†Œ ๊ฐœ์ˆ˜๋Š” ๋™์ผํ•ด์•ผ ํ•œ๋‹ค.) ์ฆ‰, ๋ฐฐ์—ด ์ฐจ์›(dimension)์„ ์žฌ๊ตฌ์กฐํ™” ๋ฐ ๋ณ€๊ฒฝํ•˜๊ณ ์ž ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.

#reshape() ๋ฉ”์„œ๋“œ ์—ฐ์Šต
test_array = np.array([1, 2, 3, 4])
test_array = test_array.reshape(2, 2)
print(test_array)

"""
[[1 2]
 [3 4]]
"""

 

*๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ์ž๋™์œผ๋กœ ์ง€์ •ํ•˜๋Š” ๊ธฐ๋Šฅ : ํฌ๊ธฐ์— -1์„ ์ง€์ •ํ•œ๋‹ค. -1๋กœ ์ง€์ •ํ•˜๋ฉด, ๋‚˜๋จธ์ง€ ์›์†Œ ๊ฐœ์ˆ˜๋กœ ๋ชจ๋‘ ์ฑ„์šฐ๋ผ๋Š” ์˜๋ฏธ

  • reshape(-1, ์ •์ˆ˜) : ์—ด ๊ฐœ์ˆ˜๋งŒํผ ์ž๋™์œผ๋กœ ๊ตฌ์กฐํ™”
  • reshape(์ •์ˆ˜, -1) : ํ–‰์˜ ์ •์ˆ˜๋งŒํผ ํ–‰์ด ์ƒ์„ฑ๋˜์–ด์„œ ์ž๋™์œผ๋กœ ๊ตฌ์กฐํ™”
  • reshape(-1) : -1๋งŒ ๋‹จ๋…์œผ๋กœ ์žˆ์„ ๊ฒฝ์šฐ 1์ฐจ์› ๋ฐฐ์—ด์„ ๋ฐ˜ํ™˜

[์ฐธ๊ณ ์ž๋ฃŒ]

๊ธฐ๊ณ„ํ•™์Šต ์ด๋ฏธ์ง€ ์ฐธ๊ณ 

https://velog.io/@choihana/%EB%A8%B8%EC%8B%A0%EB%9F%AC%EB%8B%9D-%EC%9E%85%EB%AC%B8-%EB%A8%B8%EC%8B%A0%EB%9F%AC%EB%8B%9D-%EB%B6%84%EB%A5%98%ED%95%98%EA%B8%B0

 

๋จธ์‹ ๋Ÿฌ๋‹ ์ž…๋ฌธ - ๋จธ์‹ ๋Ÿฌ๋‹ ๋ถ„๋ฅ˜ํ•˜๊ธฐ

์ด ๋ธ”๋กœ๊ทธ๋Š” ์ƒํ™œ์ฝ”๋”ฉ ์ด๊ณ ์ž‰๋‹˜์˜ ๋จธ์‹ ๋Ÿฌ๋‹ ์•ผํ•™์„ ๋“ฃ๊ณ  ์Šค์Šค๋กœ ์ดํ•ดํ•œ ๋‚ด์šฉ์„ ๋ฐ”ํƒ•์œผ๋กœ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ž˜๋ชป๋œ ๋‚ด์šฉ์ด ์žˆ์œผ๋ฉด ๋Œ“๊ธ€๋กœ ์•Œ๋ ค์ฃผ์„ธ์š” :) ๋จธ์‹ ๋Ÿฌ๋‹ ์•ผํ•™ ์‹ ์ฒญํ•˜๋Ÿฌ ๊ฐ€๊ธฐ ๐Ÿ‘‰๐Ÿป ๋จธ์‹ ๋Ÿฌ๋‹

velog.io

 

ํšŒ๊ท€์—์„œ ๊ฒฐ์ •๊ณ„์ˆ˜๊ฐ€ ๊ถ๊ธˆํ•˜๋‹ค๋ฉด?

https://math100.tistory.com/120

 

๊ฒฐ์ •๊ณ„์ˆ˜๋ž€?

์ผ๋‹จ ํšŒ๊ท€๋ถ„์„์€ ํšŒ๊ท€์‹์„ ํ™œ์šฉํ•ด์„œ ๋ฌด์—‡์ธ๊ฐ€๋ฅผ ์˜ˆ์ธกํ•˜๋Š” ๋ถ„์„์ด๋‹ค. ๊ทธ๋ž˜์„œ ๋ฌด์—‡์ธ๊ฐ€๋ฅผ ์˜ˆ์ธกํ•  ๋•Œ, ํšŒ๊ท€๋ถ„์„์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ˆˆ๋Œ€์ค‘์œผ๋กœ ๋ง‰ ์žก์€ ์ˆ˜์น˜๋ณด๋‹ค๋Š” ํ›จ์”ฌ ์‹ ๋ขฐํ•  ๋งŒํ•˜๋‹ค. ํ•˜์ง€๋งŒ ํšŒ๊ท€๋ถ„์„

math100.tistory.com

 

๊ณผ๋Œ€์ ํ•ฉ, ๊ณผ์†Œ์ ํ•ฉ์— ๋Œ€ํ•ด์„œ ์™„์ „ํ•œ ์ดํ•ด๊ฐ€ ๊ฐ€๋Šฅ

https://m.blog.naver.com/qbxlvnf11/221324122821

 

๋จธ์‹ ๋Ÿฌ๋‹ - ๊ณผ๋Œ€์ ํ•ฉ(overfitting)๊ณผ ๊ณผ์†Œ์ ํ•ฉ(underfitting), ์ •๊ทœํ™”

(๋ณธ ๊ธ€์€ ์ฑ… 'Hands-On Machine Learning with Scikit-Learn & TensorFlow'์˜ ์ผ๋ถ€๋ฅผ ์ฐธ๊ณ ํ•˜์˜€...

blog.naver.com

 

๋ณธ ์Šคํ„ฐ๋””์˜ ๋‚ด์šฉ์— ๋Œ€ํ•ด ์ž์„ธํ•œ ์„ค๋ช…๊ณผ ๊น”๋”ํ•œ ์ •๋ฆฌ

https://velog.io/@arittung/DeepLearningStudyDay4

 

k-์ตœ๊ทผ์ ‘ ์ด์›ƒ ํšŒ๊ท€ (KNN-Regression)

k-์ตœ๊ทผ์ ‘ ์ด์›ƒ ํšŒ๊ท€ (KNN-Regression), ๊ฒฐ์ •๊ณ„์ˆ˜, ๊ณผ๋Œ€์ ํ•ฉ, ๊ณผ์†Œ์ ํ•ฉ

velog.io

 

์‚ฌ์ดํ‚ท๋Ÿฐ์— ์‚ฌ์šฉํ•  ํ›ˆ๋ จ๋ฐ์ดํ„ฐ๊ฐ€ 2์ฐจ์› ๋ฐฐ์—ด์ด์–ด์•ผ ํ•˜๋Š” ์ด์œ 

https://datamasters.co.kr/55

 

[debugging] Expected 2D array, got 1D array instead

sklearn ์„ ์‚ฌ์šฉํ•˜๋‹ค ๋ณด๋ฉด ์ œ๋ชฉ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ์ข…์ข… ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ๋‹คํ–‰ํžˆ ๊ฐœ๋ฐœ์ž๋ถ„๋“ค ๊ป˜์„œ ์นœ์ ˆํžˆ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€์— ํ•ด๊ฒฐ์ฑ…์„ ์จ๋‘๊ณ ๋Š” ํ•œ๋‹ค: from sklearn.impute import SimpleImputer imp = SimpleImputer(..

datamasters.co.kr

https://scikit-learn.org/stable/modules/generated/sklearn.impute.SimpleImputer.html

 

sklearn.impute.SimpleImputer

Examples using sklearn.impute.SimpleImputer: Release Highlights for scikit-learn 0.23 Release Highlights for scikit-learn 0.23, Combine predictors using stacking Combine predictors using stacking, ...

scikit-learn.org

 

์„ ํ˜•ํšŒ๊ท€์—์„œ 2์ฐจ์› ๋ฐฐ์—ด์„ ์จ์•ผํ•˜๋Š” ์ด์œ  : ์ผ์ฐจ์‹์„ ๊ณ„์‚ฐํ•  ๋•Œ 2์ฐจ์› ๋ฒกํ„ฐ๋‚˜ ํ–‰๋ ฌ์„ ์‚ฌ์šฉํ•˜๊ณ , 2์ฐจ์› ํ–‰๋ ฌ์„ ํ›ˆ๋ จ ๋ฐ์ดํ„ฐ๋กœ ์“ฐ๋ฉด ์—ญํ–‰๋ ฌ์„ ์จ์„œ ํšŒ๊ท€์„ ์˜ ๊ธฐ์šธ๊ธฐ์™€ ์ ˆํŽธ์„ ๊ตฌํ•˜๊ธฐ ์‰ฝ๋‹ค.

https://aimb.tistory.com/135

 

์„ ํ˜•ํšŒ๊ท€์—์„œ 2์ฐจ์› array๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ 

from sklearn.linear_model import LinearRegression # 1. choose model class model = LinearRegression() # 2. instantiate model feature = ['feature_A'] target = ['feature_A'] #ํƒ€๊ฒŸ ๋ฒกํ„ฐ ๋งŒ๋“ค๊ธฐ X_train =..

aimb.tistory.com

 

reshape() ๋ฉ”์„œ๋“œ์— ๋Œ€ํ•ด ์™„์ „ ์ž˜ ์„ค๋ช…๋˜์–ด ์žˆ์Œ.

https://domybestinlife.tistory.com/149

 

[Python] numpy.reshape์˜ -1 ์˜๋ฏธ ๋ฐ ๊ธฐ๋Šฅ

ํŒŒ์ด์ฌ์˜ NumPy๋ฅผ ์ด์šฉ ์‹œ ๋ฐฐ์—ด ์ฐจ์›(Dimension)์„ ์žฌ๊ตฌ์กฐํ™” ๋ฐ ๋ณ€๊ฒฝํ•˜๊ณ ์ž ํ•  ๋•Œ reshape() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.  ์˜ˆ๋ฅผ ๋“ค์–ด, 3๊ฐœ์˜ ํ–‰๊ณผ 4๊ฐœ์˜ ์—ด๋กœ ๊ตฌ์„ฑ๋œ 2์ฐจ์›์˜ ๋ฐฐ์—ด๋กœ ์žฌ์„ค์ • ์‹œ reshape(3, 4)์ฒ˜๋Ÿผ resha

domybestinlife.tistory.com

 

๋ชจ๋ธ ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์˜๋ฏธ๊ฐ€ ๊ถ๊ธˆํ•˜๋‹ค๋ฉด?

https://www.geeksforgeeks.org/difference-between-model-parameters-vs-hyperparameters/

 

Difference Between Model Parameters VS HyperParameters - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org

 

๋ชจ๋ธ ํŒŒ๋ผ๋ฏธํ„ฐ์™€ ํ•˜์ดํผํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์ฐจ์ด์ ์ด ๊ถ๊ธˆํ•˜๋‹ค๋ฉด?

https://machinelearningmastery.com/difference-between-a-parameter-and-a-hyperparameter/

 

What is the Difference Between a Parameter and a Hyperparameter?

It can be confusing when you get started in applied machine learning. There are so many terms to use and […]

machinelearningmastery.com