Vehicle Count Prediction From Sensor Data
Sensors which are placed in road junctions collect the data of no of vehicles at different junctions and gives data to the transport manager. Now our task is to predict the total no of vehicles based on sensor data.
Attention reader! Don’t stop learning now. Get hold of all the important Machine Learning Concepts with the Machine Learning Foundation Course at a student-friendly price and become industry ready.
This article explains how to deal with sensor data given with a timestamp and predict the count of the vehicle at a particular time,
Data Set Description:
This dataset contains 2 attributes. They are Datetime and Vehicles. Where Vehicles is the class label.
Link for download this data – click here
The class label is of numeric type. So the regression technique is well suited for this problem. Regression is used to map the data into a predefined function it is a supervised learning algorithm that is used to predict the value based on historical data. We can perform regression on our data if the data is numeric. Here class label Ie Vehicles attribute is the class label which is numeric so regression should be done.
Random Forest Regressor is an ensemble technique that takes the input and builds trees then takes the mean value of all trees per row/per tuple.
Syntax: RandomForestRegressor(n_estimators=100, *, criterion=’mse’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=’auto’, max_leaf_nodes=None,min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None,random_state=None, verbose=0, warm_start=False, ccp_alpha=0.0, max_samples=None)
- Import necessary modules
- Load the dataset
- Analyze the data
- Convert DateTime attribute to week, days, hours, month, etc (which is in timestamp format.)
- Build the model
- Train the model
- Test the data
- Predict the results
Step 1: Importing the pandas module for loading the data frame.
Step 2: Define the functions for getting month, day, hours from the Timestamp (DateTime) and load it into different columns.
Step 3: Separate the class label and store into the target variable
Step 4: Create and train the data using Machine Learning algorithms and predict the results after testing.