Menu


Notice: Undefined index: alg in /home/u681245571/domains/studyglance.in/public_html/labprograms/mldisplay.php on line 81

Notice: Undefined index: url2 in /home/u681245571/domains/studyglance.in/public_html/labprograms/mldisplay.php on line 83

Notice: Undefined index: url3 in /home/u681245571/domains/studyglance.in/public_html/labprograms/mldisplay.php on line 84

Notice: Undefined index: url4 in /home/u681245571/domains/studyglance.in/public_html/labprograms/mldisplay.php on line 85

Notice: Undefined index: title in /home/u681245571/domains/studyglance.in/public_html/labprograms/mldisplay.php on line 86

Notice: Undefined index: opurl2 in /home/u681245571/domains/studyglance.in/public_html/labprograms/mldisplay.php on line 88

Notice: Undefined index: opurl3 in /home/u681245571/domains/studyglance.in/public_html/labprograms/mldisplay.php on line 89

Notice: Undefined index: opurl4 in /home/u681245571/domains/studyglance.in/public_html/labprograms/mldisplay.php on line 90

Machine Learning - Lab Programs


Aim:

Source Code:

Week5.py

'''Aim:The following training examples map descriptions of individuals onto high, medium and low credit-worthiness.

medium skiing design single twenties no -> highRisk
high golf trading married forties yes -> lowRisk
low speedway transport married thirties yes -> medRisk
medium football banking single thirties yes -> lowRisk
high flying media married fifties yes -> highRisk
low football security single twenties no -> medRisk
medium golf media single thirties yes -> medRisk
medium golf transport married forties yes -> lowRisk
high skiing banking single thirties yes -> highRisk
low golf unemployed married forties yes -> highRisk

Input attributes are (from left to right) income, recreation, job, status, age-group, home-owner. Find the unconditional probability of 'golf' and the conditional probability of 'single' given 'medRisk' in the dataset

=================================
Explanation:
=================================

In the given data set,

----> The total number of records are 10.

----> The number of records which contains 'golf' are 4.

----> Then, the Unconditional probability of golf :

			=  The number of records which contains 'golf' / total number of records
			= 4 / 10 
			= 0.4

******************************

To find the Conditional probability of single given medRisk,

---> S : single
---> MR : medRisk

---> By the definition of Baye's rule( conditional probability ), we have

	P(S ∣ MR) = P(S ∩ MR) / P(MR)

	Based on the given problem statement,

    P(S ∩ MR) = The number of MedRisk with Single records / total number of Records
			  = 2 / 10 = 0.2
    and

    P(MR) = The number of records with MedRisk /total number of Records
		  = 3 / 10 = 0.3
	
	Then, the Conditional probability of single given medRisk

	P(S ∣ MR) = 0.2 / 0.3
			  = 0.66666

===============================
Source Code :
===============================
'''
total_Records=10
numGolfRecords=4
unConditionalprobGolf=numGolfRecords / total_Records
print("Unconditional probability of golf: ={}".format(unConditionalprobGolf)) 
#conditional probability of 'single' given 'medRisk'
numMedRiskSingle=2
numMedRisk=3
probMedRiskSingle=numMedRiskSingle/total_Records
probMedRisk=numMedRisk/total_Records
conditionalProb=(probMedRiskSingle/probMedRisk)
print("Conditional probability of single given medRisk: = {}".format(conditionalProb))

Output:

image

Related Content :

Machine Learning Lab Programs

1) The probability that it is Friday and that a student is absent is 3%. Since there are 5 school days in a week, the probability that it is Friday is 20%. What is theprobability that a student is absent given that today is Friday? Apply Baye’s rule in python to get the result.(Ans: 15%) View Solution

2) Extract the data from database using python View Solution

3) Implement k-nearest neighbours classification using python View Solution

4) Given the following data, which specify classifications for nine ombinations of VAR1 and VAR2 predict a classification for a case where VAR1=0.906 and VAR2=0.606, using the result of k-means clustering with 3 means (i.e., 3 centroids) View Solution

5) The following training examples map descriptions of individuals onto high, medium and low credit-worthiness.Input attributes are (from left to right) income, recreation, job, status, age-group, home-owner. Find the unconditional probability of 'golf' and the conditional probability of 'single' given 'medRisk' in the dataset View Solution

6) Implement linear regression using python View Solution

7) Implement naive baye's theorem to classify the English text View Solution

8) Implement an algorithm to demonstrate the significance of genetic algorithm View Solution

9) Implement the finite words classification system using Back-propagation algorithm View Solution




Suggestion/Feedback Form :




Excellent  Very Good  Good  Average  Poor


This is a Compliment
This is a Suggestion for improvement
This is Feedback
This is Grievance