2017年9月14日 星期四

ML book (Hands-On Machine Learning with Scikit-Learn and TensorFlow ) (CH4 Training Models)

ML book (Hands-On Machine Learning with Scikit-Learn and TensorFlow ) (CH4 Training Models)

link: https://github.com/ageron/handson-ml/blob/master/04_training_linear_models.ipynb

Models:

1) Linear Regression,
2) Polynomial Regression
3) Logistic Regression
4) Softmax Regression


1) Linear Regression






code
>>> from sklearn.linear_model import LinearRegression
>>> lin_reg = LinearRegression()
>>> lin_reg.fit(X, y)
>>> lin_reg.intercept_, lin_reg.coef_
(array([ 4.21509616]), array([[ 2.77011339]]))
>>> lin_reg.predict(X_new)
array([[ 4.21509616],
[ 9.75532293]])


Gradient Descent
The general idea of Gradient Descent is to tweak parameters iteratively in order to minimize a cost function.














沒有留言:

張貼留言