{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Crop_Yield_Prediction_MLR.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyONwS0T7Li3k/T3RKX692yJ"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","metadata":{"id":"R5QjBRaAyC_H"},"source":["# Multiple Linear Regression\n"]},{"cell_type":"markdown","metadata":{"id":"lIMTzfBSy8Vh"},"source":["## Importing the libraries"]},{"cell_type":"code","metadata":{"id":"rN03-Fe5mUhY","executionInfo":{"status":"ok","timestamp":1628941880039,"user_tz":-480,"elapsed":3,"user":{"displayName":"Avinnaash Suresh","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gg43tbnG3E_ve7kI59iMhn1idBD-ZqV8v0bXDut=s64","userId":"14263710632077858620"}}},"source":["import numpy as np\n","import matplotlib.pyplot as plt\n","import pandas as pd"],"execution_count":8,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"aePtTVsdp2V9","executionInfo":{"status":"ok","timestamp":1628941880375,"user_tz":-480,"elapsed":5,"user":{"displayName":"Avinnaash Suresh","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gg43tbnG3E_ve7kI59iMhn1idBD-ZqV8v0bXDut=s64","userId":"14263710632077858620"}},"outputId":"4ae0b567-a46e-4393-948b-d8691d128033"},"source":["from google.colab import drive\n","drive.mount('/content/drive')"],"execution_count":9,"outputs":[{"output_type":"stream","text":["Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"Sx5g6jHGzE2_"},"source":["## Importing the dataset"]},{"cell_type":"code","metadata":{"id":"YL7Nm_VNnDiG","executionInfo":{"status":"ok","timestamp":1628941881076,"user_tz":-480,"elapsed":704,"user":{"displayName":"Avinnaash Suresh","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gg43tbnG3E_ve7kI59iMhn1idBD-ZqV8v0bXDut=s64","userId":"14263710632077858620"}}},"source":["dataset = pd.read_csv('/content/drive/MyDrive/Omdena/Local - Malaysia/Malaysia Chapter/Improving Food Security and Crop Yield in Malaysia with Machine Learning/Task 4 - Crop Yield Prediction/Dataset/data_crop_yield.csv')\n","X = dataset.iloc[:, :-1].values\n","y = dataset.iloc[:, -1].values"],"execution_count":10,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":414},"id":"u2Q5VuTxjoX2","executionInfo":{"status":"ok","timestamp":1628941881077,"user_tz":-480,"elapsed":21,"user":{"displayName":"Avinnaash Suresh","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gg43tbnG3E_ve7kI59iMhn1idBD-ZqV8v0bXDut=s64","userId":"14263710632077858620"}},"outputId":"d4dc63e0-487a-4e52-94e2-c7aa360d4c85"},"source":["dataset"],"execution_count":11,"outputs":[{"output_type":"execute_result","data":{"text/html":["
\n"," | Crop | \n","Precipitation (mm day-1) | \n","Specific Humidity at 2 Meters (g/kg) | \n","Relative Humidity at 2 Meters (%) | \n","Temperature at 2 Meters (C) | \n","Yield | \n","
---|---|---|---|---|---|---|
0 | \n","Cocoa, beans | \n","2248.92 | \n","17.72 | \n","83.40 | \n","26.01 | \n","11560 | \n","
1 | \n","Cocoa, beans | \n","1938.42 | \n","17.54 | \n","82.11 | \n","26.11 | \n","11253 | \n","
2 | \n","Cocoa, beans | \n","2301.54 | \n","17.81 | \n","82.79 | \n","26.24 | \n","9456 | \n","
3 | \n","Cocoa, beans | \n","2592.35 | \n","17.61 | \n","85.07 | \n","25.56 | \n","9321 | \n","
4 | \n","Cocoa, beans | \n","2344.72 | \n","17.61 | \n","84.12 | \n","25.76 | \n","8800 | \n","
... | \n","... | \n","... | \n","... | \n","... | \n","... | \n","... | \n","
151 | \n","Rubber, natural | \n","2308.51 | \n","18.27 | \n","83.65 | \n","26.47 | \n","6721 | \n","
152 | \n","Rubber, natural | \n","2410.13 | \n","18.58 | \n","83.45 | \n","26.81 | \n","6248 | \n","
153 | \n","Rubber, natural | \n","2967.41 | \n","18.67 | \n","85.48 | \n","26.46 | \n","6842 | \n","
154 | \n","Rubber, natural | \n","2333.46 | \n","18.50 | \n","84.85 | \n","26.43 | \n","5571 | \n","
155 | \n","Rubber, natural | \n","2109.34 | \n","18.51 | \n","83.52 | \n","26.72 | \n","5903 | \n","
156 rows × 6 columns
\n","\n"," | Precipitation (mm day-1) | \n","Specific Humidity at 2 Meters (g/kg) | \n","Relative Humidity at 2 Meters (%) | \n","Temperature at 2 Meters (C) | \n","Yield | \n","
---|---|---|---|---|---|
count | \n","156.000000 | \n","156.000000 | \n","156.000000 | \n","156.00000 | \n","156.000000 | \n","
mean | \n","2486.498974 | \n","18.203077 | \n","84.737692 | \n","26.18359 | \n","56153.096154 | \n","
std | \n","289.457914 | \n","0.293923 | \n","0.996226 | \n","0.26105 | \n","70421.958897 | \n","
min | \n","1934.620000 | \n","17.540000 | \n","82.110000 | \n","25.56000 | \n","5249.000000 | \n","
25% | \n","2302.990000 | \n","18.030000 | \n","84.120000 | \n","26.02000 | \n","8327.750000 | \n","
50% | \n","2424.550000 | \n","18.270000 | \n","84.850000 | \n","26.13000 | \n","18871.000000 | \n","
75% | \n","2718.080000 | \n","18.400000 | \n","85.510000 | \n","26.30000 | \n","67518.750000 | \n","
max | \n","3085.790000 | \n","18.700000 | \n","86.100000 | \n","26.81000 | \n","203399.000000 | \n","