Speak Parseltongue?

Hello there!!

Merry Christmas, folks!!

Have you ever wondered how you could create beautiful graphs, analyse them, find correlations, and smooth the data? The answer to your problems is a certain species of snake, and you probably need to learn a bit of parseltongue. I am talking about Python and how learning it will save you time analysing data and make your life a bit easier.

Some outputs using a python script ( libraries used: Matplotlib and Pandas)

To be honest, I am a really inefficient programmer. I write code without optimising it; my goal is often to get the output rather than think about the optimisation( Which i am improving on) . I know that some of us are apprehensive about using Python and ditching Excel all together because we are not confident with our programming skills, but everything changed back in late 2022.

Meet ChatGPT: One area where this LLM ( Large Language Model) shines is being an AI-copilot in helping you code as well as refactoring your inefficient code. We are living in a time where the typical gatekeeping of the programming community is no longer present. With GPTs, we are able to code with a limited understanding of a programming language as long as you understand the problem and how you want to solve or approach it. Learning the syntax is no longer necessary, but desirable, and I am sure that in due course, after starting to use these tools, you will get a hold of the syntax and will be fairly confident in writing your own code without any crutches.

I understood the power of Python during my internship at DBI. I was spending time analysing data in Excel and creating templates, which could have been completed in mere minutes using the help of Python and the Pandas library

Image generated using DALL-E , Python and her libraries for data analysis

Libraries: what are they?

“Libraries are collections of pre-written code that users can include in their programmes to add functionality without having to write it from scratch. These libraries consist of modules and packages that provide methods, classes, and functions for various tasks, making Python programming more efficient and streamlined

Imagine you want to build a LEGO castle. You could create every single piece of LEGO yourself (tedious and expensive), but what if you had boxes of LEGO pieces that were already made for different parts of the castle, like walls, towers, and gates? You just pick the pieces you need and put them together to make your castle. Libraries are essentially like pre-made LEGO pieces; you use them for specific tasks like plotting graphs, finding correlations, and analysing data.

Some must-have libraries are:

  • NumPy – https://numpy.org/ (A fundamental package for numerical computing in Python. It provides support for large, multi-dimensional arrays and matrices, along with a vast collection of high-level mathematical functions to operate on these arrays. Widely used in scientific computing, it is essential for performing complex mathematical operations and statistical analysis )
  • SciPyhttps://scipy.org/ (Built on NumPy, SciPy is a library used for scientific and technical computing. It extends NumPy’s capabilities by adding useful features like modules for optimization, linear algebra, integration, interpolation, special functions, FFT, signal and image processing, ODE solvers, and other tasks relevant in science and engineering.
  • Pandashttps://pandas.pydata.org/ (A powerful data manipulation and analysis tool, offering data structures like DataFrame and Series for handling and analyzing structured data. It excels in tasks such as data cleaning, transformation, and aggregation, making it indispensable in data science workflows. )
  • Matplotlib https://matplotlib.org/ ( A plotting library for creating static, interactive, and animated visualizations in Python. It’s the go-to tool for plotting graphs and charts, essential for data visualization and the graphical representation of data)
  • Seabornhttps://seaborn.pydata.org/ (A library that works on top of Matplotlib. Seaborn is particularly known for making beautiful and informative statistical graphics in Python. It provides a high-level interface for drawing attractive and informative statistical plots. Seaborn simplifies the process of creating complex visualizations like heat maps, time series, and violin plots.)
  • scikit-learnhttps://scikit-learn.org/stable/ ( libraries for machine learning in Python. It provides a range of supervised and unsupervised learning algorithms via a consistent interface. These include regression, classification, clustering, model selection, preprocessing, and dimensionality reduction. The library is built upon NumPy, SciPy, and Matplotlib)

This may seem overwhelming, but trust me,once past the initial apprehension, it is very simple and intuitive to use. I would suggest following sources to get started with:

Regarding IDE (integrated development environment ) , My favourites are Spyder and Jupyter- There are hundereds of IDEs out there , this is more like a personal choice.

Some examples

Baby steps

This is a small script to plot graphs (using Spyder IDE) , I just need to specify the column names and read the CSV output from the FDS simulation, There is an even better and more efficient way to plot using iLOC and a for loop but for the sake of interpretability, I am uploading this code

The output looks like:

Some fun with graphs

The following image below is a piece of code written on Spyder IDE to animate a graph, and since its written in Python, the readability and interpretability are pretty high. Someone with a basic understanding of programming will be able to understand the code, and if you are clueless, just paste the code in ChatGPT and ask her to explain it to you. Here, iLOC and a for loop are used to read the data, plot it, and animate itβ€”all with 38 lines of code.

Output :

Some advanced use cases (some boring stuff):

A.I. in Fire

Some fun playing around this project https://www.hackster.io/stefanblattmann/real-time-smoke-detection-with-ai-based-sensor-fusion-1086e6

The collection of training data is performed with the help of IOT devices since the goal is to develop an AI-based smoke detector device. Many different environments and fire sources have to be sampled to ensure a good dataset for training. A short list of different scenarios which are captured:

  • Normal indoor
  • Normal outdoor
  • Indoor wood fire, firefighter training area
  • Indoor gas fire, firefighter training area
  • Outdoor wood, coal, and gas grill
  • Outdoor high humidity
  • etc.

The dataset is nearly 60,000 rows long. The sample rate is 1 Hz for all sensors. To keep track of the data, a UTC timestamp is added to every sensor reading. we basically analyse what attributes contribute to a fire alarm There are 13 key attributes that trigger an alarm so we first try to understand how each parameter correlates with each other, how sensitive each are, and how they affect the state of the detector

Good luck using Excel to do this work!

The heatmap below shows correlations between the attributes.

Some Classification Algorithms applied on the database

Everyone loves Artificial Neural Networks (training an ANN on this dataset)

Output :

Analysing the result

  • The left column (with labels “0” and “1” in the rows) shows the actual true labels from the data. Here, “0” means that there was no fire alarm, and “1” means that there was a fire alarm.
  • The top row (with labels “0” and “1” in the columns) shows the predicted labels by the model. Again, “0” stands for no fire alarm predicted, and “1” stands for a fire alarm predicted.
  • The cell with “4325” represents the number of times the model correctly predicted that there was no fire alarm (true negative).
  • The cell with “11142” represents the number of times the model correctly predicted that there was a fire alarm (true positive).
  • The cell with “63” shows the number of times the model incorrectly predicted that there was no fire alarm when there was one (false negative).
  • The cell with “128” shows the number of times the model incorrectly predicted that there was a fire alarm when there wasn’t one (false positive).

Conclusion

I know I have not given a step-by-step guide on how to set everything up; this was not the intention, but my idea was to introduce the vast amount of resources out there just waiting to be used. I had a vague idea of these before IMFSE but never actually used them because:

“You never actually use these until and unless you need to use them”β€”wise words from a fellow IMFSE student, but you don’t have to approach it likewise, because once you start to play with these tools, you will understand that it’s easy to write a couple of lines of code and produce amazing graphs and enable yourself to perform cleaner analysis with these libraries. First-year IMFSE students who start their second semester at Lund would find these particularly interesting because we have weekly FDS assignments, and it would be ideal to start practicing and applying this. It may be a bit tedious to write the initial code but after that, you will realise that you need to put incrementally minimal effort and tweak your code bare minimum for every subsequent use.

Addressing the Elephant in the room – ChatGPT and other LLMs

This is something that I want to stress and is a bit worrysome , Do not use ChatGPT to complete your assignments/write exams (people have tried that and have got caught ) there is a limit to how you can effectively use these tools to aid your workflow. These LLMs have their strenghts and weakness and understanding it is paramount in effectively using them. They will never replace (atleast now) the critical thinking process that we put in drawing conclusions to a problem that we solve. The usage of ChatGPT that I mentioned here is merely for aiding you to code and refactor it and due diligance must be practised for further usage in the academia, for more details you can read the following articles

Also you can read this neat post by Professor Wojciech WΔ™grzyΕ„ski ( this neatly sums up what I intent to say ) https://www.linkedin.com/feed/update/urn:li:activity:7044612939760189440/

I am not an expert programmer , I just know where to look for resources and get the work done, but feel free to get in touch with me ( https://www.linkedin.com/in/anisjayaram/ ) or drop a comment if you are particularly interested in anything mentioned in the blog so that I could potentially write a detailed post to address them.

Special credits to my group mates Matheus Pontes Lima (https://www.linkedin.com/in/mp97/) and Vanessa Valdeabella (https://www.linkedin.com/in/vanessavaldeabella/) – the graphs and figures are from some of our work here at UPC.

Regards,

Obi-Wan-Kenobi

Fires, Dreams, and Learning: My IMFSE Journey

Have you ever found yourself wondering, “How did I get here? What led me to this moment?” I’ve had several of these introspective moments, especially when I embarked on my master’s degree journey in IMFSE. It all began when a girl from a small country like Bangladesh left her home to chase her dreams. I vividly remember every step of that journey, as it marked my first time traveling abroad and taking on the responsibility of managing everything on my own. IMFSE, for me, isn’t just a master’s program; it’s a life-changing experience filled with struggles, lessons, and growth.

I hail from a country where using emergency doors during emergencies can be challenging, fire hydrants sometimes lack water connections, and many people are unsure about what to do in a fire emergency. Transitioning from this context to a dedicated fire safety-related master’s program was a significant challenge. My background was in Building Engineering and Construction Management, where I learned about building construction but had little exposure to building safety during fire emergencies.

Before leaving my homeland, I was filled with excitement. I couldn’t help but daydream about the beauty of Scotland and the prestigious University of Edinburgh. However, reality hit me hard in the first week of IMFSE classes. Understanding what the professors were saying was a struggle and my two-week delay due to a visa issue added to the difficulties. At times, I questioned if I had made the right decision, wondering if this program was truly suited for me. It was during these uncertain times that my friend Amina offered me a reassuring reminder, “You are here just because you deserve to be here.” Her simple yet profound support acted as a powerful tonic. I persevered and soon came to the realization that choosing this path was indeed the best decision of my life.

The initial weeks were challenging as I found myself studying alongside peers who already possessed extensive knowledge of fire safety engineering. Some had their own companies, and others had substantial work experience. I compared myself to them and worried that I might not measure up. However, I reminded myself that I came here to learn, and my knowledge would grow significantly over some time. Now, just a year later, I can confidently say that I know far more than I did before. One thing that became clear is that this program is suitable for individuals from various backgrounds. We had students from electrical, mechanical, chemical, safety, civil engineering, and architecture backgrounds. Some were fresh graduates, while others had years of experience. When we started, we all had specific strengths and weaknesses, but now, we stand on equal ground, having gained a wealth of knowledge from this program.

Over the past year, I’ve undergone a profound transformation. The two semesters I spent at the University of Edinburgh and Lund University, guided by some inspiring professors, have been nothing short of amazing. This opportunity, I must say, has allowed me to delve into self-discovery. Today, I find myself a more confident, enthusiastic, and independent individual than I was just one year ago. During the summer break, when I had the chance to return to my home country, I made a sensible decision to explore the field of fire safety and gain professional experience through an internship at FRISSBE. This journey was both enjoyable and enlightening, and I look forward to sharing more about my summer adventures soon.

IMFSE has been instrumental in helping me understand the critical importance of fire engineering. Prior to this program, fire was merely a physical phenomenon extinguished with water. Now, I comprehend that a small candle flame can escalate into a massive fire. Whenever I see a building, I instinctively consider its evacuation plan and ponder how people behave in a fire. These were not common thoughts for me before, but now I recognize their significance.

In essence, this exceptional program is accessible to all backgrounds, and it unravels the mysteries of fire engineering visually. The curriculum, combining theory and practical components, is designed in such a way that every student can relate it to their background. It doesn’t change your background; instead, it enriches your career. A year into the program, I noticed a significant shift in my perspective. I began to approach building construction with a heightened focus on fire safety and its intricacies.

I am deeply grateful to everyone who supported me on this journey.

Thank You 😊

Every year, this program produces remarkable fire engineers while also welcoming a new batch of hopeful students. If you're reading this and feel that you could be the next person to benefit from this fantastic program and add value to your engineering career, consider applying for the IMFSE 2024 cohort. πŸ”₯ Applications for the IMFSE 2024 cohort are now open! πŸ”₯ CLICK HERE TO KNOW MORE πŸ”₯