Title: | Traffic Predictions Using Neural Networks |
---|---|
Description: | Estimate and return either the traffic speed or the car entries in the city of Thessaloniki using historical traffic data. It's used in transport pilot of the 'BigDataEurope' project. There are functions for processing these data, training a neural network, select the most appropriate model and predict the traffic speed or the car entries for a selected time date. |
Authors: | Kleanthis Koupidis [aut, cre], Aikaterini Chatzopoulou [aut], Charalampos Bratsas [aut], Panagiotis Tzenos [dtc], Josep Maria Salanova [dtc] |
Maintainer: | Kleanthis Koupidis <[email protected]> |
License: | GPL-2 | file LICENSE |
Version: | 0.1.1 |
Built: | 2025-03-08 05:02:55 UTC |
Source: | https://github.com/okgreece/trafficbde |
This function fills the missing dates from the data.
fillMissingDates(Data, datetime)
fillMissingDates(Data, datetime)
Data |
The historical data |
datetime |
The datetime wanted |
This function returns a data frame without missing dates.
A data frame with all the historical data between the first date and the date wanted.
Aikaterini Chatzopoulou, Charalampos Bratsas
SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime)
SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime)
This function fills the missing values from the data.
fillMissingValues(Data)
fillMissingValues(Data)
Data |
The historical data of the roads of Thessaloniki |
This function returns a data frame without missing values.
A data frame with all the historical data without missing values
Aikaterini Chatzopoulou, Kleanthis Koupidis, Charalampos Bratsas
SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink)
SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink)
This function predictes the wanted value after k steps.
kStepsForward (Data, Link_id, direction, datetime, predict, steps)
kStepsForward (Data, Link_id, direction, datetime, predict, steps)
Data |
A data frame with the historical data |
Link_id |
A character with the id of the road needed |
direction |
The direction of the road |
datetime |
The datetime wanted |
predict |
The value to be predicted |
steps |
The number of steps |
This function returns the predicted value after k steps.
The predicted value
Aikaterini Chatzopoulou, Kleanthis Koupidis, Charalampos Bratsas
## Not run: kStepsForward (X163204843_1, "163204843", "1", "2017-01-27 14:00:00", "Mean_speed", 1) ## End(Not run)
## Not run: kStepsForward (X163204843_1, "163204843", "1", "2017-01-27 14:00:00", "Mean_speed", 1) ## End(Not run)
This function loads the traffic data.
loadData(path)
loadData(path)
path |
The path where the data are. |
This function returns a data frame with the traffic data of the roads of Thessaloniki ordered by the roads.
Returns a data frame.
Aikaterini Chatzopoulou, Kleanthis Koupidis, Charalampos Bratsas
This function extracts the data of one road of Thessaloniki.
loadDataSpecLink(Link_id, direction, Data)
loadDataSpecLink(Link_id, direction, Data)
Link_id |
A character with the id of the road needed |
direction |
The direction of the road |
Data |
The historical data of the roads of Thessaloniki |
This function returns a data frame with the historical data of a specific road.
A data frame with the data of a specific road
Aikaterini Chatzopoulou, Kleanthis Koupidis
This function returns a list with the train and test data.
loadTrainTest(Data, datetime, predict)
loadTrainTest(Data, datetime, predict)
Data |
The historical data |
datetime |
The date time the user wants to predict |
predict |
The value he user wants to predict must be a column name of the data set |
This function returns a list with the train and test data that will be used for train and prediction.
A list with the following components:
trainsData The trainData for the model
testsData The testData to be predict
Aikaterini Chatzopoulou, Kleanthis Koupidis, Charalampos Bratsas
SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime) DataList <- loadTrainTest (newData, datetime, "Mean_speed")
SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime) DataList <- loadTrainTest (newData, datetime, "Mean_speed")
This function predicts the average speed of the road.
PredictionCR(List,NNOut,predict)
PredictionCR(List,NNOut,predict)
List |
A list with the following components: trainset, testset, MinMaxFromScaling |
NNOut |
The train model |
predict |
The value to be predicted |
This function returns the predicted average speed.
The predicted average speed of the road
Aikaterini Chatzopoulou, Kleanthis Koupidis, Charalampos Bratsas
## Not run: SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime) DataList <- loadTrainTest (newData, datetime, "Mean_speed") List <- PreProcessingLink(DataList) NNOut <- TrainCR (List,"Mean_speed") predicted <- PredictionCR(List,NNOut,"Mean_speed") ## End(Not run)
## Not run: SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime) DataList <- loadTrainTest (newData, datetime, "Mean_speed") List <- PreProcessingLink(DataList) NNOut <- TrainCR (List,"Mean_speed") predicted <- PredictionCR(List,NNOut,"Mean_speed") ## End(Not run)
This function processes the data.
PreProcessingLink(DataList)
PreProcessingLink(DataList)
DataList |
A list with the following components: trainData, testData, trainDataWide, cormat |
This function returns as a list object the parameters needed to train the model and predict.
A list with the following components:
trainset The trainset for the model
testset The testset to be predict
Minimum The min values of each column of the initial dataset
Maximum The max values of each column of the initial dataset
Aikaterini Chatzopoulou, Kleanthis Koupidis
SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime) DataList <- loadTrainTest (newData, datetime, "Mean_speed") List <- PreProcessingLink(DataList)
SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime) DataList <- loadTrainTest (newData, datetime, "Mean_speed") List <- PreProcessingLink(DataList)
This function trains the model.
TrainCR(List,predict)
TrainCR(List,predict)
List |
A list with the following components: trainset, testset, Min, Max |
predict |
The value to be predicted |
This function returns the trained model.
The train model
Aikaterini Chatzopoulou, Kleanthis Koupidis
## Not run: SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime) DataList <- loadTrainTest (newData, datetime, "Mean_speed") List <- PreProcessingLink(DataList) NNout <- TrainCR (List,"Mean_speed") ## End(Not run)
## Not run: SpecLink <- loadDataSpecLink("163204843","1", X163204843_1) x <- fillMissingValues(SpecLink) datetime <- "2017-01-27 14:00:00" newData <- fillMissingDates (x, datetime) DataList <- loadTrainTest (newData, datetime, "Mean_speed") List <- PreProcessingLink(DataList) NNout <- TrainCR (List,"Mean_speed") ## End(Not run)
Sample data of the traffic data of the road with Lik id "163204843" and direction = "1"
The Link id of the road
The direction of the road
The date and time of the recorded arguments
The min speed each time
The max speed each time
The mean speed each time
The standard deviation of the speed
The skewness of the speed
The kurtosis of the speed
The entries each time
The unique entries each time
RData file
TrafficBDE