DBSRA
[Getting Started Notebook] DBSRA Challange
This is a Baseline Code to get you started with the challenge.
You can use this code to start understanding the data and create a baseline model for further imporvments.
Starter Code for DBSRA Practice Challange
Author: Gauransh Kumar¶
Note : Create a copy of the notebook and use the copy for submission. Go to File > Save a Copy in Drive to create a new copy
Downloading Dataset¶
Installing aicrowd-cli
!pip install aicrowd-cli
%load_ext aicrowd.magic
%aicrowd login
!rm -rf data
!mkdir data
%aicrowd ds dl -c dbsra -o data
Importing Libraries¶
In this baseline, we will be using skleanr library to train the model and generate the predictions
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.ensemble import AdaBoostClassifier
import os
import matplotlib.pyplot as plt
import seaborn as sns
from IPython.display import display
Reading the dataset¶
Here, we will read the train.csv
which contains both training samples & labels, and test.csv
which contains testing samples.
# Reading the CSV
train_data_df = pd.read_csv("data/train.csv")
test_data_df = pd.read_csv("data/test.csv")
# train_data.shape, test_data.shape
display(train_data_df.head())
display(test_data_df.head())
Data Preprocessing¶
# selecting column with only np.int64 dtype
# only for ease of model creation and baseline purpose
# must not be considered in real competition
train_cols = []
for column in train_data_df.columns:
if train_data_df[column].dtype == np.int64:
train_cols.append(column)
print(train_cols)
# Separating data from the dataframe for final training
X = train_data_df[train_cols[:-1]].to_numpy()
y = train_data_df[train_cols[-1]].to_numpy()
print(X.shape, y.shape)
# Visualising the final lable classes for training
sns.countplot(y)
Splitting the data¶
# Splitting the training set, and training & validation
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2)
print(X_train.shape)
print(y_train.shape)
X_train[0], y_train[0]
Training the Model¶
model = AdaBoostClassifier()
model.fit(X_train, y_train)
Validation¶
model.score(X_val, y_val)
So, we are done with the baseline let's test with real testing data and see how we submit it to challange.
Predictions¶
# Separating data from the dataframe for final testing
X_test = test_data_df[train_cols[:-1]].to_numpy()
print(X_test.shape)
# Predicting the labels
predictions = model.predict(X_test)
predictions.shape
# Converting the predictions array into pandas dataset
submission = pd.DataFrame({"readmitted":predictions})
submission
# Saving the pandas dataframe
!rm -rf assets
!mkdir assets
submission.to_csv(os.path.join("assets", "submission.csv"), index=False)
Submitting our Predictions¶
Note : Please save the notebook before submitting it (Ctrl + S)
!!aicrowd submission create -c dbsra -f assets/submission.csv
Content
Comments
You must login before you can post a comment.