



































Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!




































What is statistics? Statistics is the science concerned with the collection, analysis, interpretation, and presentation of data. Its purpose: To transform raw data (numbers, categories) into useful information for making decisions under uncertainty. Its nature: It is based on mathematics, specifically probability theory, to quantify the uncertainty and variability of the real world. Historically, statistics is divided into two broad areas:
-Continuous: Measurable values within a range (e.g., height, weight, temperature). Fundamental Summary Statistics In descriptive statistics, we summarize data using two types of measures:
Y-Axis: Dependent variable (Quantitative variable). What does it allow us to see? The behavior and distribution of a quantitative variable across different categories. 25/ What is Machine Learning? Classic Definition (Arthur Samuel, 1959): ”The field of study that gives computers the ability to learn without being explicitly programmed.” Instead of writing rigid rules (if- then-else), we provide the computer with historical data and expected outcomes. The algorithm autonomously ”learns” the rules from the data. Main Objective: To generalize from experience in order to make accurate predictions on future, unseen data. Both Machine Learning (ML) and Statistics work with data to extract knowledge, but they stem from different disciplines and philosophies: Statistics: Born from Mathematics. Its primary focus is Inference, meaning understanding the data and explaining the relationships between variables. Machine Learning: Born from Computer Science and Artificial Intelligence. Its primary focus is Prediction, meaning achieving practical and highly accurate results. Difference 1: the objective Statistics: ”The Why” Explains the mechanism that generated the data. Assesses the impact and significance of every single variable. Ex: To what extent do square footage and location influence a house’s price? Machine Learning: ”The What” Builds a model to make perfect predictions. The model can be a ”black-box”, as long as it performs well. Ex: What will be the exact market price of this specific house? Difference 2: the approach to data Statistical Models: Make strong a priori assumptions about the data (e.g., the distribution must be normal, variables must be independent). If the data does not meet these assumptions, the model loses validity. ML Algorithms: Make very few mathematical assumptions. They adapt to the inherent structure of the data and are designed to handle Big Data and highly complex or non-linear relationships, where traditional statistical models struggle.
The aim of cluster analysis is to identify groups (clusters) of points that are as homogeneous as possible within themselves and different from each other. Obviously, the homogeneity/heterogeneity of the groups needs to be assessed against a set of characteristics (variables). Note that the number of groups is not known a priori. Supervised learning The dependent variable (Y) stands above The independent variable (X) is used to understand the variable Y Unsupervised learning Y variable doesn’t exist Goal is to understand something All the variables at the same level This is where we do clustering - clustering is: there is a group that behaves in a similar way - Taking the data and understand, how can I split the data in cluster, try to identify groups, that behave inside the group similar, we don’t know how many groups there are Within the framework of cluster analysis, three types of techniques can be distinguished: 1 Hard clustering : we partition the initial n elements into k groups; Partition: divide, a set of statistical units - divide into sub sets, each element in a subset belongs to one subset only, any pair of subset is a no set, no common individuals, Union: all subsets together No overlapping in clusters, so no uncertainties its either 1 or 0 2 Soft clustering: clumping (or overlapping clustering): each of the n elements is assigned a number indicating the degree to which it belongs to a given group (1, 0, 0.5: belongs, does not belong, belongs also to another group or groups).;
To be concerned about is to minimise the eternal inertia or maximise the external inertia Barycentre; g = General barycentre: mean, something that stands in the middle, tell me what on average ppl do K group centres: Point mass: Group mass: II norm of a vactor x1-g Inertia: Within + between K describes the different Groups mi= mass of each point, ist die gewichtung xi= is a single grade g= gK= very center of each group, point that stands in the middle, its the mean is the barycentre Inertia= is about the distance between each point and the barycentre, compute the distance between each point and the barycentre, its a measure that tells you how distant all the points are from the common centre, is the variance in a multidimensional space Overall inertia = deviance. Take each grade, subtract the general barycentre, square, do it with every grade 28- 28.8 square - do with every number Within Inertia: within each group is for example Quantitative inertia, economic inertia, law inertia; tell me how consistently a thing is, Overall within ineratia= all inertia within summed up Summing up within inertia will not give you the general inertia Between inertia = tells me how different the groups are, to compute is I take a representative of each group the within barycentre , subtract the general centre - square it - multiple the amount of single courses Tells me how separated the groups are T = General inertia is fixed W and B is flexible - One increased the other one decreases and vice versa Those lie on the groups and if I change that it varies, you change the grouping, the number of allocation to the groups then I am altering the allocation between the within inertia and the between inertia If i increase the number of groups - if I have 20 groups with only one value/variable - within inertia is 0 Using clustering you don’t know the amount of groups and what belongs to the group
Minimise the within inertia - the between inertia is maximised Individuals and variable Multidimensional data = using more than one elements / components Standartising = you can compare easier - gleiche Vergleichsbasis Barycentres = general is both (time and grade) 0 - because multidimensional space Each point is described by a pair values
Tool: Concept of distance Distance is a function: This definition is very general and fails to explain how to calculate the distance between two points. Distance is a function that makes R(high 6) to R but it has to have some properties Properties that must be satisfied for it : #1 The number must be positive or 0 #2 symmetry: the distance between A and B must be the same as prom B to A – #3 meaning the distance between A & B is 0 B & A is the same #4 The distance of A and B less than or equal to the sum of A & C + B & C Depending on the nature of the variables: All Numerical variables: could compute the minkowski distance - xi is a point, here 2 points - xis= one point, the s goes from one to p, - Landa we have to choose, normally 1 or 2 (xi-xi)^2 „do this for all the columns and then sum them P is the end of all the variables (maximum of variables you have)
Mahalanobis-> takes into account the correlation of the variables Lambda equal to 1 = Manhattan distance When to use: Lots of outliers Lambda equal to 2 = euclidean distance When to use: If you don’t have much outliers
a first partition is determined in which each individual belongs to the group for which the distance to the provisional centre is minimum; the internal inertia (which we call V(0)) is calculated, considering as barycentres the K provisional centres; we recalculate the new barycentres gk(0); the internal inertia W(0) is recalculated; step 1: we reallocate the individuals so that the distance from each barycentre found in step 0 (gk(0)) is minimum; the internal inertia (which we call V(1)) is calculated taking the centre of gravity (gk(0)) as the centre of gravity; we calculate the new barycentre (gk(1)); the internal inertia W(1) is recalculated; The next steps 2,3···t are obtained by repeating the steps illustrated in step 1. The process stops when W(t) −V(t) = 0 or when W(t)−V(t) < τ, where τ is a threshold value. The sense is that the algorithm ends, when no more individuals (or only a few) move from one group to another and therefore thus the internal variance does not change (or changes little). The more you repeat the process, the algorithm will converge and the barycenter will stabilize, I wouldn’t have to change the partition of the points The K means algorithm The most widely used non-hierarchical algorithm is the K-means algorithm, which was developed by MacQueen in 1967. The K-means algorithm differs from Forgy’s in that the calculation of the new barycentre is carried out immediately after the reallocation of individuals to the new group. One of the key advantages of the K-means algorithm is its ability to converge much more rapidly than Forgy’s algorithm. The drawback of non-hierarchical methods is that the number of groups to be formed is chosen at the beginning by the researcher and cannot be altered.
The Mcqueen algorithm is faster because it doesn’t compute on the old barycenter the new inertia, but it directly uses the new one Double computing of the new inertia makes things slower (and it’s harder when you have lots of data, no waste of time, that’s way the Mcqueen algorithm was proposed) Clustering it’s about grouping elements but we don’t know how many groups, I have to decide at the beginning how many groups I want (disadvantage) Non hierarchical methods are faster and work better with lots of data (advantage) Hierarchical methods One of the defining characteristics of such algorithms is that they produce a hierarchical partitioning of data in the form of a tree structure. This addresses the limitation of non-hierarchical methods, whereby the number of groups is predetermined, rather than being determined at the end of the analysis. There are two main types of hierarchical algorithms: (we won’t focus on the splitting) 1 Agglomerative (or ascending) algorithms 2 Splitting (or descending) algorithms The agglomerative methods can be further divided into the following categories: 1 The basic agglomerative methods involve one aggregation at a time. 2 The simultaneous agglomerative methods involve several aggregations at a time (not covered in the course). Basic agglomerative methods The following is a step-by-step guide to the operation of a basic aggregative algorithm: 1 the two individuals (referred to as p and q) with the shortest distances between them are aggregated to form the first cluster (h); 2 we define the criterion with which to calculate the distance between h1 and the remaining n − 2 individuals; 3 aggregates h with the least distant individual (say r); 4 we iterate the process by repeating steps 2 and 3 until all the individuals have been aggregated. The method used to calculate the distance between two objects is a defining feature of this type of algorithm.
Compute the distances between each possible pair Find which pair is most similar (choose the smallest one, it means that they are the closest) The closest will stop being individuals and will aggregate to form a new cluster Compute a new distance matrix with the individuals remaining Problem: distance between the individuals and the cluster-> there are several proposals: minimum, maximum, average When I obtain my new matrix, the process will start again 17/ Dendrogram and groups number We can represent the entire agglomeration process in a graph (dendrogram): Shows me how the algorithm worked all over the way, shows how the merging occurred X=individuals (ex: Regions) Y=index, a number that tells me at what level the individuals merge together Horizontal segment= converge into a cluster The within variance approaches the overall variance moving upwards the Y axis Within variance= close to zero= variability within the cluster is low, individuals behave similar, within variance should be low Increase in the within variance is contained, at some point it explodes, so cut it before the within variance explodes The five individuals are represented on the horizontal axis, while the vertical axis depicts an index denoting the distances at which the aggregation occurs. The newly formed individuals resulting from the aggregation process are located within the tree. What methodology should be employed to determine the optimal number of final clusters? In general, the objective is to identify the partition that is characterized by the fewest number of clusters with the highest degree of internal homogeneity. These
two requirements are mutually exclusive: if the objective is to minimize the number of groups, the nodes at the top of the tree will be removed; conversely, if the aim is to maximize internal homogeneity, the nodes at the bottom will be removed. A statistical criterion that could be employed is to select the number of groups for which the index jump is at its maximum. As illustrated in the figure above, if we go from 1 group to 2 groups, the index exhibits a variation of 9 − 4 = 5. If we proceed from 2 to 3 groups, the index varies by 4 − 2 = 2. If we go from 3 to 4 groups, the index varies by 2 − 1 =
If we did not use any information on the characteristics of the client (i.e. Savings, Wealth and Annual Income), we would conclude that the best decision rule (in the sense of the one that reduces the probability of misclassifying a new client) corresponds to Low. In fact, 5/8 clients in the sample at our disposal represent this mode. If this is the decision rule (associates each new customer with a Low credit risk), then the probability of misclassification is 3/8 and the misclassification rate is 37.5%. Now we use covariates to improve our prediction. We use Wealth (without explaining why for the moment) and divide our statistical units into two groups: those with low wealth and those with medium or high wealth. With this partition induced by the use of the variable Wealth, we obtain the following two groups Group 1: Clients B, G with 100 per cent High Credit Risk Group 2: Clients A, C, D, E, F with 83.5 per cent of Low Credit Risk
The decision rule adopted (separates clients with low Wealth from the others and classifies those with low Wealth as having High risk and others as having Low risk) has the following misclassification rate: hence, the misclassification rate is 16.7 per cent. This means that using the Wealth information, we reduced the misclassification rate by about 20 percentage points. We now use the information on Savings and split those with high savings from the others (we still say nothing about how we made this decision). The tree becomes: The last step of the algorithm takes wealth into account and separates statistical units with medium or low wealth from those with high wealth: