Nature seems to follow a recurring rule: the most extraordinary things are never centralized.
A brain is not one gigantic neuron. A flock is not a single bird leading the others. A swarm, an ecosystem, an ant colony: they all emerge from the cooperation of many simple entities.
Computer science, in many ways, has followed the same path.
For years we built software as massive monoliths. Then microservices arrived, teaching us that distributing responsibilities often makes systems more flexible, resilient, and ultimately more intelligent.
Perhaps that is why the agentic paradigm fascinates me so much.
I have always loved distributed systems. Back at university, I designed an architecture for highly parallel and distributed genetic algorithms (aimed at optimizing and training neural networks), where independent populations evolved on virtual “islands” and “archipelagos,” periodically exchanging individuals to accelerate the search for better solutions.
Even then, I was captivated by a simple idea:
Many limited entities, cooperating together, can produce a form of collective intelligence that is far greater than the sum of its parts.
Today, artificial intelligence is undergoing the same transformation.
After the era of monolithic generative models, we are witnessing the rise of agentic architectures: teams of specialized agents collaborating toward a common goal. One gathers information, another validates it, another organizes it, and another assembles the final result.
Not a single mind. A small society of minds.
To explore this paradigm, I built a personal experiment using CrewAI: a crew of cooperative agents capable of generating financial reports starting from nothing more than an ISIN (International Securities Identification Number) and Ticker.
The project is still very much a work in progress. My next step is to extend it with a daily watchlist report, where a team of specialized agents will continuously monitor the stocks and ETFs I follow, collecting market data, news, trends, and insights to produce a personalized daily briefing.
The project began as an exercise inspired by Ed Donner‘s excellent Udemy course, AI Engineer Agentic Track: The Complete Agent & MCP Course, but it quickly became something more: a way to revisit, with today’s AI technologies, those same ideas of distribution and cooperation that have fascinated me since my university days.
Perhaps it was inevitable.
The evolution of computer science seems to follow the same direction over and over again:
from the monolith to cooperation.
Once you cross the threshold into the world of agentic architectures, there is no turning back. My mind is already overflowing with ideas to explore.
The story of Reversi42 began many years ago, in an age when the word “smart working” didn’t even exist. Every morning, far more carefree than I am today, I would take the subway to work with a tiny 10-inch netbook. In that cramped space, I started developing the first version of my Reversi42 engine – supported by a colleague who was an expert Othello player.
A time travel from Vim to Coursor
I wanted to see how far I could go with minimal hardware and a few weeks of focus. I coded offline, using my first version of Python and my beloved Vim, inside a GNU/Linux terminal where every pixel truly mattered.
Years later, I reopened that old GitHub repository because I wanted to transform a legacy project into a modern testbed. I wanted to see what would happen when a prehistoric project, written in 2011 on a subway using Vim and a netbook, met the tools of 2025.
And I asked myself: how much can I build today in just a few days – backed by years of experience and the best AIs around?
Spoiler: much more than I could ever have imagined and my expectations were already high.
That’s how I opened a temporal rift, short-circuiting past and present – between the magical Vim formulas that once carried me to nirvana and the modern oracle of Cursor.
Disassemble. Rebuild. Amplify.
The new Reversi42 distills everything I’ve learned over the years:
SOLID design principles
Clear responsibilities, modular architecture
Heavy use of design patterns
A more rational, readable, testable engine
Iterative deepening and refined alpha-beta pruning
Clean heuristics and early transposition table optimizations
Modern responsive UI with WebSockets
A CI/CD pipeline
It felt like having a conversation with a younger version of myself – same passion, entirely new tools.
New Reversi WebSocket UI
How Cursor Changed the Game
Cursor empowered me to:
Perform deep structural refactoring
Anticipate and analyze edge cases in move logic
Compress the think-code-verify cycle
Clarify architectures, patterns, and responsibilities
It didn’t write the code for me but it amplified my thinking, accelerating productivity to vertiginous levels. I spent nights coding without realizing time was passing.
Working with Cursor introduced me to a new programming paradigm. Yet such power demands discipline, with experience, you learn how to guide it instead of being guided by it.
New Apocalyptron AI Engine
The New Reversi42
Modern Web UI – Browser-based interface with real-time WebSocket updates
Ultra-Fast Bitboard Engine – 50-100× faster than standard implementations
AI Gladiators – Distinct opponents from beginner to champion, each with unique play styles and Midjourney-generated avatars
No-Code AI Creation – Configure AI players via YAML (zero programming!)
New AI Engine “Apocalyptron” – Super-modular and high-performance
Opening Book System – Professional opening sequences
Tournament Mode – Run AI competitions and benchmarks
So long, and thanks for all the fish. The end of one cycle, the beginning of another. For now, Reversi42 returns to rest – maybe just for a while. Next time, it might awaken to play on a quantum computer, finding the perfect move beyond human reach.
Imagine sitting on your canary-yellow couch, sipping an ice-cold Duff with Homer, as Bart throws out a few quips and Lisa tries to correct you on every topic. Now, picture this: your one and only mission is to build a convolutional neural network (CNN) that can accurately recognize each member of the Simpsons cartoon. Because, with all that yellow around, even the best deep learning models might slip up!
The mission is clear: identify Homer, Bart, Marge, and the entire cast of Springfield with high precision and robust performance, as the images are dynamic, and the characters aren’t in obvious poses or positions.
Let’s kick things off with a spoiler: the ConvNet we built achieved extraordinary results on every front.
The outstanding accuracy achieved in recognizing characters on any new image (not used during training) is: 93.65%
How did I achieve this? I built my best CNN, trained using transfer learning and enhanced with data augmentation to improve robustness and generalization. This challenge was a magical doorway, plunging me once again into the fascinating world of deep learning—a parallel dimension where every pixel offers a new opportunity to experiment with and dive into cutting-edge techniques. And so, once again, after long workdays, I found myself on the metro, in the car, or even in some magical corner, studying and coding.
The dataset I ventured into is the famous “The Simpsons Characters Data” (by Alexandre Attia) available on Kaggle: 16,670 images covering a whopping 43 different characters from Springfield. After acquiring it, I stumbled upon the first challenge—worthy of a Simpsons-style slip on a banana peel: the dataset is highly imbalanced. Main characters have thousands of images (Homer, Bart, Lisa), while others have only a few (poor Lionel Hutz and Disco Stu!).
To balance the dataset, I had to set a threshold: only characters with at least 200 images were included in the training. This allowed me to focus on well-represented characters. With this selection of Springfield’s finest, the CNN had a solid foundation to start accurately recognizing the most iconic characters.
Transfer learning is a technique where you take a pre-trained model (such as one trained on ImageNet) and “transfer” its knowledge to solve a specific new task, like recognizing the Simpsons characters. This approach allows you to leverage the initial layers, already ‘skilled’ at recognizing general patterns (shapes, colors, textures), so you can focus on fine-tuning only the final layers to distinguish the unique details of each character. Generally, for this type of problem, it’s an excellent solution.
CNN model structure
Identifying the overall structure is an art akin to magic. For this project, I sought a blend of flexibility and robustness: data augmentation enhances generalization, the base model leverages the power of transfer learning, and GlobalAveragePooling2D reduces parameters while retaining essential information. The dense layer with 512 neurons captures the main features, while Dropout prevents overfitting and boosts robustness, making the model less reliant on individual neurons and more capable of generalizing to new data. The softmax output enables accurate classification among the various characters.
Choosing ConvNet50 as the pre-trained base model felt like selecting the best superhero to tackle the battle for Simpsons recognition! Also known as ResNet50, this network is built on a 50-layer deep structure designed to scrutinize every pixel with microscopic precision. ConvNet50 is pre-trained on ImageNet, a dataset that has processed millions of images and learned to recognize even the smallest details. This means that, even if it’s never seen Homer, Bart, or any Simpsons episode, it already knows how to identify shapes, colors, and textures to near perfection.
Why ConvNet50? First, this network’s design incorporates an architecture based on residual blocks. These blocks help maintain the information flow even in a deep network like this one, ensuring high accuracy and reducing the risk of vanishing gradients. It’s like giving the network the best GPS possible, so it always knows where it’s heading, no matter how long the journey. In our case, this means a network that stays on track, avoiding drift into errors and maintaining focus even on the finest details.
Another base model alternatives I explored:
InceptionV3: Another deep learning powerhouse, known for its ability to handle multiple scales within images. InceptionV3 could have offered greater flexibility in recognizing details like Marge’s big blue hair or Bart’s rebellious spikes, as it explores different dimensions of the same image. Often oversized, InceptionV3 is ideal for scenarios with highly intricate details that require multi-scale detection.
VGG16 or VGG19: Widely used and simpler in structure compared to ConvNet50, yet deep and precise. These networks perform excellently in many computer vision applications, though they tend to be less efficient in terms of resources.
MobileNet: Ideal if my goal were to deploy the model on mobile or low-resource devices. MobileNet is fast and lightweight—an extreme nerd choice if I wanted my CNN to run on an embedded system. But for the Simpsons, opting for a more powerful model made sense!
Ultimately, ConvNet50 offers the perfect balance: it’s deep enough to capture the complexities of Springfield’s characters, well-trained to capture even the smallest details, and optimized to provide fast and efficient results without overloading the system.
To achieve excellent results, I incorporated data augmentation, an essential technique for improving model performance, especially when the dataset is imbalanced or limited in the number of images. In our case, data augmentation allows us to virtually increase the size of the dataset by creating variations of existing images (through rotation, zoom, contrast, and horizontal reflection).
A self-portrait of myself analyzing the outstanding results achieved
After transfer learning, where we unlock and retrain only the final layers of the pre-trained model, I applied fine-tuning, unlocking and retraining only the last layers of the model. This approach allows the model to specialize in the details of the Simpsons characters, retaining general knowledge while adapting to the specific nuances of the new dataset.
Validation e Training Dataset – Loss and Accuracy during Transfer TrainingValidation e Training Dataset – Loss and Accuracy during Fine Tuning TrainingSimpson Characters Recognition – Confusion Matrix
We present the simulation on images from the dataset not used in training, showcasing the actual character, the recognized character, and the network’s confidence level. These are images the network has never seen before, yet it identifies them with a high degree of certainty. Click on the images to view them in detail.
This project is highly reusable for numerous similar applications. Depending on the project’s requirements, one could adjust the model’s structure or choose a different base model.
“In the wise words of Homer Simpson, ‘Mmm… data!’ With this model, even Springfield would be proud of our machine learning journey!”
The charts and model performance metrics are based on a single execution of the notebook. With each run, these values may vary slightly, yet they consistently remain optimal and align closely with the results shown.
If this topic has sparked your interest and you’d like to delve deeper, I suggest these references:
In this imaginative journey to the frontier of AI, we’ll project ourselves into the year 2912, where we will challenge the Data Analysis module of ChatGPT v4 to solve a space-time anomaly.
To break the ice, I asked ChatGPT to briefly describe, based on its knowledge, how it imagines humanity in the year 2912, especially in relation to intergalactic travel.
“By the year 2912, I envision humanity as a highly advanced civilization, spread across multiple planets and star systems. Thanks to discoveries in physics and bioengineering, humans are able to adapt to different space environments and have developed intergalactic travel technology that allows crossing vast cosmic distances in a short time. Spacecrafts are elegant and sophisticated, equipped with AI systems to assist and protect travelers. Human cultures are diverse, influenced by various space colonies, yet united by a common quest for exploration and knowledge.”
I share ChatGPT’s optimism, which doesn’t describe a dystopian future or conflicts, but collaboration among civilizations; probably a reflection of its algorithms’ optimism bias.
Now, let’s describe our intergalactic problem presented on Kaggle:
The interstellar spaceship Titanic, on its maiden voyage, is transporting about 13,000 emigrants from our solar system to three newly habitable exoplanets. Passengers come from Earth, Mars, and Europa, some in cryogenic sleep. The ship offers various services, including VIP treatments, a SPA, a shopping center, and a high-tech Virtual Reality deck. All onboard activities are tracked by a next-generation computer system.
Near Alpha Centauri, en route to the torrid 55 Cancri E, the ship encounters a space-time anomaly hidden by a dust cloud. After 1,000 years, it seems the tragedy of the previous Titanic is repeating in space.
After the impact, although the ship remains miraculously intact, nearlyhalf the passengers are teleported to an alternate dimension!
To aid rescue teams and recover the missing passengers, we must predict which passengers have been teleported using data from the damaged computer system.
Here’s where we come in with the assistance of ChatGPT v4 and its Data Analytics module.
We face a synthetic problem, created in the lab, which I consider extremely valid and complete to delve into various themes related to data analysis and machine learning algorithms.
To effectively solve these types of problems typically requires complex theoretical and programming knowledge. ChatGPT assists the operator by guiding through all stages of the process.
Here are the details of the Spaceship Titanic problem:
We start with a training file containing data on two-thirds of the passengers and information on whether they have been teleported, and a test file with the same data but no information on the remaining passengers’ teleportation status.
The challenge is to predict, as accurately as possible, whether the passengers in the test file will be teleported.
A unique ID for each passenger, in the format gggg_pp where gggg indicates a group the passenger belongs to and pp is the passenger number within the group.
HomePlanet
The planet the passenger departed from, usually their permanent residence planet.
CryoSleep
Indicates whether the passenger chose to be put in suspended animation for the journey. Cryosleep passengers are confined to their cabins.
Cabin
The cabin number where the passenger is located. Presented in the format deck/number/side, where the side can be P for Port (left) or S for Starboard (right).
Destination
The planet where the passenger disembarks.
Age
The passenger’s age.
VIP
Indicates whether the passenger paid for a special VIP service during the trip.
RoomService
Amount the passenger charged to room service. NameThe names and surnames of the passenger.TransportedIndicates whether the passenger has been transported to another dimension. This is the target variable, the column we are trying to predict.
FoodCourt
Amount the passenger charged to the food court.
ShoppingMall
Amount the passenger charged to the shopping center.
Spa
Amount the passenger charged to the spa.
VRDeck
VRDeckAmount the passenger charged to the virtual reality deck.
Name
The name and surname of the passenger.
Transported
Indicates whether the passenger has been transported to another dimension. This is the target variable, the column we are trying to predict.
known passenger data
I attempted to solve the problem using ChatGPT v. 4.0 utilizing its Data Analysis module.
After presenting the training file, ChatGPT reprocessed it in the best way and also proposed the best strategies for managing missing data.
Spoiler Alert if you want to tackle this problem without any information.
I asked ChatGPT to explain how these variables might influence the Target Transported variable, and here’s the response:
CHATGPT RESPONSE — SPOILER ALERT —
Predicting whether a passenger has been teleported or not is based on analyzing various factors (or variables) in the dataset. Here’s a brief summary of how some of these variables might influence the probability of being teleported:
HomePlanet (Planet of Origin): The probability of being teleported may vary depending on the passenger’s planet of origin. There could be specific trends or policies associated with each planet influencing this probability.
CryoSleep (Cryogenic Sleep): Passengers in cryogenic sleep may have a higher probability of being teleported, perhaps due to specific procedures or protocols related to their state.
Cabin (Cabin): The type or location of the cabin might correlate with the probability of being teleported, perhaps due to proximity to specific teleportation devices or areas of the spacecraft.
Destination (Destination): The final destination might influence the probability of being teleported, perhaps due to different procedures for different places or travel distances.
Age (Age) and VIP: Though with a weaker correlation, age and VIP status may play a role, potentially due to policies or preferential treatments for certain age groups or VIPs.
Expenses (RoomService, FoodCourt, etc.): Expenditures in various categories (like RoomService, FoodCourt, etc.) show a correlation, suggesting that a passenger’s spending behavior might be linked to their probability of being teleported.
It’s important to note that these are correlations observed in the data and do not necessarily imply a direct cause-effect relationship. Teleportation decisions might be influenced by a complex interplay of these factors and others not captured in the dataset.
END OF CHATGPT RESPONSE — END OF SPOILER ALERT —
The analysis phase was truly impressive, considering it was completely automated.
During the model construction phase, ChatGPT guided us through various stages. Errors occurred several times, which were analyzed and recovered more or less effectively. A major limitation is that more complex computations are also interrupted due to timeout.
ChatGPT suggested using the Random Forest algorithm for the model.
I asked for the rationale behind this choice.
CHATGPT RESPONSE
I chose the Random Forest model to predict the teleportation status for various reasons, making it particularly suitable for this type of problem:
Handling Categorical and Continuous Variables: Random Forest effectively manages both categorical and continuous variables. In the provided dataset, we have both types of variables, making Random Forest an appropriate choice.
Robustness to Noisy Data and Outliers: Random Forest is known for its robustness to noisy data and outliers, which can be present in real datasets like this.
Lower Risk of Overfitting: Thanks to its ensemble algorithm nature, combining the results of many decision trees, Random Forest tends to have a lower risk of overfitting compared to single decision trees.
Variable Importance: Random Forest provides useful insights into variable importance, which can help understand which factors most significantly influence the prediction. This is useful for interpreting the model’s results in relation to the business problem.
Good Overall Performance: Generally, Random Forest is known for its good performance across a wide range of classification problems, making it a reliable starting point for many machine learning applications.
Flexibility and Scalability: It’s a flexible model that can be easily adapted to improve performance (e.g., adjusting the number of trees) and scales well with large datasets.
In summary, I chose Random Forest for its robustness, reliability, and ability to provide high-quality results on a complex dataset like the one provided.
END OF CHATGPT RESPONSE
The result achieved was an accuracy of 0.79822, which I find astonishing given that it was conducted in a fully guided mode; we also placed reasonably well on the leaderboard for this problem.
These are the parameters obtained on the validation set.
PARAMETER
Value
Accuracy
0.7901
Precision (False)
0.8000
Precision (True)
0.7800
Recall (False)
0.7700
Recall (True)
0.8100
F1-Score (False)
0.7800
F1-Score (True)
0.8000
validation set parameters
All the Python code created can be viewed, which is extremely useful for beginners.
ChatGPT V4 Data Analysis proved to be an incredible assistant, albeit a bit unstable as there were errors that forced me to start over.
All images were created by DALL·E 2 through ChatGPT v4.
Uno dei post che ha generato il maggior interesse in questo blog è certamente quello dedicato alla face detection tramite OpenCV. Riprendiamo questo tema dopo molto tempo parlando degli algoritmi alla frontiera per il Face Detection e Face Recognition. Lo scopo del post è fare il punto sullo stato dell’arte ed indirizzare verso mouduli open source liberamente e facilmente utilizzabili nelle applicazioni reali.
Matrix Reloaded – The Architect
La Face Detection è l’elaborazione che ha lo scopo di rilevare la presenza di volti umani all’interno di un’immagine digitale; nel precedente articolo è stata affrontata solo questa tematica attraverso algoritmi tradizionali ma consolidati.
Gli algoritmi di Face Detection si sono evoluti nel tempo migliorando l’accuratezza della rilevazione anche attraverso l’uso di reti neurali convoluzionarie (CNN)o reti Deep Learning opportunamente strutturate ed addestrate; tale processamento sfrutta massivamente l’eventuale presenza di moderne GPU o NPU per aumentarne l’efficienza ed il parallelismo. Nel nostro caso specifico ci siamo limitati al riconoscimento di volti umani in posizione frontale.
Matrix Reloaded Architect – Face Detection Benchmark MTCNN
Il benchmark estremo che ho utilizzato per mettere alla prova i moduli python individuati, è un breve video tratto dal dialogo tra Neo e l’Architetto in Matrix Reloaded; nel video, in un’atmosfera surreale, sono presenti innumerevoli volti che variano rapidamente per dimensione, inclinazione, espressione, presenza o meno di occhiali. Un video estremo di prova che farà friggere neuroni e sinapsi anche alle più evolute e performanti reti neurali convoluzionarie.
Questo è il video che è stato prodotto attraverso la nostra elaborazione:
Il Benchmark che ho utilizzato per la Face Detection in Python – L’architetto in Matrix Reloaded – questo è il risultato ottenuto tramite l’uso del modulo MTCNN insieme ad OpenCV che ho usato per l’elaborazione del video
Il modulo Python che, almeno nei miei esperimenti, ha dimostrato i migliori risultati in termini di qualità e prestazioni è MTCNN; in esecuzione su una sessione Colab con GPU attiva elabora efficientemente il flusso di frame con un livello di accuratezza molto alto se si escludono i volti in posizione non frontale. Nel video prodotto si trova l’esito dell’elaborazione dove, oltre ai volti, sono stati marcati anche alcuni punti caratteristici del viso (occhi, naso, estremi della bocca). Questo modulo è quello che riesce a rilevare meglio volti di dimensioni più piccole e non perfettamente allineati garantendo anche un’efficienza molto più alta degli altri moduli provati; MTCNN fornisce, per ogni volto rilevato, anche un livello di confidenza nella rilevazione (in tutto il video ho trovato solo un falso positivo pertanto non ho ritenuto necessario introdurre una soglia).
Il Trono di Spade – foto usata come base per l’apprendimento dei principali personaggi
In alternativa, si propone l’uso del modulo: face_recognition che ha comunque garantito un’ottima precisione su volti di dimensioni significative ed un’efficienza adeguata; su tale modulo è possibile variare l’algoritmo di rilevamento (CNN o HOG) ed effettuare del tuning per cercare di rilevare volti di dimensioni minori. Sul benchmark utilizzato la rilevazione CNN non riusciva ad intercettare gli stessi volti di MTCNN mentre la rilevazione HOG, oltre a non velocizzare molto il processamento, riduceva drasticamente il numero di volti rilevati. In condizioni normali anche questo modulo è da considerare un’ottima scelta e noi lo useremo per effettuare anche il Face Recognition. Questo modulo può richiedere un quantitativo di memoria sulla GPU più elevato soprattutto se si vogliono rilevare i volti con dimensioni più piccole.
Tutti i personaggi sono stati correttamente rilevati
Dopo aver rilevato ed isolato i volti, l’elaborazione della Face Recognition ci permette l’associazione di un volto ad una persona. In assenza di informazioni o di preappendimento sulle persone da ricercare, è possibile aggregare i volti su possibili individui basandosi sulla similitudine delle caratteristiche fisiologiche e biometriche. Gli algoritmi per effettuare tale riconoscimento, per codificare un volto in un insieme di parametri comparabili sono davvero molteplici e tutti estremamente interessanti. Anche in questo caso le reti neurali convoluzionarie (CNN) offrono un contributo importante a questi algoritmi.
Tutti i personaggi sono stati correttamente rilevati ad eccezione di Missandei che non era presente nella foto iniziale
Per implementare un Face Recognition in pochissime righe di codice Python ed in modo efficiente è possibile usare il modulo face_recognition; se si vuole approfondire come questo modulo funziona internamente vi consiglio di leggere questo aricolo.
Tutti gli attori presenti nel file di training sono stati correttamente rilevati anche senza abiti ed acconciature di scena. Come atteso Drogo non viene rilevato perché non presente nel file di training.
In questo caso ho creato un notepad colab di test che da una foto iniziale acquisisce le caratteristiche fisiologiche e biometriche dei vari personaggi della serie Il Trono di Spade; il modulo utilizzato, alla versione attuale, dovrebbe rappresentare ciascun volto tramite 128 parametri caratteristici.
tutti gli attori presenti nella foto di training sono stati rilevati anche Daenarys che appare molto differente rispetto al personaggio interpretato
Per testare il rilevamento ho provato a far riconoscere i personaggi su altre foto contenenti anche personaggi non presenti all’interno della foto di apprendimento; i risultati sono impeccabili. Il modulo utilizzato ha un’accuratezza eccellente sia per quanto riguarda i personaggi appresi che per quelli non analizzati che non ha mai classificato come falsi positivi.
anche in questo caso tutti gli attori presenti nella foto di training sono stati individuati correttamente
Per spingere oltre il test abbiamo avviato la detection su foto in cui gli attori non appaiono con i costumi di scena ed hanno acconciature o il colore dei capelli totalmente differente dai personaggi che hanno interpretato; anche in questo caso l’algoritmo non sbaglia e non rileva mai falsi positivi.
Anche se non ho effettuato delle prove dirette, sono convinto che l’algoritmo scali bene all’aumentare del numero delle persone da rilevare; non ho provato a sottoporre qualche foto degli attori quando erano più giovani.
Concludiamo dicendo che oltre alla Face Detection ed alla Face Recognition ai volti possono essere applicati altri algoritmi per l’estrazione di caratteristiche molto importanti come la rilevazione del sesso, dell’età, del sentimento (es. rabbia, gioia, paura, sorpresa, …).
Fatemi sapere i vostri pareri e le vostre esperienze su Face Detection, Face Recognition nei commenti.
L’RMS Titanic è stato un transatlantico britannico della classe Olympic naufragato nelle prime ore del tragico 15 aprile 1912, durante il suo viaggio inaugurale, a causa della collisione con un iceberg avvenuta nella notte.
La sfida proposta da Kaggle: Titanic – Machine Learning from Disaster alla quale ho aderito, richiede l’analisi di un dataset contenente informazioni relative ad un sottoinsieme di passeggeri imbarcati sul Titanic con lo scopo di realizzare un modello predittivo che sia in grado di classificare al meglio se un determinato passeggero si salverà dal naufragio.
tassi di sopravvivenza per classe
Alcune delle informazioni disponibili per l’analisi, di cui occorre individuare il livello di correlazione con la probabilità di salvezza, sono: sesso, età, cabina, classe, ponte, numero di parenti a bordo, porto di imbarco, tariffa pagata; moltissime altre informazioni possono essere derivate da elaborazioni più o meno complesse ed implicite tra i dati disponibili come ad esempio dai nomi completi è possibile risalire ai titoli, ad alcune professioni o anche spingersi al raggruppamento delle famiglie.
La grande sfida è quella di spingere al massimo l’accuratezza del modello predittivo al fine di classificare al meglio un insieme di passeggeri di test di cui non è nota la sorte; solo dopo la sottomissione a Kaggle si scoprirà il livello di accuratezza raggiunto.
Il modello predittivo di base che occorre superare e contro il quale ci si deve confrontare, che ho definito come modello baseline, assume semplicemente che tutte le donne si salveranno; applicando questa condizione elementare, si raggiunge un’accuratezza dell’insieme di passeggeri da classificare di poco superiore al 76%.
modello baseline: tutte le donne si salvano raggiunge un’accuratezza dello 0.76555
Questa competizione è un’ottima introduzione alla piattaforma Kaggle e richiede lo sviluppo di tutte le fasi di costruzione di un modello predittivo: analisi dei dati, preparazione e raffinamento dei dati, visualizzazione dei dati, costruzione del modello, validazione del modello e della sua accuratezza, comprensione della piattaforma Kaggle.
Nel mio notebook ho deciso di affrontare la sfida in Python costruendo un modello tramite la libreria XGBoost nota sia per essere alla base delle migliori implementazioni all’avanguardia del settore ma anche perché alla base dei modelli vincenti delle competizioni Kaggle. Tale libreria implementa il framework Gradient Boostin modalità estremamente scalabile, efficiente e portabile.
La mia implementazione, già completamente funzionante, è ancora in evoluzione è raggiungibile a questo indirizzo:
Al fine di comprendere meglio l’articolo: “Modeling How Infectious Diseases like Coronavirus Spread“ ed i riferimenti citati, continuando ad approfondire, mi sono ritrovato a costruire il framework: “Infection Spread Simulator Construction Kit”.
Si tratta di un notebook Python su Colab per la modellazione della diffusione di un’infezione attraverso un modello SEIR descritto da un sistema di equazioni differenziali (o un algoritmo); lo stesso modello proposto per l’analisi della diffusione del covid-19 nell’articolo che ha ispirato questo lavoro.
Chiunque, anche senza nessuna base matematica, con una conoscenza basilare di programmazione, può modificare il notebook all’interno della propria sandbox Colab, descrivere un virus o il comportamento di un’infezione ed analizzare la sua diffusione nel tempo per comprendere come la variazione di certi parametri può incidere nella diffusione.
Si tratta di un prototipo, nato per uso strettamente personale, con molti limiti ma voglio comunque condividerlo con la comunità rilasciandolo come software libero sotto la licenza GNU/GPL v.3.
Sarei felice di ricevere i vostri feedback, i vostri modelli, le vostre evoluzioni anche direttamente su github. Nei prossimi giorni, utilizzando questo framework o una sua evoluzione, vorrei provare a realizzare il complesso modello di diffusione del covid-19 descritto nell’articolo.
MALARIA Il primo modello reale (estensione del SEIR) che rilascio è quello della malaria. In questo caso ho dovuto apportare delle modifiche più complesse al modello base.
Some years ago, needing to quickly identify duplicate files within Unix file systems residing on embedded devices or NAS (e.g., Synology, QNAP, D-Link), and dissatisfied with the tools I found online, I developed a command-line Perl tool with the following goals:
Very lightweight and usable even on embedded devices (requires only the Perl 5.7.3 interpreter or higher, with no additional dependencies);
Maximum efficiency on very slow disks or network drives.
Thus, the first version of the free software ffdup was born, which I released under the GNU/GPL v3.0 license on:
E’ da molto che non scrivo in questo blog; semplicemente sono stato impegnato in alcuni progetti che non reputo ancora pubblicabili.
Voglio segnalarvi due interessanti riferimenti nel campo dell’AI, computational intelligence, machine learning; argomenti di cui mi sto occupando in questo periodo.
The Pac-Man Projects
Come base degli esercizi per un corso di intelligenza artificiale, presso l’università di Berkeley, viene proposto agli studenti di sviluppare in python alcuni algoritmi all’interno del famoso gioco del Pac-Man; il corso termina con un multi-player contest.
Trovo questa idea geniale e molto efficace dal punto di vista didattico.
Il materiale può essere liberamente utilizzato come base per corsi di intelligenza artificiale ma si richiede di non pubblicare online le soluzioni dei problemi posti.
Ms Pac-Man vs Ghost Team Competition
Per chi volesse cimentarsi nello sviluppo in java di algoritmi che pilotano Ms Pac-Man o la squadra dei quattro fantasmi è stata organizzata un’avvincente competizione:
Per festeggiare degnamente l’arrivo del mio nuovo portatile in famiglia ho pensato di renderlo in grado di riconoscere volti umani da una sorgente video in tempo reale.
Video dell’applicazione realizzata
Segue il video dimostrativo dell’applicazione realizzata:
OpenCV (Open Source Computer Vision Library)
Era da tempo che desideravo utilizzare la libreria Open CV per tornare a fare qualche esperimento di Computer Vision e per esplorare le sue tanto decantate potenzialità.
OpenCV è una libreria rilasciata sotto licenza BSD dalla Intel per l’elaborazione realtime delle immagini e la Computer Vision.
Scritta in C e C++ è utilizzabile, tramite wrapper (sia ufficiali che non) in diversi linguaggi: Python, Ruby, Java, C# ed è stata portata sui principali sistemi operativi: GNU/Linux, FreeBSD, Mac OS X, Windows ma anche Android e iOS per lo sviluppo di applicazioni su dispositivi mobili.
Alcuni wrapper esportano solo un limitato sottoinsieme di funzionalità.
Mi sono reso conto che le potenzialità di tale libreria sono superiori alle mie più rosee aspettative: c’è tutto quello che può servire (e si può sognare) per realizzare applicazioni avanzate di Computer Vision ed elaborazione delle immagini.
Sviluppare un’applicazione di ottima qualità per la face detection in realtime, problema normalmente complesso, diventa banale a tal punto che mi sono limitato a fare qualche ricerca su internet ed assemblare poche righe di codice Python trovate in alcuni blog.
Face Detection ed Haar-like features
L’algoritmo molto efficiente che viene utilizzato per la rilevazione dei volti, basato sulle Haar wavelet, è stato elaborato da Viola-Jones nell’ambito dell’object detection ed è stato pensato proprio per il problema della face detection in tempo reale.
Con OpenCV è possibile addestrare nuovi identificatori di oggetti tuttavia sono già presenti i seguenti classificatori (in formato xml):
Nelle mie prove, dopo aver individuato il volto, ho provato a rilevare anche gli occhi e la bocca ma in questo caso i risultati non mi hanno soddisfatto.
Sorgente Python
I miei esperimenti sono stati effettuati su una macchina GNU/Linux Ubuntu 11.04 con OpenCV 2.1.
E’ richiesto il pacchetto python-opencv, presente nei repository ufficiali e si assume che nel path dello script sia presente una directory haarcascades contenente i vari xml necessari per la detection.
Su Ubuntu 11.04 è possibile trovarli nella directory:
segue il codice sorgente utilizzato per la realizzazione del video:
#!/usr/bin/python
#----------------------------------------------------------------------------
# Face Detection Test (OpenCV)
#
# thanks to:
# http://japskua.wordpress.com/2010/08/04/detecting-eyes-with-python-opencv
#----------------------------------------------------------------------------
import cv
import time
import Image
def DetectFace(image, faceCascade):
min_size = (20,20)
image_scale = 2
haar_scale = 1.1
min_neighbors = 3
haar_flags = 0
# Allocate the temporary images
grayscale = cv.CreateImage((image.width, image.height), 8, 1)
smallImage = cv.CreateImage(
(
cv.Round(image.width / image_scale),
cv.Round(image.height / image_scale)
), 8 ,1)
# Convert color input image to grayscale
cv.CvtColor(image, grayscale, cv.CV_BGR2GRAY)
# Scale input image for faster processing
cv.Resize(grayscale, smallImage, cv.CV_INTER_LINEAR)
# Equalize the histogram
cv.EqualizeHist(smallImage, smallImage)
# Detect the faces
faces = cv.HaarDetectObjects(
smallImage, faceCascade, cv.CreateMemStorage(0),
haar_scale, min_neighbors, haar_flags, min_size
)
# If faces are found
if faces:
for ((x, y, w, h), n) in faces:
# the input to cv.HaarDetectObjects was resized, so scale the
# bounding box of each face and convert it to two CvPoints
pt1 = (int(x * image_scale), int(y * image_scale))
pt2 = (int((x + w) * image_scale), int((y + h) * image_scale))
cv.Rectangle(image, pt1, pt2, cv.RGB(255, 0, 0), 5, 8, 0)
return image
#----------
# M A I N
#----------
capture = cv.CaptureFromCAM(0)
#capture = cv.CaptureFromFile("test.avi")
#faceCascade = cv.Load("haarcascades/haarcascade_frontalface_default.xml")
#faceCascade = cv.Load("haarcascades/haarcascade_frontalface_alt2.xml")
faceCascade = cv.Load("haarcascades/haarcascade_frontalface_alt.xml")
#faceCascade = cv.Load("haarcascades/haarcascade_frontalface_alt_tree.xml")
while (cv.WaitKey(15)==-1):
img = cv.QueryFrame(capture)
image = DetectFace(img, faceCascade)
cv.ShowImage("face detection test", image)
cv.ReleaseCapture(capture)
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptRead More
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.