<jupyter_start><jupyter_text>**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_classifier.csv"** dataset from piazza resourse or [click here](https://piazza.com/class_profile/get_resource/ku1fdd7zhev3r2/kwv4ddrap491yz) 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_classifier.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 `'Label'` is also not a feature rather it is our target. $y_i = 1$ means admitted. $y_i = -1$ means not admitted for $i^{th}$ student.  * We will store it in a seperate variable `Y` using `Y = data['Label']`.  * Convert `Y` to numpy array using `Y = Y.values`  * Dorp the column from `data` using `data.drop('Label', axis=1, inplace=True)`* In `data` we are left with two features gre scores &  toefl scores. 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. Assume the admission acceptance is decided based on these two features. So for every $i^{th}$ student has features $x_1$, and $x_2$<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**4. Add a ones column vector to X & partition the data and labels:**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:**This time we design the classifier as follows. The classifier will give the appropriate admission label for an student. If the value $c_0 +c_1 x_1 +c_2x_2$ is positive, sign function outputs $1$. Otherwise it outputs $-1$.$$y_p = np.sign(c_0 +c_1x_1+c_2x_2)$$Now, calculate the coefficients $c = (c_0, c_1, c_2)$ by finding the least square solution for $(Xc = Y)$. Follow the exact procedure followed by earlier lab. So you will find $ĉ$ using the pseudo inverse of X. Use `X_train` and `X_train` as dataset.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**6. Find predicted labels:**Find the predicted labels `Y_test_pred`, by using the formula `Y_test_pred = np.sign(X_test * c_hat)`.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**7. Calculate the accuracy:**Apparently `Y_test` are the ground truths for the test data. Now you have built a classifier that is defined by `c_hat`. Calculate the accuracy of your predicted label: `Y_test_pred` and groundtruth labels: `Y_test`.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**8. Seperate the data into positive and negative:**Finally, separate `X_train` into `X_pos`, `X_neg` using the concept of boolean array indexing and `Y_train`. So that all `X_pos` will have labes `1`. And `X_neg` will have `-1` labels.<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**9. Plot 2D figure with X_pos & X_neg:**Plot 2D figure with `X_pos` and `X_neg` so that for each data point has feature $x_1$ will be on `x-axis` and $x_2$ will be on `y-axis`. Use marker ‘o’ with red color for `X_neg` and marker ‘*’ with blue color for `X_pos`.**Note: Previously we added one vector in $0^{th}$ column of `X`. Hence, feature $x_1=X[1]$ and feature $x_2=X[2]$<jupyter_code># Write appropriate code<jupyter_output><empty_output><jupyter_text>**10. Plot the discriminating line:**Plot the discriminating line produced by the equation $c_0 + c_1 x_1 + c_2x_2 = 0$ by finding:$$x_2 = -( c_0 + c_1x_1) / c_2$$for $x_1 = 290:350$. Now, plot previous plots along with a new line plot using $x_1, x_2$ to see the boundary<jupyter_code># Write appropriate code<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10778312199387845, 'fraction_numerical': 0.017052907739396588, 'mean_word_length': 5.563845050215208, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '510153', 'license': 'MIT', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1448, 'n_words': 581, 'path': 'Lab_8_Building_Least_Square_Binary_Classifier.ipynb', 'repo_name': 'mirsazzathossain/CSE317-Lab', 'size': '4574'}