Wednesday 24 October 2012

Supervised vs Unsupervised learning (Data Mining)


 Supervised  vs Unsupervised learning

Machine learning algorithms are described as either 'supervised' or 'unsupervised'. The distinction is drawn from how the learner classifies data. In supervised algorithms, the classes are predetermined. These classes can be conceived of as a finite set, previously arrived at by a human. In practice, a certain segment of data will be labelled with these classifications. The machine learner's task is to search for patterns and construct mathematical models. These models then are evaluated on the basis of their predictive capacity in relation to measures of variance in the data itself. Many of the methods referenced in the documentation (decision tree induction, naive Bayes, etc) are examples of supervised learning techniques.
Unsupervised learners are not provided with classifications. In fact, the basic task of unsupervised learning is to develop classification labels automatically. Unsupervised algorithms seek out similarity between pieces of data in order to determine whether they can be characterized as forming a group. These groups are termed clusters, and there are a whole family of clustering machine learning techniques.
In unsupervised classification, often known as 'cluster analysis' the machine is not told how the texts are grouped. Its task is to arrive at some grouping of the data. In a very common of cluster analysis (K-means), the machine is told in advance how many clusters it should form -- a potentially difficult and arbitrary decision to make.
It is apparent from this minimal account that the machine has much less to go on in unsupervised classification. It has to start somewhere, and its algorithms try in iterative ways to reach a stable configuration that makes sense. The results vary widely and may be completely off if the first steps are wrong. On the other hand, cluster analysis has a much greater potential for surprising you. And it has considerable corroborative power if its internal comparisons of low-level linguistic phenomena lead to groupings that make sense at a higher interpretative level or that you had suspected but deliberately withheld from the machine. Thus cluster analysis is a very promising tool for the exploration of relationships among many texts.

Wednesday 26 September 2012

ACID properties of database


Atomicity
All changes to data are performed as if they are a single operation. That is, all the changes are performed, or none of them are.
For example, in an application that transfers funds from one account to another, the atomicity property ensures that, if a debit is made successfully from one account, the corresponding credit is made to the other account.
Consistency
Data is in a consistent state when a transaction starts and when it ends.
For example, in an application that transfers funds from one account to another, the consistency property ensures that the total value of funds in both the accounts is the same at the start and end of each transaction.
Isolation
The intermediate state of a transaction is invisible to other transactions. As a result, transactions that run concurrently appear to be serialized.
For example, in an application that transfers funds from one account to another, the isolation property ensures that another transaction sees the transferred funds in one account or the other, but not in both, nor in neither.
Durability
After a transaction successfully completes, changes to data persist and are not undone, even in the event of a system failure.
For example, in an application that transfers funds from one account to another, the durability property ensures that the changes made to each account will not be reversed.

DB2 vs MySql or Difference between DB2 and MySql

Tuesday 25 September 2012

Program to find 2's complement


void revert(char *str,char *comp,int l);

int main()
{
  int i,found=0,l,stlen;
  char *str,*comp;

  clrscr();

printf("\nEnter a binary string\n");
gets(str);
stlen=strlen(str);
l=stlen;
l--;
       // printf("\nlength=%d..%c..",l,str[l]);
while(l)
{
if(found)
{
revert(str,comp,l);
break;
}
else
{
if(str[l]=='1')
found=1;
comp[l]=str[l];
printf("%c",str[l]);
l--;
}
}
printf("\ncopmlement is");
puts(comp);

getch();
return(0);
}


void revert(char *str,char *comp,int l)
{
while(l>=0)
{
if(str[l]=='1')
{printf("0");comp[l--]='0' ;}
else
{printf("1");comp[l--]='1';}
}
}

Program to Conver Hexadecimal String to Decimal number



int main()
{
char *str;
clrscr();
printf("\nEnter a hexadecimal string\n");
gets(str);

printf("\nthe corresponding decimal value is %d",htoi(str));
getch();
return(0);
}

int power (int a, int b) // utility function
{
int res = 1 ;
while( b>0 )
{
res *= a ;
b--;
}
return ( res );
}

int htoi ( char* s )
{
int result = 0,new_result;
//int value =0;
int len = strlen(s);
int exp = len;
char c;
int i;

  for( i=0; i<len; i++)
   {

    c = s[i];

     if ( c >='1' && c<='9')
new_result = (int)( (c - '0') * power(16, exp-1) );

     else
if (c >='A' && c<='F')
  new_result = (int)( (c - 55) * power(16, exp-1) );

    exp --;
    result += new_result;

   }

return (result);
}