From 5f2b7c3c9858997e60dec9c70baa2e3a261e77eb Mon Sep 17 00:00:00 2001 From: Selman Date: Sun, 4 Apr 2021 16:47:06 +0300 Subject: [PATCH] sources codes added for third video --- .../.ipynb_checkpoints/model-checkpoint.ipynb | 74 ++++++++++++++++++- ML-Project/model.ipynb | 74 ++++++++++++++++++- readme.MD | 7 +- 3 files changed, 150 insertions(+), 5 deletions(-) diff --git a/ML-Project/.ipynb_checkpoints/model-checkpoint.ipynb b/ML-Project/.ipynb_checkpoints/model-checkpoint.ipynb index 6ce0955..a385f1b 100644 --- a/ML-Project/.ipynb_checkpoints/model-checkpoint.ipynb +++ b/ML-Project/.ipynb_checkpoints/model-checkpoint.ipynb @@ -1088,7 +1088,79 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "#Train Test Split\n", + "X_train, X_test, y_train, y_test = train_test_split(data.iloc[:,0:-1], data.iloc[:,-1], test_size=0.2, random_state=0)\n", + "X_train" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Linear Regression\n", + "regressor = LinearRegression()\n", + "regressor" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "regressor.fit(X_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Linear Regression Predict\n", + "y_pred = regressor.predict(X_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#backward elimination with statsmodels\n", + "X = np.append(arr = np.ones((969,1)).astype(int), values = data, axis=1)\n", + "x_list = np.array(data.iloc[:,0:-1], dtype = float)\n", + "model = sm.OLS(data.iloc[:,-1], x_list).fit()\n", + "model.summary()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "X = np.append(arr = np.ones((969,1)).astype(int), values = data, axis=1)\n", + "x_list = np.array(data.iloc[:,[0,1,2,3,5,6]], dtype = float)\n", + "model = sm.OLS(data.iloc[:,-1], x_list).fit()\n", + "model.summary()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "X = np.append(arr = np.ones((969,1)).astype(int), values = data, axis=1)\n", + "x_list = np.array(data.iloc[:,[0,2,3,5,6]], dtype = float)\n", + "model = sm.OLS(data.iloc[:,-1], x_list).fit()\n", + "model.summary()" + ] } ], "metadata": { diff --git a/ML-Project/model.ipynb b/ML-Project/model.ipynb index 6ce0955..a385f1b 100644 --- a/ML-Project/model.ipynb +++ b/ML-Project/model.ipynb @@ -1088,7 +1088,79 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "#Train Test Split\n", + "X_train, X_test, y_train, y_test = train_test_split(data.iloc[:,0:-1], data.iloc[:,-1], test_size=0.2, random_state=0)\n", + "X_train" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Linear Regression\n", + "regressor = LinearRegression()\n", + "regressor" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "regressor.fit(X_train, y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Linear Regression Predict\n", + "y_pred = regressor.predict(X_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#backward elimination with statsmodels\n", + "X = np.append(arr = np.ones((969,1)).astype(int), values = data, axis=1)\n", + "x_list = np.array(data.iloc[:,0:-1], dtype = float)\n", + "model = sm.OLS(data.iloc[:,-1], x_list).fit()\n", + "model.summary()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "X = np.append(arr = np.ones((969,1)).astype(int), values = data, axis=1)\n", + "x_list = np.array(data.iloc[:,[0,1,2,3,5,6]], dtype = float)\n", + "model = sm.OLS(data.iloc[:,-1], x_list).fit()\n", + "model.summary()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "X = np.append(arr = np.ones((969,1)).astype(int), values = data, axis=1)\n", + "x_list = np.array(data.iloc[:,[0,2,3,5,6]], dtype = float)\n", + "model = sm.OLS(data.iloc[:,-1], x_list).fit()\n", + "model.summary()" + ] } ], "metadata": { diff --git a/readme.MD b/readme.MD index b326616..112156b 100644 --- a/readme.MD +++ b/readme.MD @@ -7,9 +7,10 @@ **** -- [YouTube Channel](https://www.youtube.com/channel/UCqaZGIkvE8IrgyCdnTAF8Hw) +- [YouTube Channel](https://www.youtube.com/SelmanBaskaya) - [Tanıtım | Kanal İçeriği | Machine Learning & Web Development Projesi #0](https://www.youtube.com/watch?v=BkprXbS6tA4) - [Veri Tipleri, Kolon ve Encoding İşlemleri | Machine Learning & Web Development Projesi #1](https://www.youtube.com/watch?v=uba0iHWMsCY) +- [train_test_split() - Linear Regression - statsmodels | Machine Learning & Web Development Projesi #2](https://www.youtube.com/watch?v=IPCLX1E0mo4) **** @@ -17,8 +18,8 @@ ### Machine Learning - [x] Data labeling - [x] Data preparation -- [ ] Training of the ML Model -- [ ] Optimization of ML Model +- [x] Training of the ML Model +- [x] Optimization of ML Model ### Web Application - [ ] Install Flask