<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: João Castro</title>
    <description>The latest articles on DEV Community by João Castro (@jcastroo).</description>
    <link>https://dev.to/jcastroo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1155059%2F8d7b7e09-aa9f-4cb6-84b3-96b8ab82b760.jpeg</url>
      <title>DEV Community: João Castro</title>
      <link>https://dev.to/jcastroo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jcastroo"/>
    <language>en</language>
    <item>
      <title>Can Your Smartphone Detect Aggressive Driving? Building a ConvLSTM with Sensor Data</title>
      <dc:creator>João Castro</dc:creator>
      <pubDate>Fri, 11 Sep 2026 14:59:31 +0000</pubDate>
      <link>https://dev.to/jcastroo/can-your-smartphone-detect-aggressive-driving-building-a-convlstm-with-sensor-data-1gag</link>
      <guid>https://dev.to/jcastroo/can-your-smartphone-detect-aggressive-driving-building-a-convlstm-with-sensor-data-1gag</guid>
      <description>&lt;p&gt;What if a smartphone could recognize aggressive driving without any specialized hardware installed in the vehicle?&lt;/p&gt;

&lt;p&gt;Modern phones already contain accelerometers, gyroscopes, and GPS sensors capable of capturing how a vehicle moves. The real challenge is turning those noisy, continuous signals into reliable information about the person behind the wheel.&lt;/p&gt;

&lt;p&gt;In our recently published research, &lt;strong&gt;“Driving Behavior Classification Using a ConvLSTM,”&lt;/strong&gt; we explored exactly that. We developed a deep-learning pipeline that distinguishes between &lt;strong&gt;normal and aggressive driving&lt;/strong&gt;, using data collected through a mobile application in real driving conditions.&lt;/p&gt;

&lt;p&gt;The proposed model achieved &lt;strong&gt;99.75% accuracy&lt;/strong&gt;, outperforming the Stacked LSTM and Bidirectional LSTM architectures evaluated in the same study.&lt;/p&gt;

&lt;p&gt;But the most important lesson was not simply that one neural network performed better than another.&lt;/p&gt;

&lt;p&gt;It was that &lt;strong&gt;better data representation can matter as much as model complexity&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why driving behavior classification matters
&lt;/h2&gt;

&lt;p&gt;Driving behavior affects far more than individual road safety. Reliable classification can support:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Advanced driver-assistance systems;&lt;/li&gt;
&lt;li&gt;Fleet monitoring and risk assessment;&lt;/li&gt;
&lt;li&gt;More efficient transport and logistics operations;&lt;/li&gt;
&lt;li&gt;Fuel-consumption analysis;&lt;/li&gt;
&lt;li&gt;Usage-based insurance;&lt;/li&gt;
&lt;li&gt;Intelligent Transport Systems;&lt;/li&gt;
&lt;li&gt;Research into autonomous and connected vehicles.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Many existing approaches depend on vehicle-integrated sensors or manufacturer-specific data. That can introduce cost, compatibility, and accessibility limitations.&lt;/p&gt;

&lt;p&gt;We wanted to investigate a more portable alternative: &lt;strong&gt;a software-based system built around sensors already available in a smartphone&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Collecting real-world data with a phone
&lt;/h2&gt;

&lt;p&gt;We developed a dedicated mobile application to record:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linear acceleration across the X, Y, and Z axes;&lt;/li&gt;
&lt;li&gt;Angular velocity from the gyroscope across the same axes;&lt;/li&gt;
&lt;li&gt;GPS position and vehicle speed;&lt;/li&gt;
&lt;li&gt;Timestamps and device metadata.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The data were collected in real driving scenarios using two vehicles. To reduce unwanted variation, the smartphones were placed consistently in a horizontal position, facing upward, with the accelerometer’s Y-axis aligned with the front of the vehicle.&lt;/p&gt;

&lt;p&gt;This detail matters. A model cannot learn meaningful motion patterns if the sensor orientation changes unpredictably between sessions.&lt;/p&gt;

&lt;p&gt;The recorded signals captured events such as sudden acceleration, hard braking, turns, lane changes, and abrupt stops or starts. These raw measurements formed the basis for classifying driving as either normal or aggressive.&lt;/p&gt;

&lt;h2&gt;
  
  
  The difficult part: preprocessing
&lt;/h2&gt;

&lt;p&gt;Raw sensor data are noisy, inconsistent, and difficult for a model to interpret directly. For that reason, preprocessing became a central part of our work rather than a minor preparation step.&lt;/p&gt;

&lt;p&gt;Our pipeline included:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cleaning and structuring the sensor readings&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Separating positive and negative motion values&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transforming the six accelerometer and gyroscope axes into twelve features&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Normalizing the resulting values&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Labeling driving behavior using identified maneuvers&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Preparing the sequences for model training&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Why split positive and negative values?&lt;/p&gt;

&lt;p&gt;The direction of movement carries meaning. An acceleration in one direction and the same magnitude in the opposite direction should not become indistinguishable. We therefore represented each original signal using separate positive and negative components, with negative magnitudes converted to absolute values in their corresponding columns.&lt;/p&gt;

&lt;p&gt;This produced a consistent, non-negative representation while preserving directional information.&lt;/p&gt;

&lt;p&gt;In practical terms, the pipeline transformed low-level readings from the &lt;strong&gt;sensor domain&lt;/strong&gt; into features that were more useful in the &lt;strong&gt;maneuver domain&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That transformation was essential to the final performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why combine Conv1D and LSTM?
&lt;/h2&gt;

&lt;p&gt;Driving data are time series. A single reading tells us very little; the relevant information lies in how measurements evolve across a sequence.&lt;/p&gt;

&lt;p&gt;An LSTM is a natural choice because it can learn temporal dependencies. However, local patterns also matter. A short burst of acceleration or a sudden change in angular velocity may reveal an aggressive maneuver.&lt;/p&gt;

&lt;p&gt;Our hybrid architecture combines both capabilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Conv1D&lt;/strong&gt; extracts local patterns from sensor sequences;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LSTM layers&lt;/strong&gt; learn longer-term temporal relationships;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dropout and batch normalization&lt;/strong&gt; improve stability and reduce overfitting;&lt;/li&gt;
&lt;li&gt;A final &lt;strong&gt;sigmoid layer&lt;/strong&gt; performs binary classification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The architecture contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Conv1D (64 filters, kernel size 1, ReLU)
→ Batch Normalization
→ Dropout (0.5)
→ LSTM (256 units, return sequences)
→ Dropout (0.2)
→ LSTM (128 units)
→ Dropout (0.2)
→ Dense (1 unit, sigmoid)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model was compiled with the Adam optimizer and binary cross-entropy loss. Training ran for up to 30 epochs with a batch size of 256, supported by early stopping and model checkpointing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing three sequence models
&lt;/h2&gt;

&lt;p&gt;We evaluated the proposed ConvLSTM against two alternatives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stacked LSTM&lt;/strong&gt;, which learns hierarchical temporal representations;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bidirectional LSTM&lt;/strong&gt;, which processes sequences in both forward and backward directions;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ConvLSTM&lt;/strong&gt;, our Conv1D–LSTM hybrid for local feature extraction and temporal learning.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The results were consistently strong across all three architectures:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;F1 score&lt;/th&gt;
&lt;th&gt;Hamming loss&lt;/th&gt;
&lt;th&gt;Jaccard score&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Proposed ConvLSTM&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;99.75%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;99.75%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.25%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;99.50%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stacked LSTM&lt;/td&gt;
&lt;td&gt;99.69%&lt;/td&gt;
&lt;td&gt;99.69%&lt;/td&gt;
&lt;td&gt;0.31%&lt;/td&gt;
&lt;td&gt;99.39%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bidirectional LSTM&lt;/td&gt;
&lt;td&gt;99.62%&lt;/td&gt;
&lt;td&gt;99.62%&lt;/td&gt;
&lt;td&gt;0.38%&lt;/td&gt;
&lt;td&gt;99.24%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The numerical differences are small, but the ConvLSTM led across every reported metric. Its combination of convolutional feature extraction and temporal modeling proved especially effective for these sensor sequences.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Preprocessing is part of the model
&lt;/h3&gt;

&lt;p&gt;It is tempting to focus on architecture selection and hyperparameter tuning. In this project, however, the quality and structure of the input data were fundamental.&lt;/p&gt;

&lt;p&gt;Normalization, directional feature separation, labeling, and maneuver extraction gave the network a much clearer problem to solve.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Smartphones can enable accessible transport intelligence
&lt;/h3&gt;

&lt;p&gt;A phone-based solution does not depend on a particular vehicle manufacturer or proprietary onboard interface. This makes the approach portable across different vehicles and potentially easier to deploy at scale.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Hybrid models are well suited to sensor time series
&lt;/h3&gt;

&lt;p&gt;Conv1D and LSTM layers solve complementary problems. The convolutional layer identifies relevant local patterns, while the recurrent layers preserve temporal context.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. High test performance is not the end of the research
&lt;/h3&gt;

&lt;p&gt;The current model performs binary classification: normal or aggressive. Real-world systems must also handle different phone positions, devices, drivers, roads, weather conditions, and traffic environments.&lt;/p&gt;

&lt;p&gt;Strong experimental results are a promising foundation, but deployment requires broader datasets, real-time validation, scalability testing, and better interpretability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this work can go next
&lt;/h2&gt;

&lt;p&gt;Our next steps include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identifying the specific aggressive maneuver rather than only producing a binary label;&lt;/li&gt;
&lt;li&gt;Expanding the dataset across more drivers, vehicles, devices, and environments;&lt;/li&gt;
&lt;li&gt;Optimizing inference for real-time mobile use;&lt;/li&gt;
&lt;li&gt;Improving explainability so predictions can be connected to recognizable driving events;&lt;/li&gt;
&lt;li&gt;Exploring integration with connected-vehicle and intelligent traffic-management systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of returning only “aggressive driving detected,” a future system could explain that it identified &lt;strong&gt;hard braking&lt;/strong&gt;, &lt;strong&gt;rapid acceleration&lt;/strong&gt;, or an &lt;strong&gt;abrupt turn&lt;/strong&gt;, together with when and where the event occurred.&lt;/p&gt;

&lt;p&gt;That would make the output far more useful for drivers, fleet operators, safety systems, and researchers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;This study began with a practical question: can everyday mobile sensors provide enough information to classify driving behavior reliably?&lt;/p&gt;

&lt;p&gt;Our results suggest that they can.&lt;/p&gt;

&lt;p&gt;By combining careful preprocessing with a Conv1D–LSTM architecture, we achieved &lt;strong&gt;99.75% accuracy&lt;/strong&gt; in distinguishing normal from aggressive driving. More importantly, the work shows how accessible hardware and well-designed machine-learning pipelines can contribute to safer and more intelligent mobility.&lt;/p&gt;

&lt;p&gt;The full open-access paper is available here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://doi.org/10.3390/futuretransp5020052" rel="noopener noreferrer"&gt;Driving Behavior Classification Using a ConvLSTM&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you work with time-series data, mobile sensors, intelligent transport systems, or sequence models, I would be interested to hear how you approach preprocessing and real-world validation.&lt;/p&gt;

&lt;p&gt;What do you think is the greatest obstacle to deploying this kind of model outside a controlled study?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
    </item>
  </channel>
</rss>
