Chessboard distance or Minkowski distance

Consider two objects and describe by 10 features and write a c-program to compute Lr distance by the varying the “r-value”.

The C-program automatically reads the 10 random number and the value of r going to increment automatically up to 50. Our infinity value is set to 50, can be changed to the desired value. the r-value is 1 then it is called the city-block distance, if the value of r is 2 then it is called Euclidean distance and if the value of r is infinity then it is called as a chessboard or Lr distance, supremum distance (also referred to as Lmax, L norm and as the Chebyshev distance) is a generalization of the Minkowski distance for L → ∞.

The C-program automatically reads the 10 random number and the value of r going to increment automatically up to 50. Our infinity value is set to 50, can be changed to the desired value.

The c-program is as follows:



#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<float.h>
int main()
{
    long int i,j,r,max,a[10],b[10];
    double c[10],sum;
    float k;

    printf("reading\n\n    object1\t object2\n");

    for (i=0;i<10;i++)
    {
        a[i] = rand() % 10 + 1;
        b[i] = rand() % 15 + 3;
        printf("\t%d\t %d\n ",a[i],b[i]);
    }

    c[0]=abs(a[0]-b[0]);
    max = c[0];
//    printf("max is %d\n",c[0]);

    printf("the absolute values of each differences \n");

    for (i=0;i<10;i++)
    {
        c[i]=abs(a[i]-b[i]);
        printf("%.f\n",c[i]);
        if (c[i]>max)
            max=c[i];
    }
    printf( "\nmaximum value is %d\n\n\n" , max );

    for ( r=1;r<=50;r++)
    {
        sum = 0;
        for (i=0;i<10;i++)
        {
            sum += pow(c[i],r);
        }
        k = (float) 1 / (float)r;
        c[i] =  pow(sum,k);
        printf("%.2f\t%.f\t%d %f\n", k,sum,r,c[i]);
    }
    c[r+1]=max;
    printf("\n%ld\t%f\n",r,c[r+1]);
    return 0;
}


 Output:

Fig: Output up to first 16 values
Fig: Output values from 17 to 51

Academic students can ask me their queries related to projects and assignments using the comment section.

Feature evaluation: Unsupervised model and supervised model

Unsupervised model

Here,
  • Variance can be used as evaluation criteria.
  • The maximum variance ranked first.
  • Descending order sorting of variances.
Fig: Unsupervised feature selection model.

Rank the features based on variance and chose top "d" features.
This is called unsupervised feature selection or elimination model. 

Supervised model: 

Fig: Supervised feature selection model.

Equation: Mean.

Fig: Mean of individual classes.
Here,
Fig: ICV < BCV.
  • The minimum variance ranked first.
  • Ascending order sorting of variance.

    Compute:

    Intra class variance (ICV)/within class variance:


    Inter class variance/between class variance(BCV):

    Ration from BCV to ICV is high.
    Fig: Ratio from BCV to ICV.
    Chose the one feature with the highest rank as first. 
    This is called as Ward's or Fisher's criterion.
    This is only for supervised learning.
    This is used in the Fisher's Linear Discriminant Analysis technique (FLD or LD) and feature transformation.
    Such a discriminating algorithm is called the Fisher's Linear Discrimination algorithm.
    Loosely coupled across the sample of the class. 

    Example:

    Read the below feature matrix. Calculate the variance sort them accordingly.
Object A, B, C, D, E, and F can be represented by using 8 features.
Table: Feature matrix

Solution:

Table: Solution to the problem stated above.
Ascending sorting of the variances: 
Table: Ascending sorting of variances.
The next topic is filters and wrapper methods. 
Subscribe, to get instant notification of updates.
Follow and don't forget to share.

Feature evaluation criteria

Feature sub-setting is through selection or elimination.


We look approximation algorithm:

  1. Feature evaluation criteria.
  2. Feature are ranked.
  3. Select top 'd' features.
1 and 2 could be independent of learning algorithm (unsupervised).
Example: Filtering algorithm (filters)/model.
Ex: Big data, independent of class label. Then it is called as unsupervised feature selection (classification).

1 and 2 could be dependent of learning algorithm (supervised).
Example: Wrapper algorithm (wrappers)/model.
Ex: Small data, class label/class information dependent. Then it is called as supervised feature selection (clustering).

Techniques of dimensionality reduction

Techniques of dimensionality reduction

Dimensionality reduction:-


Reducing the number of features keeping in mind the ability to discriminating each data object from the rest of the objects.

Given are "m" number of features (m relatively large) discriminating each "n" objects, the task is to re-describing "n" objects with d<<m (d is relatively smaller than m) number of features which may be some of those "m" features or may be new features computed using "m" features, such that desired (target) or task accomplished (classification, clustering) without loss of data generality.
  • Finding out d<<m
    • choosing some d out of m features (also called sub-setting or selection).
    • computed d from m (also called feature transformation).
Fig: Dimensionality reduction 1.


Feature sub-setting:-



Thanks for reading.
Subscribe and follow to get notification of my blog's updates.

Cluster validation

What is cluster validation?
A process of estimating the goodness of cluster formed. That is, to ensure how accurate the obtained results of clustering.

To understand the cluster validation, consider the below figure 1 example confusion matrix obtained by the process of classification (unsupervised learning) or clustering (supervised learning).

Figure 1: Example of the confusion matrix.
 Where,
The expected result of cluster 1: CE1. The expected result of cluster 2: CE2.
The expected result of cluster 3: CE3. The expected result of cluster 4: CE4.
Obtained result of cluster 1: CO1. Obtained result of cluster 2: CO2.
Obtained result of cluster 3: CO3. Obtained result of cluster 4: CO4.
Row: Indicates how many samples belong to a particular cluster?
Column: Indicates how many samples are placed in the cluster from which cluster?

Example: Arrangement of library books.

Calculating recall (recall ability) concerning:

Cluster C1:

Cluster C2:

Cluster C3:


Cluster C4:

Calculating average recall :
 
Calculating precision concerning:

Cluster C1:
Cluster C2:

Cluster C3:
Cluster C4:
Calculating average precision :

In the case of k clustering problem,





Both P and R are normalized.

Generally, we go when we need two cluster problems.

When the population is imbalanced accuracy does not hold good.

F-Measure is high only when P and R are high.

F-Measure is also called as Ff-Micro.

Note: It suits all classification & cluster recognition, segmentation, and suits for all research projects.

The title of the next topic that I'll upload is "Techniques of dimensionality reduction".

Follow and subscribe to my blog.

Thank you for reading this article.


Difference between sequential allocation and linked allocation


Sequential allocation

Linked allocation

Static in nature. Dynamic in nature.
Required to estimate the capacity of the structure. Not required.
All memory locations are consecutive in nature. Therefore computed addressing is possible. Need not be. It works based on pointer addressing.
Two logically adjacent elements are also physically adjacent. Not necessarily. Therefore each data element should hold the address of its next logically adjacent element. This can be a bottleneck problem.
Support direct accessing or addressing of data. Sequential addressing or accessing of data.
In a strict sense, deletion, and insertion operations are prohibited. Insertion and deletion operation is possible and is straight forward.
Splitting and merging operation is also prohibited. However, these can be realized by data movement with extra memory allocation. This can be sometimes a bottleneck problem. Possible and straight forward.
No such problem. Loss of address results with loss of the structure (tail end).