<jupyter_start><jupyter_text>**Problem Statement:**In this experiment we will do Ordinary least squares (multiple) regression for the prediction of Graduate Admissions from an Indian/Bangladeshi perspective. The dataset can be obtained from[Piazza](https://piazza.com/class_profile/get_resource/ku1fdd7zhev3r2/kwaz7m8lx5a52k) and [Kaggle](https://www.kaggle.com/mohansacharya/graduate-admissions). The dataset (Admission_Predict.csv) containss even features arranged into columns in a CSV file. There are 400 sample datapoints. The features are as follows:1. GRE Scores (out of 340)2. TOEFL Scores (out of 120)3. University Rating (out of 5)4. Statement of Purpose and Letter of Recommendation Strength (out of 5)5. Undergraduate GPA (out of 10)6. Research Experience (either 0 or 1)7. Chance of Admit (ranging from 0 to 1)The first column of the dataset contains a serial number, and the final column provide the probability of getting admission, i.e. the target output for each datapoint.We will be using the dataset to create a linear regression model in order to determine the chances of admission of a new sample student, and to assess how well our model works in making a useful forecast.  **1. Import necessary packages:**<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**2. Upload and load dataset:**At first we have to upload the dataset to google colab to start working with it. Please download the **"Admission_Predict.csv"** dataset from piazza resourse or [click here](https://piazza.com/class_profile/get_resource/ku1fdd7zhev3r2/kwaz7m8lx5a52k) to download it. Then click on files form sidebar, drag and drop your file to side bar to upload the dataset.Now, use `data = pd.read_csv("Admission_Predict.csv")` to load the data.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**3. Preprocess the Data:*** To visualize the loaded data use `print(data.head())`. * Now, after visualizing the data did you observe we have an extra column named `Serial No.`? * This certainly is not a feature, so we will drop this column. Use `data.drop('Serial No.', axis=1, inplace=True)` to drop the column.* See the column `'Chance of Admit'` is also not a feature rather it is our target.   * We will store it in a seperate variable `y` using `y = data['Chance of Admit ']`.  * Convert `y` to numpy array using `y = y.values`  * Dorp the column from `data` using `data.drop('Chance of Admit ', axis=1, inplace=True)`* In `data` we are left with all 7 features. Covert it to numpy array and store in a new variable `X` using `X = data.values`. So, `X` is the matrix of feature columns, each column in `X` will be the feature vectors.☢ Note: Be careful about the space after the column name `'Chance of Admit '`.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**4. Add a ones column vector to X:**Add a new column cosisting ones as $0^{th}$ column to X. Saw the [numpy documentation](https://numpy.org/doc/stable/reference/generated/numpy.c_.html) for more details. Devide data X and y into x_train, x_test, y_train and y_test. Train dataset will contains 300 datapoints and test dataset will contains 100 datapoint.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**5. Solve the system of equation:**Solve the system of equations $(Xβ = y)$ to find the values of the $β$ vector $(β_0, β_1, β_2, \ldots, β_n)$. You can find $β$ using $β = X^† y = (X^T X)^{−1} X^T y = R^{−1} Q^T y$. There is also a numpy function to calculate the psuedo inverse: `np.linalg.pinv()`, saw the [numpy documentation](https://numpy.org/doc/stable/reference/generated/numpy.linalg.pinv.html) for more details. Use `x_train` and `y_train` as dataset.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**6. Find predicted chance of admit:**Find the predicted chance of admit $\hat y$, by multiplying $X * β$. For prediction use `x_test` as dataset.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**7. Find the error vector e:**Find the error vector, $e$, by subtracting $\hat y$ from `y_test`.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**8. Compute the $r^2$ value:**Recall that, $r^2 = 1 - SSE / SST$, where $SSE$ is the sum of squared errors: $e^Te$ and $SST = \text{Total sum of squares : } (\text{y_test} - avg(\text{y_test}))^T(\text{y_test} - avg(\text{y_test}))$<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**9. Plot the vectors $y$, $\hat y$, and $e$:**Plot the vectors $\text{y_test}$, $\hat y$, and $e$, and make suitable observations. Use different color for three vectors while ploting.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**10. Test with new data:**Introduce a new sample student with your own data, and find where they fall.<jupyter_code># Write appropriate code<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup