Docsity

Principles of artificial intelligence and machine learning, Appunti di Machine learning

Toggle sidebar
bg1
Principles of Artificial Intelligence and Machine Learning
Lecture 03.10: Historical Background of Artificial
Intelligence
Artificial intelligence was founded in the 1950s making it a 70-year-old discipline, still young by academic
standards.
Alan Turing, the British mathematician, is widely regarded as thefounding figure of AI, whose work
laid the theoretical foundation for the field;
oTuring initially referred to the concept as“mechanical intelligence,”reflecting the
technological context of the time when computers were essentiallymechanical devices;
oHis core idea was that it might be possible to build machines capable of mimicking the
behavior of the human brain;
oTuring’s vision of AI, machines imitating the brain, differs from today’s interpretation.
Modern AI does not attempt toreplicate human emotions or consciousnessbut rather focuses on
experienced based learning and task-oriented intelligence;
The early years of AI were dominated by experimental efforts to make machines simulate cognitive
tasks rather than to mirror psychology or emotion.
One of the first practical applications of AI was instrategy games such as chess, chosen because they involve
afinite and well-defined set of rules and moves.
This made them particularly suitable for early computational experiments. In chess, every move creates
a branching set of possibilities, which can be systematically analyzed;
While humans can onlyanticipate a limited number of future movesdue to memory and cognitive
constraints, machines cancalculate all possible moves and outcomes, exploring every path to
determineoptimal strategies. Ascomputational power increased, machines could analyze larger
numbers of moves more rapidly, eventuallysurpassing human players.
He notes that when computer resources were limited, humans could still win, but as performance
improved, machines became unbeatable. This development marked aturning pointin AI history,
illustrating how advances in hardware capability directly translated into superior machine performance.
Following these early successes,AI research centerswere established at prominent institutions such asMIT,
Stanford, and Boston, focusing on expanding AI intonew domains. By the1960s, efforts turned
towardindustrial automation andnatural language processing (NLP), that is, enabling machines to understand
and use human languages. “Natural languages”(like English, Italian, or French) are those used by humans,
whereas“artificial languages”(like Python, COBOL, BASIC, or FORTRAN) areprogramming
languagesdesigned for computers.
The first natural language processing program was ELIZA, created in 1965.
This program simulated a typed conversation between a user and the computer: users entered text and
ELIZA generated textual responses;
Althoughnaïve and simplistic, the system gave users theillusion of dialogue, the feeling of “talking” to
the machine;
ELIZA can be compared with today’s conversational systems such asAlexaorSiri, which engage
ingenuine interactionandunderstand spoken language, representing a massive leap in complexity and
capability.
After initial optimism, AI experienced aperiod of stagnation, often referred to as an“AI winter.”
For about15 years, progress slowed, funding declined, and enthusiasm faded;
Researchers found thattraditional rule-based systemscould not effectively handlereal-world problems,
which are often uncertain, variable, and context-dependent. This impasse led to thebirth of the
machine learning paradigm, marking a fundamental shift in the field. In theclassical AI approach,
problems were encoded assets of logical rules—rigid “if–then” statements that machines applied
deterministically. This approach leftno room for uncertainty or adaptation. Machine learning
introduced astatistical approach, allowing algorithms tolearn patterns from datarather than rely on
predefined rules. Machines could nowdevelop their own internal representations and decision
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55

Anteprima parziale del testo

Scarica Principles of artificial intelligence and machine learning e più Appunti in PDF di Machine learning solo su Docsity!

Principles of Artificial Intelligence and Machine Learning

Lecture 03.10: Historical Background of Artificial

Intelligence

Artificial intelligence was founded in the 1950s making it a 70-year-old discipline, still young by academic standards.  Alan Turing, the British mathematician, is widely regarded as the founding figure of AI, whose work laid the theoretical foundation for the field; o Turing initially referred to the concept as “mechanical intelligence,” reflecting the technological context of the time when computers were essentially mechanical devices; o His core idea was that it might be possible to build machines capable of mimicking the behavior of the human brain; o Turing’s vision of AI, machines imitating the brain, differs from today’s interpretation.  Modern AI does not attempt to replicate human emotions or consciousness but rather focuses on experienced based learning and task-oriented intelligence;  The early years of AI were dominated by experimental efforts to make machines simulate cognitive tasks rather than to mirror psychology or emotion. One of the first practical applications of AI was in strategy games such as chess, chosen because they involve a finite and well-defined set of rules and moves.  This made them particularly suitable for early computational experiments. In chess, every move creates a branching set of possibilities, which can be systematically analyzed;  While humans can only anticipate a limited number of future moves due to memory and cognitive constraints, machines can calculate all possible moves and outcomes, exploring every path to determine optimal strategies. As computational power increased, machines could analyze larger numbers of moves more rapidly, eventually surpassing human players.  He notes that when computer resources were limited, humans could still win, but as performance improved, machines became unbeatable. This development marked a turning point in AI history, illustrating how advances in hardware capability directly translated into superior machine performance. Following these early successes, AI research centers were established at prominent institutions such as MIT, Stanford, and Boston, focusing on expanding AI into new domains. By the 1960s, efforts turned toward industrial automation and natural language processing (NLP), that is, enabling machines to understand and use human languages. “Natural languages” (like English, Italian, or French) are those used by humans, whereas “artificial languages” (like Python, COBOL, BASIC, or FORTRAN) are programming languages designed for computers. The first natural language processing program was ELIZA, created in 1965.  This program simulated a typed conversation between a user and the computer: users entered text and ELIZA generated textual responses;  Although naïve and simplistic, the system gave users the illusion of dialogue, the feeling of “talking” to the machine;  ELIZA can be compared with today’s conversational systems such as Alexa or Siri, which engage in genuine interaction and understand spoken language, representing a massive leap in complexity and capability. After initial optimism, AI experienced a period of stagnation, often referred to as an “AI winter.”  For about 15 years, progress slowed, funding declined, and enthusiasm faded;  Researchers found that traditional rule-based systems could not effectively handle real-world problems, which are often uncertain, variable, and context-dependent. This impasse led to the birth of the machine learning paradigm, marking a fundamental shift in the field. In the classical AI approach, problems were encoded as sets of logical rules—rigid “if–then” statements that machines applied deterministically. This approach left no room for uncertainty or adaptation. Machine learning introduced a statistical approach, allowing algorithms to learn patterns from data rather than rely on predefined rules. Machines could now develop their own internal representations and decision

strategies based on experience. This paradigm shift allowed for flexibility, probabilistic reasoning, and an ability to handle the ambiguities of the real world. As a result, a new wave of breakthroughs occurred, giving rise to advanced applications and systems capable of performing previously impossible tasks. Once the machine learning approach took hold, there was an explosion of new developments. Technologies like chatbots, data analysis systems, and intelligent interfaces emerged, allowing for natural human–machine communication in multiple languages. Machine learning began achieving remarkable success in diverse domains—medical diagnostics, image recognition, object detection, and more. By the 2010s and early 2020s, AI had achieved an extraordinary level of capability, becoming integrated into virtually every field of human activity. The adoption and over-resiliance on AI tools can create risks: These systems can act as “oracles,” answering almost any question, but this convenience carries potential danger: people may stop thinking critically and lose essential cognitive skills. Uncritical dependence on AI can lead to intellectual stagnation, an inability to think independently, summarize ideas, or even communicate effectively. AI should serve as an amplifier of human skills, not a replacement for them. Without a solid foundation of knowledge, users risk becoming “slaves to the machine. To avoid this dependency and remain autonomous is to understand how technology works. TURING TEST The Turing Test devised by Alan Turing is a method for determining whether a machine exhibits human-like intelligence.  The test involves human evaluator communicating via written text with both a human and a machine, without knowing which is which;  If the evaluator cannot reliably distinguish between human and machine responses, the machine is said to have achieved artificial intelligence;  In Turing’s time, there were no vocal interfaces, so the test relied exclusively on written communication;  Today most advanced AI tools would easily pass the Turing Test, producing text indistinguishable from human writing. This demonstrates how far AI has progressed reaching a level of fluency and coherence that mirrors human communication. IBM Watson is one of the first major demonstrations of AI’s practical success.  Developed by IBM roughly 15 years ago, Watson was a question-answering computer system capable of processing natural language input, questions posed in plain English;  Watson competed on the American TV quiz show Jeopardy!, where it successfully defeated human champions. This represented a significant milestone in AI’s ability to understand, interpret, and respond to natural language, showcasing the tangible results of decades of research;  He notes that Watson’s knowledge base consisted of approximately 200 million pages of text, a number that sounds vast but is modest by today’s standards illustrating both the rapid evolution of AI and the exponential growth in available data;  The system operated by interpreting natural language questions and searching for answers within its own knowledge base, which drew on multiple sources such as Wikipedia. Each time a question was posed, Watson analyzed its meaning, searched through its stored data, and generated an appropriate answer. He notes that Watson’s knowledge base, about 200 million pages of text, was surprisingly compact, requiring storage space comparable to a few terabytes, which by today’s standards is quite modest. He humorously observes that many students’ laptops now contain 1–2 terabytes of memory, meaning that a contemporary personal computer could, in principle, host Watson’s data and processing power. This contrast highlights how quickly hardware capabilities have advanced, making what once required supercomputers now feasible on consumer devices. Another major milestone in AI history is AlphaGo, the AI system developed by DeepMind later acquired by Google. While computers had already mastered chess in the 1960s, AlphaGo represented a leap forward because Go is a far more complex game, with an astronomically larger number of possible moves. In just a few years, AlphaGo evolved from beating professional Go players to defeating 9-dan masters, the highest rank in the game, and finally the world champion. This progression occurred within two to three years, marking an unprecedented acceleration in machine performance. AlphaGo combined random search strategies with neural networks, making it one of the first widely recognized applications of deep

The classical approach to AI was based on building logical reasoning chains, where humans explicitly programmed the machine with “if–then” statements. These rules were rigid and could not handle ambiguity or variability. That approach mainly relies on causal relationships. Most recently, machine learning has become the major development of AI. It involves feeding the machine with examples, each described by measurable parameters and associated outcomes. Machine learning favors a statistics-based approach. Through this process, the system learns to associate specific conditions with probable results. For example, if a dataset shows that certain combinations of temperature, pressure, and humidity often precede rain, the machine can learn to predict rainfall without being told explicit meteorological formulas. This statistical learning requires vast quantities of data and high computational power, both of which have become available only in recent decades due to digitalization and massive data collection. The shift from symbolic to statistical AI thus marks the foundation of today’s machine learning era. FEATURES AND TARGET VARIABLES In machine learning there are two fundamental concepts:

  1. Features: input parameters that help a machine plan, just as they help humans; o These are the measurable characteristics or factors that describe each instance in the dataset;
  2. Target variables: output or decision that the model must predict; In simple cases, the target variable might take binary values, such as “yes” or “no”, but in more complex applications, like medical diagnosis, there can be multiple possible outcomes (e.g., disease A, B, C, D, or none). Similarly, in image recognition, the target could represent several categories such as car , dog , lamp , or truck. SUPERVISED MACHINE LEARNING When we talk about supervised machine learning we refer to the type of learning corresponding to the examples previously discussed.  In supervised learning the system is trained using a set of labeled examples that is, instances for which the correct output is already known;  This allows the machine to learn the relationship between input features and their associated target variables; An example application: AI in Medical Decision Making, Intensive Care Prioritization To demonstrate real-world applications, we can describe how AI can assist doctors in emergency departments. When a new patient arrives, physicians must decide whether to admit them to intensive care a crucial judgment that can determine survival. Doctors rely on experience, but they are limited by stress and personal knowledge. A machine, however, can access the collective data from thousands of hospitals worldwide, integrating the experience of countless medical professionals. By comparing the new patient’s parameters, vital signs, test results, and health history, with similar past cases, the system can estimate the probability of survival and recommend an appropriate course of action. Such systems can also balance ethical and economic trade-offs, such as whether scarce ICU beds should be prioritized for patients with higher chances of recovery. Although sensitive, these decisions are an inevitable part of healthcare resource management. AI’s contribution lies in providing data-driven objectivity, enhancing but not replacing human judgment. Another application: AI in Finance: Credit Scoring and Risk Assessment Banks and credit card companies must decide whether to approve new credit cards or loans, and these decisions depend on assessing an applicant’s financial reliability. Machine learning models analyze numerous features such as age, income, employment status, property ownership, existing debts, and more based on thousands of historical cases where past applicants either repaid or defaulted. By recognizing statistical patterns, the system can estimate the probability that a new applicant will fulfill their financial obligations. Only applicants with sufficiently high repayment probability are approved. These datasets are typically structured in the following way: each row corresponds to a past case, and each column represents a specific parameter, such as job status, salary, or home ownership. The final column contains the outcome label, whether the person repaid or defaulted. The model learns from this structure to predict outcomes for future applicants. This financial use case, he notes, exemplifies the core principle of supervised learning, where machines generalize from labeled examples to make decisions in new, unseen situations.

 During training, the model discovers the mapping from inputs to outputs so that, when presented with new data, it can predict the correct outcome;  The quality of this learning process is measured by how well the model minimizes errors, its goal is to make as few mistakes as possible in its predictions. ROLE OF BIG DATA IN MACHINE LEARNING: WHAT IS DRIVING THE RISE OF ML Data availability has a critical role in enabling modern artificial intelligence and machine learning. Infact we have an increasingly growing amount of data available; data are now (nearly) all natively digital.  The number of applications and users generating data is continuously increasing. We have data coming from observation platforms (markets), sensors (IoT) and User-generated data.  These techniques depend on enormous amounts of examples, often numbering in the hundreds of thousands or millions;  The success and spread of machine learning applications are largely due to the explosive growth of data in recent decades. He highlights that this expansion is exponential rather than linear, the total volume of data generated globally continues to increase at an accelerating pace, reaching scales measured in zettabytes, a unit far beyond gigabytes or terabytes. Amount of data in the world Every interaction on the internet, every post, message, or purchase, contributes new data to the global pool. Today, unlike twenty or thirty years ago, individuals are active producers of data, not just consumers. Each online activity adds to the immense datasets that fuel machine learning systems. This continual generation of data provides the raw material for algorithms to learn from and improve. This ongoing growth in data creation is unstoppable and forms one of the key reasons for the success of artificial intelligence and machine learning. The more data machines have access to, the better they can learn patterns, make predictions, and refine their performance.

Lezione 7/10: SUPERVISED AND UNSUPERVISED LEARNING

Example: Customer Classification and Market Segmentation Suppose a company has extensive data about its customers, such as the number of purchases made in the past six months, frequency of purchases, preferred payment methods, and spending ranges. The goal is to segment these customers into groups so that each group can receive targeted marketing strategies. Groups might include, for instance, “affluent customers,” “low- income customers,” “young customers,” or “elderly customers.” Each segment requires a tailored marketing approach, a practice students can observe daily through advertisements and personalized offers. How much data do we generate each day?  500 million tweets;  294 billion emails;  4 million gigabytes of Facebook data;  100 billion WhatsApp messages;  500 hours of new content added every minute on YouTube

 We don’t know the number and the characteristics of the groups we are going to analyze. We can distinguish due major types of supervised learning:

  1. Classification
  2. Regression Every supervised learning problem, he notes, falls into one of these two categories, depending on the nature of the target variable (i.e., what is being predicted). .  Regression identifies a mathematical function that provides the most suitable (closest to data) output value: the output is a number; o We have a single feature (see pic); o involves predicting a continuous value rather than a class. Classifier is a machine that takes features as inputs (instance characteristics) and the class label identifies the class to which the instance belongs (target variable).

SUPERVISED VS UNSUPERVISED LEARNING

 in supervised learning, the classes are known in advance (e.g., “diabetic” vs. “non-diabetic”), while in ;  unsupervised learning, the structure is discovered through analysis.. In this graph we can see and expanded categorization of ML tasks. Beyond the broad supervised/unsupervised distinction there are multiple subtypes of learning problems.  Classification segments the feature space into a number of regions (classes): the output is a class; o We can represent the problem in such a way that there is a separation line between the instances that between to classes (even different between them); o classification problems involve predicting one of a finite set of outcomes and are often representend in 2 dimensions (features)

o In real-world applications, there may be hundreds

or thousands of features, but visual demonstrations typically use two.

BINARY VS MULTI-CLASS CLASSIFICATION

 binary classification is suitable for problems that require a YES/NO answer;  we may have multiple output classes instead CLASSIFICATION APPLICATIONS Classification is one of the most widespread applications of machine learning today and gives several concrete examples.

  1. Face recognition:  Suppose we have photographs of each of the twenty students in the classroom. When given a new picture, the task is to identify which student it belongs to. This is a multi-class classification problem with twenty possible outcomes;  To make the system more complete, he adds an extra “none of the above” category covering cases where the photo belongs to someone outside the class. Thus, the full set of classes must include all possible outcomes to ensure the classifier can always assign an input to one of them.
  2. Voice recognition:  The setup is similar: given samples of each student’s voice, the classifier must decide whether a new voice sample matches one of them or belongs to someone else;  Again, this is a classification problem with as many classes as there are individuals, plus potentially one “unknown” class.
  3. Medical diagnoses  medical tasks often involve classification, determining whether a patient has a disease, or, in multi-class versions, identifying which specific pathology the patient has.
  4. Character recognition In economics, classification can be used to predict outcomes like whether a company will go bankrupt in the next six months. This is a binary classification (yes/no). Alternatively, a company’s profit range could be predicted in categories (e.g., “0–1 million euros,” “1–5 million euros,” etc.), making it a multi-class classification problem. DECISIOM TREE TO CLASSIFY A decision tree is a very simple yet effective classifier. In a decision tree diagram, each box represents a feature that the algorithm examines to plan. Each branch corresponds to a possible value or range of that feature, leading to another node or to a final prediction.

CASE STUDY: FACE RECOGNITION AND TASK FRAMING

We can elaborate a face recognition example, describing how training data are collected: multiple images of the same person taken under various lighting conditions, angles, and orientations.  The task is to train the model so that, when presented with new images, it can correctly identify whether each image belongs to the target individual or to someone else;  The evaluation process involves testing the classifier with several images, one of the target person and others of different individuals and observing its outputs. Ideally, the system should respond “yes” for the correct image and “no” for all others. This example highlights the importance of properly framing a classification task, defining the question clearly and determining the exact set of possible classes. In the face recognition scenario, the question is: “Does this new image belong to the individual we’re tracking?” The answer options (classes) are binary: “yes” or “no.” Proper problem framing is crucial because it determines how the model will learn and what kind of output it can produce.

Lecture 10.

We are going to analyzing several problems in order to correctly categorize them into the types of machine learning tasks. PROBLEM 1- PREDICTING KEY WASTE COLLECTION % You are asked to retrieve some data concerning e-waste collection percentages for a large number of countries. The aim is to predict e-waste collection percentages based on socio-economic indicators such as income per capita or population size. Is this task as classification or regression?  we will have a regression with possible values from 0-100%;  this is because the task involves predicting a numerical value, not a discrete category. PROBLEM 2- IMAGE CLASSIFICATION (Bicycles, Scooters, Motorbikes) You are asked to retrieve 100 images for each of the following categories: bicycles, scooters, and motorbikes. Then, given a new image, the goal is to determine which category it belongs to.  This is classification task with three classes. PROBLEM 3- PREDICTING PASSENGERS SATISFACTION LEVEL The third problem involves datasets derived from passenger satisfaction surveys conducted among airline customers. The goal is to predict satisfaction levels using various predictor variables such as passenger age, type of flight (domestic, international, or transatlantic), and presence of delays.  It is a regression because the satisfaction level is a numerical or ordered variable that can take a range of values depending on the scale used, for example, from 0 to 10, 0 to 100%, or 1 to 5/7 on a Likert scale;  the specific range depends on how the survey was designed: A satisfaction scale can vary in granularity: a 5-point scale captures coarse satisfaction levels, while a 7-point Likert scale provides finer distinctions;  satisfaction is subjective and can depend on different factors for different individuals, such as price, comfort, or timeliness. Although these determinants are outside the scope of the exercise, the goal is to understand the type of machine learning task (regression) and the nature of the target variable (numerical). PROBLEM 4- PREDICTING FLIGHT DELAYS BEYOND 15 MINUTES In the fourth example, students must predict whether a flight will be delayed by more than 15 minutes.  it is a classification task, since the answer is binary: either “yes” (the delay exceeds 15 minutes) or “no” (the delay does not);  It distinguishes from a regression task because a regression task would instead predict the exact duration of the delay (e.g., 10 minutes, 21 minutes, etc.). Here, since the question is simply whether the delay exceeds a threshold, it qualifies as binary classification. PROBLEM 5- PREDICTING RAINFALL The fifth problem asks students to use various weather observations, such as pressure, temperature, and cloud cover, to predict whether it will rain tomorrow.  It is a binary classification task, with the possible outcomes being “yes” (it will rain) or “no” (it will not rain). PROBLEM 6- CUSTOMER SEGMENTATION It involves customer segmentation. The example assumes a UK company that needs to divide its customers into groups and identify high-value customers. there are two separate objectives: segmenting customers and detecting high-value ones, suggesting that the problem may involve different analytical approaches.  It is an unsupervised learning, specifically a clustering experience because we do not want a value we only want to divide them into groups;  while classification and regression rely on known target labels, clustering requires the algorithm to determine both the number and nature of segments on its own.

 Clustering tasks can yield two types of outputs: o Non-overlapping (exclusive) clusters, where each data point (customer) belongs to exactly one segment; o Overlapping clusters, where a customer can belong to multiple segments simultaneously. In fuzzy clustering, membership is not binary (0% or 100%) but gradual, allowing partial belonging to several clusters simultaneously.  This technique can make conceptual sense in many contexts, such as marketing, where customers often share characteristics of multiple groups. Ultimately, whether to use non-overlapping or overlapping clusters depends on the specific context and analytical goal.  This distinction sets up the following discussion on partitioning versus fuzzy clustering. PROBLEM 7- FORECASTING BIKE RENTALS This example involves a bike rental shop seeking to forecast the number of customers renting bikes at various times — hourly or daily. The predictive features include both environmental variables (such as temperature, rainfall, and weather conditions) and seasonal factors (like time of year).  It is a regression problem, since the goal is to predict a numerical quantity — the count of rentals;  the target variable’s range as 0 to infinity, since there may be no rentals at certain times but theoretically no upper bound on the number of rentals;  If we narrow the range (es. 0-1 or 2-3) the classification transforms into a regression since we have single numbers The distinction between classification and regression is not absolute but continuum. By progressively narrowing the width of the classification ranges, one can make a classification problem behave almost identically to a regression one.  For example, if the ranges for bike rentals are made very small — 0–1, 2–3, 4–5, and so on, the classification task becomes practically indistinguishable from regression, even though it is formally defined as a discrete prediction problem;  This demonstrates that the two paradigms are conceptually related and that, depending on the granularity of the output variable, a machine-learning task can transition smoothly from classification to regression. PROBLEM 8- PREDICTING TYPES AND OUTCOMES OF CRIMES In the eighth problem, the dataset comes from the San Francisco Police Department, containing crime reports for a specific year. The objective is twofold:  Predict the type of crime (e.g., robbery, burglary, or murder);  Predict the type of crime resolution (e.g., suspect arrested, suspect killed, unresolved). Predicting the type of crime is a classification task since the target variable consists of discrete categories.  Sometimes a single record may involve multiple crimes at once—for instance, a burglary that escalates into a robbery and a murder. In such cases, multiple labels can apply simultaneously; o in this case we can distinguish between scalar output variables, which hold a single value (like a class label or a numerical amount), and vector output variables, which can represent multiple simultaneous outcomes; o In most classification or regression problems discussed so far, the output variable was scalar, a single prediction per input; o However, when multiple labels or outcomes can apply to a single observation, the output becomes a vector, leading to multi-label classification or multi-output prediction. Until now the tasks discussed have involved scalar outputs, meaning that the model produces a single numerical or categorical value for each input. However, in some cases, the target variable may instead be a vector, containing multiple elements.Using the example of predicting crime types in San Francisco, a single incident might involve more than one category of crime, for example, both robbery and battery. In such cases, the output cannot be represented by a single label, but rather by a vector of binary indicators, where each element corresponds to a specific crime type: a value of 1 indicates that the crime type is present, and 0 that it is not. For instance, if only a robbery occurs, the output vector might be [1, 0, 0], whereas a robbery combined with a

o This introduces a distinction between different kinds of variables an essential concept for any data analysis or machine learning pipeline. DATA TYPES BY SOURCE NATURE Data can be classified according to their nature or format. When we discuss the type of data we refer to their nature before the encoding process since after conversion all the data in the digital systems become binary numerical variables:

  1. text data which consists of sequences of characters, including letters, numbers, and punctuation marks, like those found in a document; o Textual information does not fit neatly into the numerical/categorical dichotomy (discussed ahead) it rather consists of sequences of characters and often requires specialized processing techniques such as tokenization, vectorization, or embedding to be used effectively in machine learning; o Text data can be treated as categories or classes when used in machine learning tasks; o Text data are typically converted into some vector numeric coding to be treated o For example, if the goal of a model is to predict a word or a character in a text sequence, each possible word or character effectively becomes a class in a classification problem; o Thus, although text is not numerical by nature, it typically corresponds to categorical data before being numerically encoded; o However, in practical computation, text must undergo a coding or encoding process that converts these words or characters into numbers, such as through one-hot encoding, embeddings, or other text representations.
  2. numeric data , which can represent either pure numbers (such as the number of bikes rented per day) or quantitative measurements (such as length, height, or temperature, which come with units of measure); o These numerical variables can be integers or real numbers, depending on the context; o Beyond text and numbers, there are images, which are data represented in formats such as JPEG or PNG; o Images can be chromatic (color) or monochrome, depending on the representation.
  3. audio data , referring to recordings or voice samples, often used in speech recognition or acoustic analysis;
  4. video data combines both image and sound over time; o while videos are stored as sequences of numeric pixel values, the essential distinction lies in their original content; o for example, whether a frame depicts a cat, a dog, or a yellow object; o video data are provided through a video file format (typically a bitmap file); o Like with text, the meaningful differences among data types concern the source and semantics of the data before encoding, not their post-digital format, which is always numeric. In addition to these distinct formats, there exist multimedia data , which are combinations of the previous types.  for example, a file that contains text, images, and videos together;  Multimedia data, therefore, act as containers for multiple data modalities, often requiring more complex processing pipelines.

While these distinctions between text, image, audio, and video describe the source of the data, once data are stored and processed digitally, they all share the same fundamental representation: sequences of bits.  In the digital domain, everything becomes numerical even images and sounds are encoded as numeric arrays or strings of bits;  Therefore, while it is meaningful to talk about “image data” or “audio data” in terms of their original format, at the computational level, the difference disappears;  All data become numerical and machine-readable, making them uniform for processing by algorithms; TYPES OF VARIABLES There are two basic types of variables:

  1. Numerical variables: those variables to which a number is assigned as a quantative value;
  2. Categorical variables: variables defined by the classes or categories into which an individual member fall. Both features and the target variable can belong to either type, and understanding this distinction is essential to selecting the right model.  For example, determining whether the target variable is numerical or categorical determines whether the task is a regression or classification problem, respectively. However, the same distinction must be applied to features , as they can also be of either kind.
  3. Numerical features might represent measurable quantities like age or temperature. Numerical variables can be distinguished in two fundamental subtypes: o Discrete variables: are those that take on only specific, separate values, typically integers or countable quantities. These may arise from counting (e.g., the number of bikes rented in a day: 0, 1, 2, 3, …) or from categorical numeric sets that have a finite or countable number of possible values. A variable might still be considered discrete even if its possible values are not consecutive integers; for example, if it can take on values like 1, 2, and 4, the set is still finite and countable, and thus discrete; o Continuous variables: can assume any value within a range , potentially infinite, and often come from measurement rather than counting. The professor stresses that the difference between the two types is not about whether the numbers themselves have decimals, but whether the set of possible values is finite (discrete) or infinite (continuous).
  4. Categorical features might represent types or groups, such as color or brand. Categorical data represent a set of possible categories or classes where the value of the variable can lie. For example, the color of a sweater might be “yellow,” “red,” or “black.” These are distinct categories, and even though they are non-numeric, they are still values of the variable “color.” Hence, categorical variables can be thought of as taking values from a finite set of options, unlike numerical variables, which vary along a continuous or discrete numeric scale. TYPES OF NUMERICAL VARIABLES  Discrete: reflect a number obtained by counting (no decimal) or from categorical numeric sets that have a finite or countable number of possible values; o are defined as those that can only take values from a set of predefined, distinct values, typically integers or countable quantities; o A variable might still be considered discrete even if it’s possible values are not consecutive integers, what matters is whether they can be mapped to integral variables; o for example, if it can take on values like 1, 2, and 4, the set is still finite and countable, and thus discrete.  Continuous: reflects a measurement, the number of decimal places depends on the precision of the measuring device; o they can assume any value within a range, potentially infinite, and often come from measurement rather than counting. o Continuous variables fall into two subtypes based on the scale used:

o For instance, sentences like “The dog bit the fox” and “The fox bit the dog” have the same representation in these matrices, even though the meaning differs;  These matrices only tell us which words appear, not how they’re ordered;  DTM and TDM matrices may have size of thousands rows/columns; o They are also very sparse (high percentage of zeroes) TDM MATRICES DTM MATRICES A DTM matrix is just the transpose of its associated TDM matrix;  Each row represents a document;  Each column represents a word;  numbers represent the frequency of each term in each document. In contrast, a TDM inverts this structure: words appear on the rows, and documents on the columns. ONE-HOT ENCODING: VECTOR-BASED REPRESENTATION One-hot encoding is a method where each word is represented by a vector of zeros, with a single 1 at the position corresponding to that word in the vocabulary;  Instead of a matrix, this approach uses a collection of vectors, where each word has its own one-hot vector; o For example, the word "Paris" may be represented as a vector with a 1 in the second position and 0s elsewhere. A basic representation of documents is through the words they contain;  Each document is a vector in a vector space;  Vector space dimensions are the single words;  Each coordinate represents the frequency of that word in the document;  Very expensive;  Does not preserve semantic distance. Words as vectors  Rows represent words;  Columns represent documents;  Entries represent frequency of words in documents. TDM vs DTM matrices This distinction is purely structural, altering how data is accessed and displayed, but the underlying information remains the same.  So, the main difference between the two matrices lies in their orientation, the TDM focuses on terms as rows, while the DTM focuses on documents as rows.

ISSUES :

One-hot encoding creates a vector space whose dimensionality equals the vocabulary size.  So, if your vocabulary has 50,000 unique words, each one-hot vector has 50,000 components, all zeros except one;  These vectors are extremely sparse, and the document is represented as a set of such vectors, with frequency reflected by vector repetition (e.g., a word appearing twice has a vector scaled by two);  While conceptually simple, this method is storage-intensive and inefficient. So:  Semantically similar words are represented through orthogonal vectors;  Their dot product, which can be used as a similarity metric, is zero. Both DTM/TDM matrices and one-hot encodings suffer from the same core problem: they do not capture word meaning or order.  Words like "motel" and "hotel", which are clearly related, are treated as completely independent in these systems;  As a result, semantic relationships between words are lost, making these representations unhelpful for more sophisticated language tasks like similarity or clustering. WORD EMBEDDING The problem with DTM/TDM (and one-hot encoding) is that they do not consider the position of words in the text, i.e., their context.  One-hot encoding does not preserve semantic similarity; To overcome this issue, we can introduce a very popular context-aware encoding is word embedding:  a more advanced representation of words as vectors;  Unlike one-hot encodings, word embeddings preserve both semantic similarity and contextual relationships;  A popular method for generating word embeddings is Word2Vec. This central idea of word embeddings is rooted in the distributional hypothesis, which states that a word's meaning is derived from the context it appears in;  Thus, similar contexts imply similar meanings;  As a result, word embeddings capture word similarity in their vector representations, and words with related meanings have vectors that are close together in space;  If a word has multiple meanings (like “bank”), it may end up with vectors that reflect different contexts. The distributional hypothesis is not mathematically proven, but it works well in practice.  In traditional methods like one-hot encoding or DTM, the vector size grows with vocabulary size, which is inefficient;  In contrast, word embeddings use fixed-size vectors regardless of how many words are in the vocabulary, making them more compact and scalable. Summary of Key differences Between One-Hot and Word Embeddings  In word embeddings like Word2Vec, each word is mapped to a dense vector, and the mapping is learned through algorithms;  Unlike one-hot encoding where you arbitrarily assign a 1 to a word’s position, word embeddings are generated to reflect actual word usage and meaning;  The idea is that words appearing in similar contexts have similar meanings, an assumption known as the distributional hypothesis.

IMAGE REPRESENTATION

Each pixel is a tiny element of an image that contains color data.  The resolution of an image is determined by the number of horizontal and vertical pixels; o for example, an image that is 500×1000 pixels contain 500,000 individual pixels;  Higher resolution means more detail but also requires more storage space;  A 20-megapixel image (20 million pixels) will take up far more storage than a 5-megapixel one;  Each pixel stores color information, so the more pixels an image has, the more visually detailed and larger the file will be. VECTOR CODING Vector coding represents an image using geometric primitives, lines, curves, shapes, defined mathematically.  Vector graphics do not depend on resolution, since shapes are computed at any scale;  Common formats: SVG, EPS, AI (Adobe Illustrator). Unlike bitmap images, vector images are not made of pixels.  Instead, they are composed of geometric elements such as squares, circles, and curves;  Each element is mathematically described by parameters, like coordinates and dimensions; o For example, a square is defined by its corner coordinates, and a circle by its center and radius;  This results in a more compact and structured way to encode an image. We have two approaches:

  1. Bitmap (raster); o An image is divided into a matrix of pixels; o A pixel represents a dot, which is the smallest unit of the image; o Image resolution depends on the number of pixels in the image; o Higher resolution images require larger memory; o Once image is divided into pixels, each pixel is given a bit-pattern; o The pixel bit-pattern determines the color of the pixel
  2. Vector coding; GRAY-SCALE IMAGES To represent a gray-scale image of 4 colors (for example) we need to increase the length of bit-pattern representing the pixel to be 2 bits.

FULL COLOR IMAGES

Any visible color could be constructed from the 3 basic colors Red, Green, Blue (RBG).  The difference between one color and another depends on the intensity of the RBG components in the color;  Therefore, to represent a colored image, each pixel in the image must be represented by 3 different bit patterns. Each of them represents the intensity of the basic colors;  The length of a bit pattern representing each basic color is usually 8 bits

APPLICATIONS OF VECTOR CODING

Vector coding is widely used in different fields.  One major application is in computer-aided design, or CAD, where it is used to create precise technical drawings and engineering models;  It is also commonly used in logo and icon design, because vector images can be easily resized and edited without losing quality;  Another important use is in data visualization, for creating charts and diagrams that clearly represent information;  Finally, vector coding is applied in machine learning preprocessing, especially when working with structured graphical data. REDUNDANCY We can distinguish different types of redundancy:  Spatial redundancy: neighboring pixels in a frame are often similar, compression exploits this (like in JPEG); o Even within a single image, areas often have identical pixel values (like a white wall); o Rather than storing each pixel’s value, the same value can be reused across that region.  Temporal redundancy: successive frames are similar; o coding can store only changes between frames;

PROS OF VECTOR CODING

  1. Scalability: images can be resized to any dimension without losing quality;
  2. Compactness: simple shapes and text take up less storage space than pixel-based images;
  3. Editability: each element, such as lines, curves, or colors, can be easily modified;
  4. Precision: vector coding is ideal for technical drawings, logos, and icons where geometric accuracy is essential.

CONS OF VECTOR CODING

There are also limitations:  Vector coding is not suitable for complex natural images, like photographs, because it cannot capture the fine detail and texture of real-world scenes. VIDEO REPRESENTATION Videos are a series of images (frames) shown sequentially (one after another);  Thus, video data representation is basically the representation of images changed with time;  Video files are multimedia files (also include audio track).

VIDEO CODING

Video coding refers to the process of representing and compressing video data for efficient storage and transmission;  Each frame can be treated as a bitmap or vector image, but storing every frame independently is inefficient;  The goal of video coding is to reduce redundancy (spatial and temporal) while maintaining acceptable quality.