Giter Club home page Giter Club logo

dsc-bayes-theorem-lab-seattle-ds-102819's Introduction

Bayes' Theorem - Lab

Introduction

In this lab, you'll practice Bayes' Theorem in some simple word problems.

Objectives

In this lab you will be able to:

  • Use Bayes' theorem to determine the probability of specific events

Define a custom function for Bayes' theorem

To start, write a function, bayes(), which takes in the probability of A, the probability of B, and the probability of B given A. From this, the function should then return the conditional probability of A, given that B is true.

def bayes(P_a, P_b, P_b_given_a):
    # Your code here
    return P_a_given_b

Skin Cancer

After a physical exam, a doctor observes a blemish on a client's arm. The doctor is concerned that the blemish could be cancerous, but tells the patient to be calm and that it's probably benign. Of those with skin cancer, 100% have such blemishes. However, 20% of those without skin cancer also have such blemishes. If 15% of the population has skin cancer, what's the probability that this patient has skin cancer?

Hint: Be sure to calculate the overall rate of blemishes across the entire population.

# Your code here
0.46875

Children (I)

A couple has two children, the older of which is a boy. What is the probability that they have two boys?

# Your solution P(2boys|older child is a boy)
0.5

Children (II)

A couple has two children, one of which is a boy. What is the probability that they have two boys?

# Your solution P(2boys|1 of 2 children is a boy)
0.3333333333333333

A diagnostic test

A diagnostic test is advertised as being 99% accurate

  • If a patient has the disease, they will test positive 99% of the time

  • If they don't have the disease, they will test negative 99% of the time

  • 1% of all people have this disease

If a patient tests positive, what is the probability that they actually have the disease?

# Your solution P(Disease | positive test)
0.5

Summary

In this lab, you practiced a few simple examples of Bayesian logic and how you can add prior information to update your beliefs about the chance of events.

dsc-bayes-theorem-lab-seattle-ds-102819's People

Contributors

loredirick avatar mathymitchell avatar shakeelraja avatar sumedh10 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

yufenlin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.