<jupyter_start><jupyter_text>* * *  연습문제 - 속도가 30일때와 50일때의 제동거리를 예측하세요.<jupyter_code>cars = pd.read_csv("DataSet/cars.csv", sep = ",")
cars.shape
cars.head()
cars.columns = ["speed", "dist"]
cars.head()
learningRate = 0.003
times = 5001

x_data = cars["speed"]
y_data = cars["dist"]

x = tf.placeholder(dtype = tf.float32, shape = [None])
y = tf.placeholder(dtype = tf.float32, shape = [None])
w = tf.Variable(tf.random_normal([1]))
b = tf.Variable(tf.random_normal([1]))
hf = w * x + b
cost = tf.reduce_mean(tf.square(hf - y))
train = tf.train.GradientDescentOptimizer(learning_rate=learningRate).minimize(cost)

with tf.Session() as sess :
    sess.run(tf.global_variables_initializer())
    for step in range(times) :
        sess.run(train, feed_dict={x: x_data, y:y_data})
        if step%500 ==0:
            print(step, sess.run(cost, feed_dict={x: x_data, y:y_data}))

    print("===========모델 완성===========")
    cv, wv, bv = sess.run([cost, w, b], feed_dict={x: x_data, y:y_data})
    print("Cost : ", cv, "\n가중치 : ", wv, "\n편향 : ", bv)

    print("===========예측==============")
    print("속도가 30일때 예상되는 제동거리 : ", sess.run(hf, feed_dict={x:[30]}))
    print("속도가 50일때 예상되는 제동거리 : ", sess.run(hf, feed_dict={x:[50]}))<jupyter_output>0 563.47107
500 244.11746
1000 236.24535
1500 232.0085
2000 229.72816
2500 228.50084
3000 227.84027
3500 227.48474
4000 227.29344
4500 227.19043
5000 227.13504
===========모델 완성===========
Cost :  227.13504 
가중치 :  [3.8864188] 
편향 :  [-16.78933]
===========예측==============
속도가 30일때 예상되는 제동거리 :  [99.80324]
속도가 50일때 예상되는 제동거리 :  [177.53162]
{'fraction_non_alphanumeric': 0.2226438962681847, 'fraction_numerical': 0.12586970271979758, 'mean_word_length': 4.203947368421052, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '150879', 'license': 'MIT', 'n_tokens_mistral': 854, 'n_tokens_neox': 794, 'n_words': 137, 'path': 'TensorFlow_3.ipynb', 'repo_name': 'heejinADP/TIL', 'size': '1581'}