1
$\begingroup$

I am predicting the number of cars from a traffic dataset.

Here is my data dictionary:

The ‘Traffic-Major-Roads(kilometres)’ file contains the following variables (variable names are in bold):

  • Year - Traffic volumes are shown for each year from 2000 onwards.
  • CP (count point) – a unique reference for the road link that links the AADFs to the road network.
  • ONS GOR Name – the former Government Office Region that the CP sits within.
  • ONS LA Name – the local authority that the CP sits within.
  • Road – this is the road name (for instance M25 or A3).
  • RCat – the classification of the road type (see data definitions for the full list).
  • S Ref E – Easting coordinates of the CP location.
  • S Ref N – Easting coordinates of the CP location.
  • A-Junction – The road name of the start junction of the link
  • B-Junction – The road name of the end junction of the link
  • LenNet – Total length of the network road link for that CP (in kilometres).
  • PC – Traffic volume (in thousands of vehicle kilometres) for pedal cycles.
  • 2WMV – Traffic volume (in thousands of vehicle kilometres) for two-wheeled motor vehicles.
  • Car - Traffic volume (in thousands of vehicle kilometres) for Cars and Taxis.
  • Bus – Traffic volume (in thousands of vehicle kilometres) for Buses and Coaches
  • LGV – Traffic volume (in thousands of vehicle kilometres) for LGVs.
  • HGVR2 – Traffic volume (in thousands of vehicle kilometres) for two-rigid axle HGVs.
  • HGVR3 – Traffic volume (in thousands of vehicle kilometres) for three-rigid axle HGVs.
  • HGVR4 – Traffic volume (in thousands of vehicle kilometres) for four or more rigid axle HGVs.
  • HGVA3 – Traffic volume (in thousands of vehicle kilometres) for three or fourarticulated axle HGVs.
  • HGVA5 – Traffic volume (in thousands of vehicle kilometres) for five-articulated axle HGVs.
  • HGVA6 – Traffic volume (in thousands of vehicle kilometres) for six-articulated axle HGVs.
  • HGV – Traffic volume (in thousands of vehicle kilometres) for all HGVs.
  • AMV – Traffic volume (in thousands of vehicle kilometres) for all motor vehicles.

I need to predict the variable AMV.

So, I have one-hot encoded Road, and kept date, time in my features. But, number of Roads being very large. I have too many features.

Can you please suggest how should I proceed?

$\endgroup$

3 Answers 3

3
$\begingroup$

I am having too many features.

No, you don't :).

First of all, it is highly likely that not all of them are important for the prediction that you want to make.

I would highly recommend using a CART Random Forest for regression of the variable of interest. It literally requires minimal coding if you choose to do it in python using the RF algorithm from the sklearn package.

It's big advantage is that it is straightforward to use and understand and, moreover, it provides you with the learnt feature_importances_ of all inputs after training, so that you can exclude the least important ones and speed up the inference/training in the future.

-EDIT-

To understand the difference between Classification and Regression Decision trees, check this helpful link.

The decision tree implementations for regression are commonly the C4.5, the C5.0 or the CART algorithm. The one that is used by sklearn is CART, please take a look at section 1.10.6 in this link.

A good example of how to use the sklearn Decision Tree for regression is this.

$\endgroup$
4
  • $\begingroup$ hi @pcko1 , thanks for your reply. I have one more doubt. I thought Random Forest is used in classification problems, but this is a regression problem . How can I use it ? Should I look for PCA ? $\endgroup$
    – DukeLover
    Jul 2, 2018 at 18:13
  • $\begingroup$ I edited my answer, kindly check :) $\endgroup$
    – pcko1
    Jul 2, 2018 at 19:15
  • 1
    $\begingroup$ hi @pcko1 , thanks for really insightful and valuable answer. I applied RandomForestRegressor which gave me a significantly lower RMSE. But , I am not sure how to discard the insignificant features. Can you please help me ? Here is my link to kernel : Predicting car count $\endgroup$
    – DukeLover
    Jul 3, 2018 at 10:12
  • $\begingroup$ it is really simple. Check the example in the middle of this page: scikit-learn.org/stable/modules/generated/…. After you print the feature importances (as shown in the example), you will have an understanding of which features are the least important (lowest importance values). Then you can manually exclude them from the next training of your algorithm. $\endgroup$
    – pcko1
    Jul 3, 2018 at 10:52
0
$\begingroup$

From what I understand, your question is regarding feature selection. If that is the case, you could try lasso regression, which is a regularization technique that shrink coefficients of the predictors, thereby helping with feature selection. Hope that helps.

$\endgroup$
0
$\begingroup$

Even I agree that the number of features is less.

I think you should follow the following roadmap to achieve your task:-

  1. Analyze the data and find out columns with missing values
  2. Try to fill up the missing value (if possible) or you may also drop the columns depending upon the nulls in it.
  3. For all the column data where data is not in numerical form, transform the data into the numerical form using the one-hot encoding method.
  4. Now your data is ready to be trained. Meanwhile, you can also see if you want to drop any feature or want to create a new one.
  5. Train your model with any of the regression algorithms like XGBoost, SVM, Lasso Regression, etc and predict your values.
  6. For verification of your model performance, you should check RMSE (Root Mean Squared Error).
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.