0% found this document useful (0 votes)
11 views

ML Lab Exp-5

Uploaded by

kishore5783
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

ML Lab Exp-5

Uploaded by

kishore5783
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

5.

The following training examples map descriptions of individuals onto high, medium
and low credit-worthiness.
medium skiing design single twenties no -> high Risk high golf trading married forties
yes ->low Risk low speedwaytransport married thirties yes -> med Risk medium football
banking single thirties yes -> low Risk high flying media married fifties yes ->high Risk
low football security single twenties no -> med Risk medium golf media single thirties
yes -> med Risk medium golf transport married forties yes -> low Risk high skiing
banking single thirties yes -> high Risk low golf unemployed married forties yes ->high
Risk

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 `med Risk' in the dataset?
Implement linear regression using python.

from sklearn.cluster import KMeans

import numpy as np

# Define the dataset

X = np.array([

[1.713, 1.586], [0.180, 1.786], [0.353, 1.240],

[0.940, 1.566], [1.486, 0.759], [1.266, 1.106],

[1.540, 0.419], [0.459, 1.799], [0.773, 0.186]

])

y = np.array([0, 1, 1, 0, 1, 0, 1, 1, 1])

# Fit KMeans model

kmeans = KMeans(n_clusters=3, random_state=0).fit(X)

# Print input data

print("The input data is ")

print("VAR1 \t VAR2 \t CLASS")

for i, val in enumerate(X):


print(val[0], "\t", val[1], "\t", y[i])

print("="*20)

# Get test data from the user

print("The Test data to predict ")

VAR1 = float(input("Enter Value for VAR1: "))

VAR2 = float(input("Enter Value for VAR2: "))

test_data = [VAR1, VAR2]

print("="*20)

# Predict the class for the test data

predicted_class = kmeans.predict([test_data])

print("The predicted Class is:", predicted_class[0])

OUTPUT:

The input data is

VAR1 VAR2 CLASS

1.713 1.586 0

0.18 1.786 1

0.353 1.24 1

0.94 1.566 0

1.486 0.759 1

1.266 1.106 0

1.54 0.419 1

0.459 1.799 1

0.773 0.186 1

====================

The Test data to predict


Enter Value for VAR1: 1.5

Enter Value for VAR2: 1.7

====================

The predicted Class is: 1

You might also like