Question: Please help me solve file DAC's Classification and Evaluation according to the pictured instructions. #Step 1 : # Import libraries # In this section, you

Please help me solve file DAC's Classification and Evaluation according to the pictured instructions.
#Step 1:
# Import libraries
# In this section, you can use a search engine to look for the functions that will help you implement the following steps
#Step 2:
# Load dataset and show basic statistics
# 1. Show dataset size (dimensions)
# 2. Show what column names exist for the 49 attributes in the dataset
# 3. Show the distribution of the target class CES 4.0 Percentile Range column
# 4. Show the percentage distribution of the target class CES 4.0 Percentile Range column
# Step 3:
#Clean the dataset - you can eitherhandle the missing values in the dataset
# with the mean of the columns attributes or remove rows the have missing values.
# Step 4:
#Encode the Categorical Variables - Using OrdinalEncoder from the category_encoders library to encode categorical variables as ordinal integers
# Step 5:
# Separate predictor variables from the target variable (attributes (X) and target variable (y) as we did in the class)
# Create train and test splits for model development. Use the 90% and 20% split ratio
# Use stratifying (stratify=y) to ensure class balance in train/test splits
# Name them as X_train, X_test, y_train, and y_test
# Name them as X_train, X_test, y_train, and y_test
X_train =[] # Remove this line after implementing train test split
X_test =[] # Remove this line after implementing train test split
# Do not do steps 6-8 for the Ramdom Forest Model
# Step 6:
# Standardize the features (Import StandardScaler here)
# Step 7:
# Below is the code to convert X_train and X_test into data frames for the next steps
cols = X_train.columns
X_train = pd.DataFrame(X_train, columns=[cols]) # pd is the imported pandas lirary - Import pandas as pd
X_test = pd.DataFrame(X_test, columns=[cols]) # pd is the imported pandas lirary - Import pandas as pd
# Step 8- Build and train the SVM classifier
# Train SVM with the following parameters. (use the parameters with the highest accuracy for the model)
# 1. RBF kernel
# 2. C=10.0(Higher value of C means fewer outliers)
# 3. gamma =0.3(Linear)
# Test the above developed SVC on unseen pulsar dataset samples
# compute and print accuracy score
# Save your SVC model (whatever name you have given your model) as .sav to upload with your submission
# You can use the library pickle to save and load your model for this assignment
# Optional: You can print test results of your model here if you want. Otherwise implement them in evaluation.py file
# Get and print confusion matrix
cm =[[]]
# Below are the metrics for computing classification accuracy, precision, recall and specificity
TP = cm[0,0]
TN = cm[1,1]
FP = cm[0,1]
FN = cm[1,0]
# Compute Precision and use the following line to print it
precision =0 # Change this line to implement Precision formula
print('Precision : {0:0.3f}'.format(precision))
# Compute Recall and use the following line to print it
recall =0 # Change this line to implement Recall formula
print('Recall or Sensitivity : {0:0.3f}'.format(recall))
# Compute Specificity and use the following line to print it
specificity =0 # Change this line to implement Specificity formula
print('Specificity : {0:0.3f}'.format(specificity))
# Step 9: Build and train the Random Forest classifier
# Train Random Forest with the following parameters.
# (n_estimators=10, random_state=0)
# Test the above developed Random Forest model on unseen DACs dataset samples
# compute and print accuracy score
# Save your Random Forest model (whatever name you have given your model) as .sav to upload with your submission
# You can use the library pickle to save and load your model for this assignment
# Optional: You can print test results of your model here if you want. Otherwise implement them in evaluation.py file
# Get and print confusion matrix
cm =[[]]
# Below are the metrics for computing classification accuracy, precision, recall and specificity
TP = cm[0,0]
TN = cm[1,1]
FP = cm[0,1]
FN = cm[1,0]
# Compute Classification Accuracy and use the following line to print it
classification_accuracy =0
print('Classification accuracy : {0:0.4f}'.format(classification_accuracy))
# Compute Precision and use the following line to print it
precision =0 # Change this line to implement Precision formula
print('Precision : {0:0.3f}'.format(precision))
# Compute Recall and use the following line to print it
recall =0 # Change this line to implement Recall formula
print('Recall or Sensitivity : {0:0.3f}'.format(recall))
# Compute Specificity and use the following line to print it
specificity =0 # Change this line to implement Specificity formula
print('Specificity : {0:0.3f}'.format(specificity))
Evaluation file in picture
Assignment brief in picture
Please help me solve file DAC's Classification

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!