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 - BC

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

 Transparen Toronto Office Locations
Addresses of Transparen Corporation offices in Toronto, Ontario.

 
 High Scalability - Large Systems Optimization
Transparen Corporation lends its expertise to clients experiencing rapid and sudden growth in traffic or server utilization, bottlenecks, systems instability, downtime during peak traffic, or which would like to plan to avoid such issues.

 
 Throughput (or Bandwidth) vs. Latency
This document uses the example of Bill Gates purchasing Google to explain the difference between bandwidth (or throughput) and latency.

 
 Emergency Management Services
The prototypical emergency involves a shutdown of essential services for a finite period of time. What will your organization do when a world-wide financial crisis strikes?

 
 Fast RAID Server Data Recovery Service
Transparen's Vancouver International Response Team provides the option in Canada and USA to get a raid server back running in hours - eliminating costly waiting associated with typical RAID recoveries.

 
 Data Recovery Service
Have you deleted a mission critical file? Accidentally dropped a computer, or formatted a hard drive? No recent backup? Mistakes can happen, but the data might still be there.

 
 About Transparen
Transparen is committed to serving its clients.

 
 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

 
 COMMUNITY TRUST EMPLOYS FOREST WORKERS IN HOUSTON
VICTORIA ? The Community Development Trust?s Job Opportunities Program is funding the clearing of mountain pine beetle trees in recreation sites near Houston and using the wood to build picnic tables, shelters and board walks, Community Development Minister Blair Lekstrom and Bulkley Valley-Stikine MLA Dennis MacKAY announced.

 
 COMMUNITY TRUST EMPLOYS FOREST WORKERS IN SLIAMMON
SLIAMMON ? Ten forest workers are improving silviculture conditions on two forestry blocks near Powell River as a result of $74,000 in funding through the Job Opportunities Program, Community Development Minister Blair Lekstrom and Forests and Range Minister Pat Bell announced.

 
 COMMUNITY TRUST IMPROVING MCBRIDE'S RECREATION OPTIONS
MCBRIDE ? Funding from the Community Development Trust?s Job Opportunities Program is improving McBride?s winter sports and year-round trail network, Community Development Minister Blair Lekstrom and Prince George-Mount Robson MLA and Deputy Premier Shirley Bond announced.

 
 2008: A GROUNDBREAKING YEAR FOR BRITISH COLUMBIA
2008 will go down as a memorable year for British Columbia.

 
 FILM INCENTIVE BC TAX CREDIT CHANGE TO BENEFIT INDUSTRY
VICTORIA ? The Province intends to change the Film Incentive BC tax credit to further support the industry and encourage investment in B.C., announced Finance Minister Colin Hansen.

 
 COMMUNITY TRUST IMPROVING RECREATION IN GRAND FORKS
VICTORIA ? More than $330,000 from the Community Development Trust?s Job Opportunities Program is improving walking and cycling trails in Grand Forks and contributing to the management of beetle-affected stands in the area, Community Development Minister Blair Lekstrom and Forests and Range Minister Pat Bell announced.

 
 $11.5 MILLION TO EXPAND MARKETS FOR B.C. WOOD PRODUCTS
VICTORIA ? Forestry Innovation Investment Ltd. has released its annual call for proposals to boost demand for B.C. wood products in Asia-Pacific and other key markets, Forests and Range Minister Pat Bell announced.

 
 08/01/2009: How to Divorce and Not Wreck the Kids
For years, divorce has pitted couples against each other, fueling conflict and concerns about the children caught in the middle of it. Now, unhappy couples with children are looking for ways to end their marriage, but not end the family. Today on the podast, we'll hear from a couple trying to do that and the director of a CBC TV documentary called "How To Divorce and Not Wreck The Kids".

 
 07/01/2009: A Death in the Family - Documentary
Today on the podcast, the story of Paul Johnson and Bill Mullins-Johnson, two brothers from Sault Saint Marie, Ontario whose lives were torn apart after the murder of Paul's four-year-old daughter ... a crime that turned the two men against each other even though neither of them had committed it.

 
 06/01/2009: The Threatening Sea
Today on the podcast, we continue our Watershed series with a trip to Vanuatu, a nation of 83 islands in the South Pacific that is slowly but surely sinking into the sea.

 
 05/01/2009: Australia Drought
Dispatches from The Big Dry. Current producer Kathleen Goldhar brings us a report from Australia's enduring drought and the economy it's spawned, where rainless communities unravel, only the adaptable prosper and water is the new gold standard.

 
 02/02/2009: Economy Panel - 2009 Forecast
With the annus horibilis of 2008 in the rear view mirror, and 2009 lying in the wait, The Current organized an economy panel to give us their forecast for the new year.

 

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
* Burnaby (City) * Campbell River (Town) * Chilliwack (City) * Comox (City) * Coquitlam * Cranbrook (City) * Delta (City) * Duncan (City) * Grand Forks (City) * Hope (Town) * Kamloops (City) * Kelowna (City) * Ladysmith (Town) * Langley (City) * Mission (City) * Nanaimo (City) * Nelson (City) * New Westminster (City) * North Vancouver (City) * Penticton (City) * Port Alberni * Prince George (City) * Prince Rupert (City) * Quesnel (City) * Saanich (City) * Sidney (City) * Sooke (City) * Steveston (City of Richmond) * Surrey (City) * Tofino * Ucluelet * Vancouver (City) * Vernon (City) * Victoria (City) * West Vancouver (City) * Whistler * White Rock