[Week 5–6 Buildings In The City]

Harun Doğanay
bbm406f17
Published in
3 min readJan 5, 2018

In 5th an 6th weeks we have worked on methods. Then we gathered result from each.

We used 5 different methods. These are Convolutional Neural Networks,Support-Vector Machine, Decision Tree,Random Forest,Gradient Boosting.

Convolutional Neural Network

One of the most popular techniques used in improving the accuracy of image classification is Convolutional Neural Networks (CNNs for short).
Building a Convolutional Neural Network We used 80% of the data as the training set and 20% as the test set. X train, X test, y train, y test = train test split(X, y, test size=0.2, random state=4) Now that we’re done pre-processing and splitting our dataset we can start implementing our neural network. We used Keras deep learning library in python to build our CNN(Convolutional Neural Network). The process of building a Convolutional Neural Network always involves four major steps.
Step — 1 : Convolution
Step — 2 : Pooling
Step — 3 : Flattening
Step — 4 : Fully connection

We have been through each of the above procedures while coding our neural network. First let us import all the required keras packages using which we are going to build our CNN, make sure that every package is installed properly in your machine, there is two ways os using keras, i.e Using Tensorflow backend and by using Theano backend.We tested the below code using Theano backend

Support Vector Machines

In Python, scikit-learn is a widely used library for implementing machine learning algorithms, SVM is also available in scikit-learn library and follow the same structure.(Import library, object creation, fitting model and prediction).

Decision Tree

While building our decision tree classifier, we can improve its accuracy by tuning it with different parameters(you can see below). But this tuning should be done carefully since by doing this our algorithm can overfit on our training data & ultimately it will build bad generalization model.

DecisionTreeClassifier(): This is the classifier function for DecisionTree. It is the main function for implementing the algorithms

Random Forest

Random forest algorithm is a supervised classification algorithm and an ensemble learning method. As the name suggest, this algorithm creates the forest with a number of trees. Random Forest is less vulnerable to overfitting.Random Forest is also available in scikitlearn library and we used it from scikit

Gradient Boosting

Stochastic Gradient Boosting (also called Gradient Boosting Machines) is one of the most sophisticated ensemble techniques. Gradient Boosting is also available in scikit-learn library and follow the same structure (Import library, object creation, fitting model and prediction). It is also a technique that is proving to be perhaps of the the best techniques available for improving performance via ensembles.

We construct a Gradient Boosting model for classification using the GradientBoostingClassifier class. This technique employs the logic in which the subsequent predictors learn from the mistakes of the previous predictors. Therefore, the observations have an unequal probability of appearing in subsequent models and ones with the highest error appear most.

RESULTS

In fact, after we selected this project, it was stated that the research that we conducted resulted in the best result cnn in such photo classification projects. We gave our concentration to CNN. We tested 4–5 models. Some of them gave bad results. We’ll examine the top three models here. We have tried dozens of different configurations for these three models. We have updated the parameters according to the results we have achieved.

Convolutional Neural Network

Model 1 accuracy: 50% Our first model 2 convolution layer, 4 activation layer, 1 max pooling, dropout flatten and dense layers. We have used relu as an activation function.The last layers are softmax.

Model 2 accuracy: 54% Our second model has 6 convolution layer, 6 dropout layer, 3 max pooling, flatten and dense layers.We have used relu as an activation function.The last layers are softmax.

Model 3 accuracy: 57% Our last and third model has 6 convolution layer, 4 dropout layer, 3 max pooling, flatten and dense layers. We have used relu as an activation function. The last layers are softmax

Support Vector Machines

Best accuracy: 55%
One of the most preferred photo classification algorithms is SVMs. We tested the SVM algorithm to see and compare how successful our CNN models are. With SVM we have achieved much better results than we expected. Obviously, we were not hoping that SVM could get such close results to CNN

Decision Tree

if we give ’gini’ as criterion parameter we get 34% accuracy and if we give ’entropy’ as criterion parameter we get 35% accuracy.

Random Forest Best accuracy: 45%

Gradient Boosting Best accuracy: 48%

--

--