## Now the data is available at the following locations:
## Now the data is available at the following locations:
TRAINING_IMAGES_FOLDER="data/train/cameraFront"
TRAINING_IMAGES_FOLDER="data/train/cameraFront"
TRAINING_LABELS_PATH="data/train/train.csv"
TRAINING_LABELS_PATH="data/train/train.csv"
TESTING_LABELS_PATH="data/test/test.csv"
TESTING_LABELS_PATH="data/test/test.csv"
TESTING_IMAGES_FOLDER="data/test/cameraFront"
TESTING_IMAGES_FOLDER="data/test/cameraFront"
# For this baseline, we will only be using the front camera angle of the car just for demonstration purpose. For actual one should try and see the best combination of all the angles
# For this baseline, we will only be using the front camera angle of the car just for demonstration purpose. For actual one should try and see the best combination of all the angles
We use PIL library to load our images. Here we are creating our array where our input features are the mean colours and output features are the rotations along the x axis.
We use PIL library to load our images. Here we are creating our array where our input features are the mean colours and output features are the rotations along the x axis.
We now see the kind of images the dataset contains to get a better idea.
We now see the kind of images the dataset contains to get a better idea.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
plt.figure(figsize=(20,20))
plt.figure(figsize=(20,20))
foriinrange(16):
foriinrange(16):
filename,xRot=training_labels_df.iloc[i]
filename,xRot=training_labels_df.iloc[i]
filepath=os.path.join(
filepath=os.path.join(
TRAINING_IMAGES_FOLDER,
TRAINING_IMAGES_FOLDER,
filename
filename
)
)
im=Image.open(filepath)
im=Image.open(filepath)
plt.subplot(4,4,i+1)
plt.subplot(4,4,i+1)
plt.axis('off')
plt.axis('off')
plt.title("canSteering: %.3f"%(xRot))
plt.title("canSteering: %.3f"%(xRot))
plt.imshow(im)
plt.imshow(im)
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Split Data into Train and Validation
## Split Data into Train and Validation
We split the dataset into Training data and Validation datasets to help us test the generalizability of our models, and to ensure that we are not overfitting on the training set.
We split the dataset into Training data and Validation datasets to help us test the generalizability of our models, and to ensure that we are not overfitting on the training set.
Here we have selected the size of the testing data to be 20% of the total data. You can change it and see what effect it has on the accuracies. To learn more about the train_test_split function [click here](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html).
Here we have selected the size of the testing data to be 20% of the total data. You can change it and see what effect it has on the accuracies. To learn more about the train_test_split function [click here](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html).
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Now, since we have our data splitted into train and validation sets, we need to get the label separated from the data.
Now, since we have our data splitted into train and validation sets, we need to get the label separated from the data.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
X_train,y_train=zip(*training_set)
X_train,y_train=zip(*training_set)
X_val,y_val=zip(*validation_set)
X_val,y_val=zip(*validation_set)
X_train=np.array(X_train)
X_train=np.array(X_train)
y_train=np.array(y_train)
y_train=np.array(y_train)
X_val=np.array(X_val)
X_val=np.array(X_val)
y_val=np.array(y_val)
y_val=np.array(y_val)
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Define the Classifier
## Define the Classifier
Now we finally come to the juicy part.
Now we finally come to the juicy part.
Now that all the data is all loaded and available nice, we can finally get to training the classifier. Here we use sklearn [`MLPRegressor`](https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPRegressor.html) to train our network. We can tune the hyper parameters based on cross validation scores
Now that all the data is all loaded and available nice, we can finally get to training the classifier. Here we use sklearn [`MLPRegressor`](https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPRegressor.html) to train our network. We can tune the hyper parameters based on cross validation scores
**Note**: Do take a look at the submission format.The submission file should contain the following header : `filename,xRot`.
**Note**: Do take a look at the submission format.The submission file should contain the following header : `filename,xRot`.
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## To download the generated csv in Google Colab run the below command
## To download the generated csv in Google Colab run the below command
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
fromgoogle.colabimportfiles
fromgoogle.colabimportfiles
files.download('submission.csv')
files.download('submission.csv')
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
### Well Done! 👍 We are all set to make a submission and see your name on leaderborad. Lets navigate to [challenge page](https://www.aicrowd.com/challenges/autodri) and make one.
### Well Done! 👍 We are all set to make a submission and see your name on leaderborad. Lets navigate to [challenge page](https://www.aicrowd.com/challenges/autodri) and make one.