일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 주성분 분석
- Q-Q 플롯
- 주성분 줄이기
- R과 Python
- 데이터 분석 프로세스
- 명목형 데이터
- 상관 분석
- 상위포지션
- 시계열 모델링
- 날짜 시간 데이터 전처리
- 시계열 특성을 고려한 이상치 탐지
- custom vision
- ARIMA 모델링
- 시계열 상관 분석
- 순서형 데이터
- 군집화 시각화 방법
- 다변량 분석
- Z-점수 기반 이상치 탐지
- 상자 그림
- Python
- 데이터 수집 및 전처리
- 데이터의 차원 축소
- ARMA 모델링
- 최소-최대 정규화
- 데이터 종류에 따른 분석 방법
- 범주형 데이터
- 계절성 모델
- 다중상관분석
- 지수평활법
- 선형 판별 분석 LDA
Archives
- Today
- Total
me made it !
[머신러닝] lab 04-1: multi-variable linear regression을 TensorFlow에서 구현하기 본문
TIL/머신러닝
[머신러닝] lab 04-1: multi-variable linear regression을 TensorFlow에서 구현하기
yeoney 2023. 3. 28. 17:35반응형
https://youtu.be/fZUV3xjoZSM?t=416
none : 값이 없다는 의미가 아니라 [현재 값을 정해주지 않는다 : 부정]는 의미
그 어떤 n의 값도 들어올 수 있음
# Lab 4 Multi-variable linear regression
import tensorflow as tf
tf.set_random_seed(777) # for reproducibility
x1_data = [73., 93., 89., 96., 73.]
x2_data = [80., 88., 91., 98., 66.]
x3_data = [75., 93., 90., 100., 70.]
y_data = [152., 185., 180., 196., 142.]
# placeholders for a tensor that will be always fed.
x1 = tf.placeholder(tf.float32)
x2 = tf.placeholder(tf.float32)
x3 = tf.placeholder(tf.float32)
Y = tf.placeholder(tf.float32)
w1 = tf.Variable(tf.random_normal([1]), name='weight1')
w2 = tf.Variable(tf.random_normal([1]), name='weight2')
w3 = tf.Variable(tf.random_normal([1]), name='weight3')
b = tf.Variable(tf.random_normal([1]), name='bias')
hypothesis = x1 * w1 + x2 * w2 + x3 * w3 + b
# cost/loss function
cost = tf.reduce_mean(tf.square(hypothesis - Y))
# Minimize. Need a very small learning rate for this data set
optimizer = tf.train.GradientDescentOptimizer(learning_rate=1e-5)
train = optimizer.minimize(cost)
# Launch the graph in a session.
sess = tf.Session()
# Initializes global variables in the graph.
sess.run(tf.global_variables_initializer())
for step in range(2001):
cost_val, hy_val, _ = sess.run([cost, hypothesis, train],
feed_dict={x1: x1_data, x2: x2_data, x3: x3_data, Y: y_data})
if step % 10 == 0:
print(step, "Cost: ", cost_val, "\nPrediction:\n", hy_val)
'''
0 Cost: 19614.8
Prediction:
[ 21.69748688 39.10213089 31.82624626 35.14236832 32.55316544]
10 Cost: 14.0682
Prediction:
[ 145.56100464 187.94958496 178.50236511 194.86721802 146.08096313]
...
1990 Cost: 4.9197
Prediction:
[ 148.15084839 186.88632202 179.6293335 195.81796265 144.46044922]
2000 Cost: 4.89449
Prediction:
[ 148.15931702 186.8805542 179.63194275 195.81971741 144.45298767]
'''
반응형
'TIL > 머신러닝' 카테고리의 다른 글
[머신러닝] K- 최근접 이웃 알고리즘 (0) | 2023.03.30 |
---|---|
[머신러닝] lab 04-2: TensorFlow로 파일에서 데이타 읽어오기 (new) (0) | 2023.03.28 |
[머신러닝] multi-variable linear regression (new) (0) | 2023.03.28 |
[머신러닝] DeepLearningZeroToAll (0) | 2023.03.22 |
[머신러닝] Linear Regression의 Hypothesis 와 cost (0) | 2023.03.22 |