Lidar Car Detection
5 Fold Cross Validation Solution for Lidar Car Detection
A detailed solution for challenge Lidar Car Detection
5-Fold Cross Validation XGBoost Solution for Lidar Car Detection
Lidar Car Detection¶
Downloading Dataset¶
Installing aicrowd-cli
In [1]:
!pip install aicrowd-cli
%load_ext aicrowd.magic
In [5]:
%aicrowd login
In [6]:
!rm -rf data
!mkdir data
%aicrowd ds dl -c lidar-car-detection -o data
Importing Libraries¶
In [11]:
import os
import random
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.graph_objects as go
import xgboost as xgb
import lightgbm as lgb
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeRegressor,ExtraTreeRegressor
from sklearn.ensemble import RandomForestRegressor
from sklearn.ensemble import AdaBoostRegressor,BaggingRegressor
from sklearn.ensemble import ExtraTreesRegressor,GradientBoostingRegressor
from sklearn.model_selection import KFold
seed = 2020
Reading the dataset¶
In [13]:
# Reading the training dataset
data_dir = "./data"
train_data = np.load(os.path.join(data_dir,"train.npz"), allow_pickle=True)
train_data = train_data['train']
# Loading the test data
test_data = np.load(os.path.join(data_dir, "test.npz"), allow_pickle=True)
test_data = test_data['test']
train_data.shape, test_data.shape
Out[13]:
Visualizing the dataset¶
In this section, we will be visualizing a sample 3D lidar data
In [9]:
# Getting a random 3D lidar sample data
INDEX = random.randint(0, train_data.shape[0])
# Getting the individual x,y and z points.
x = train_data[INDEX][0][:, 0].tolist()
y = train_data[INDEX][0][:, 1].tolist()
z = train_data[INDEX][0][:, 2].tolist()
# Label for the corrosponding sample ( no. of cars )
label = train_data[INDEX][1]
# Generating the 3D graph
fig = go.Figure(data=[go.Scatter3d(x=x, y=y, z=z,
mode='markers',
marker=dict(
size=1,
colorscale='Viridis',
opacity=0.8))])
print("No. of cars : ", label)
fig.show()