Select your font size 
 
about us products & services consulting & support news & events contact us
Paul Meagher shows how to use a database query to calculate conditional probability.

Conditional Probability and SQL - Quebec

print this article 
 

P(A | B) can be mapped onto database-query operations. For example, the probability of cancer given a positive test result, P(+cancer | +test), can be obtained by issuing this SQL query then doing some tallies on the result set like this:

SELECT cancer_status FROM Data WHERE test_status='+test'

If I gather information about how several boolean-valued tests co-vary with a boolean-valued diagnosis (like that of cancer or not cancer), then I can perform slightly more complex queries to study how diagnostically useful other factors are in determining whether a patient has cancer, such as in the following:

SELECT cancer_status FROM Data WHERE genetic_status='+' AND age_status='+' AND biopsy_status='+'

In the case of detecting e-mail spam, I might be interested in computing P(+spam | title_word='viagra' AND title_word='free'), which could be viewed as a directive to issue the following SQL query:

SELECT spam_status FROM Emails WHERE email_title LIKE 'viagra' AND email_title LIKE 'free' 

After enumerating the number of e-mails that are spam and have "viagra" and "free" in the title (like so):

count_emails(spam_status='+spam' AND email_title LIKE 'viagra' AND email_title LIKE 'free')

and dividing by the overall number of e-mails with the words "viagra" and "free" in the title:

count_emails(email_title LIKE 'viagra' AND email_title LIKE 'free')

I might arrive at the conclusion that the appearence of these words in the title strongly and specifically co-varies with the message being spam (after all, 18/18 = 100 percent) and this rule might be used to automatically filter such messages.

In Bayes spam filtering, you need to initially train the software in which e-mails are spam and which are not. One can imagine storing spam_status information with each e-mail record (for example, email_id, spam_status, email_title, or email_message) and doing the previous queries and counts on this data to decide whether to forward a new e-mail into your inbox.



Page:   1  2  3  4  5  6  7  8  9  10  11 Next Page: Frequency versus probability format

The content shown in this page was first published by IBM developerWorks and is reprinted with permission from Paul Meagher (www.datavore.com)


Most Recent Website and Regional Updates

 Research Tools
Measure human resource allocation and collect data with the goal of determining patterns that will bring forward actionable insights which may lead to policy changes, saving money and improving quality of service.

 
 Process Evaluation Questions
Questions to help focus discussion about process improvement

 
 Operations Research
Operations Research (frequently called OR), is the methodical study of how to do things better. It is also called Optimization Theory.

 
 Our Role in Operations Optimization
Meet objectives more efficiently by improving operational effectiveness and profitability.

 
 Monte Carlo Method
Short description of the Monte Carlo Method in optimization theory.

 
 Introduction to Markov Process
Introduction to Markov Chains and Markov Processes, with a link to an introductory PDF which provides essential details about Markov analysis, along with helpful examples and exercises.

 
 Windows PC Tech Support Price Calculator
Transparen offers first-class Windows PC and Linux PC tech support services based on a number of factors such as a count of supported desktops.

 
 21/11/2008: Somali Pirates
Earlier this week, a giant Saudi oil tanker became the largest vessel ever hijacked by pirates operating with near impunity off the coast of Somalia. Today on the Current podcast, we'll have an interview with the head of one of the pirate groups operating in the area.

 
 20/11/2008: Juice Box Investigation
How a tainted juice box led one family on a convoluted quest for answers about their children's health.

 
 19/11/2008: Intimidation by Pharmaceutical Companies
Doctors sometimes discover that the drugs they're prescribing can be more harmful to some of their patients than the diseases they treat. But as CBC Radio health reporter Pauline Dakin tells the Current, some doctors say they've been intimidated by pharmaceutical companies into keeping their suspicions and their research quiet.

 

Google
 
Web transparen.com

Contact Information

Related Information

 
   
 
E C M | © 2003-2007 Transparen Corp.      

Standardized Services: Data Recovery Service / Creative Services / Premium Web Hosting Services / System Administration Tech Support Services
Recent Projects: Full-Service Mortgage and Financing Company / System to manage flights from Vancouver to Tofino / Photo exchange verification service
Our Vancouver BC Server Proudly Hosts: automated parking and revenue control systems, leafside lane at southlands, cost effective alternative power sources, Higher Grade Learning Centres, pacific forage bag supply, sunburst medical, neosonic design, roger mahler photography - passionate, intriguing, desirable, the connection between east and west, affordable flights to victoria and tofino, low interest mortgage brokers in vancouver, richmond, surrey, toronto, Toronto Calgary and Vancouver IT staffing and talent search
* Acton Vale * Alma * Amos * Amqui * Asbestos * Baie-Comeau * Baie-Saint-Paul * Barkmere * Beauceville * Beauharnois * Beaupré * Bécancour * Bedford * Belleterre * Beloeil * Berthierville * Blainville * Boisbriand * Bois-de-Filion * Bonaventure * Bromont * Brownsburg-Chatham * Cabano * Candiac * Cap-Chat * Cap-Santé * Carignan * Carleton-Saint-Omer * Causapscal * Chambly * Chandler * Chapais * Charlemagne * Châteauguay * Château-Richer * Chibougamau * Clermont * Coaticook * Contrecoeur * Cookshire-Eaton * Cowansville * Danville * Daveluyville * Dégelis * Delson * Desbiens * Deux-Montagnes * Disraeli * Dolbeau-Mistassini * Donnacona * Drummondville * Dunham * Duparquet * East Angus * Farnham * Fermont * Forestville * Fossambault-sur-le-Lac * Gaspé * Gatineau * Gracefield * Granby * Grande-Rivière * Hudson * Huntingdon * Joliette * Kingsey Falls * Lac-Brome * Lac-Delage * Lachute * Lac-Mégantic * Lac-Saint-Joseph * Lac-Sergent * La Malbaie * La Pocatière * La Prairie * La Sarre * L'Assomption * La Tuque * Laval * Lavaltrie * Lebel-sur-Quévillon * L'Épiphanie * Léry * Lévis * L'Île-Cadieux * L'Île-Perrot * Longueuil * Lorraine * Louiseville * Magog * Malartic * Maniwaki * Marieville * Mascouche * Matagami * Matane * Mercier * Métabetchouan- Lac-à-la-Croix * Métis-sur-Mer * Mirabel * Mont-Joli * Mont-Laurier * Montmagny * Montreal - largest city * Mont-Saint-Hilaire * Mont-Tremblant * Murdochville * Neuville * New Richmond * Nicolet * Normandin * Notre-Dame-de-l'Île-Perrot * Notre-Dame-du-Lac * Otterburn Park * Paspébiac * Percé * Pincourt * Plessisville * Pohénégamook * Port-Cartier * Pont-Rouge * Portneuf * Prévost * Princeville * Quebec - provincial capital * Repentigny * Richelieu * Richmond * Rimouski * Rivière-du-Loup * Rivière-Rouge * Roberval * Rosemère * Rouyn-Noranda * Saguenay * Saint-Basile * Saint-Basile-le-Grand * Saint-Césaire * Saint-Constant * Sainte-Adèle * Sainte-Agathe-des-Monts * Sainte-Anne-de-Beaupré * Sainte-Anne-des-Monts * Sainte-Anne-des-Plaines * Sainte-Catherine * Sainte-Catherine-de- la-Jacques-Cartier * Sainte-Julie * Sainte-Marguerite-Estérel * Sainte-Marie * Sainte-Marthe-sur-le-Lac * Sainte-Thérèse * Saint-Eustache * Saint-Félicien * Saint-Gabriel * Saint-Georges * Saint-Hyacinthe * Saint-Jean-sur-Richelieu * Saint-Jérôme * Saint-Joseph-de-Beauce * Saint-Joseph-de-Sorel * Saint-Lazare * Saint-Lin-Laurentides * Saint-Marc-des-Carrières * Saint-Ours * Saint-Pamphile * Saint-Pascal * Saint-Pie * Saint-Raymond * Saint-Rémi * Saint-Sauveur * Saint-Tite * Salaberry-de-Valleyfield * Schefferville * Scotstown * Senneterre * Sept-Îles * Shawinigan * Sherbrooke * Sorel-Tracy * Stanstead * Sutton * Témiscaming * Terrebonne * Thetford Mines * Thurso * Trois-Pistoles * Trois-Rivières * Valcourt * Val-d'Or * Varennes * Vaudreuil-Dorion * Victoriaville * Ville-Marie * Warwick * Waterloo * Waterville * Windsor