Category : ML LAB

6. ASSUMING A SET OF DOCUMENTS THAT NEED TO BE CLASSIFIED, USE THE NAÏVE BAYESIAN CLASSIFIER MODEL TO PERFORM THIS TASK. BUILT-IN JAVA CLASSES/API CAN BE USED TO WRITE THE PROGRAM. CALCULATE THE ACCURACY, PRECISION, AND RECALL FOR YOUR DATA SET.  SOLUTION  NO DATASET FOR SOLUTION REQUIRES INTERNETlab6.py from sklearn.datasets import fetch_20newsgroupsfrom sklearn.metrics import confusion_matrixfrom sklearn.metrics import classification_reportimport ..

Read more

7. WRITE A PROGRAM TO CONSTRUCT A BAYESIAN NETWORK CONSIDERING MEDICAL DATA. USE THIS MODEL TO DEMONSTRATE THE DIAGNOSIS OF HEART PATIENTS USING STANDARD HEART DISEASE DATA SET. YOU CAN USE JAVA/PYTHON ML LIBRARY CLASSES/API. SOLUTION To execute the program first open a terminal and install packages “pgmpy” & “bayespy”in Terminal>>>pip install pgmpy>>>pip install bayespyheartdisease.csv SuperSeniorCitizen Male Yes ..

Read more

10. IMPLEMENT THE NON-PARAMETRIC LOCALLY WEIGHTED REGRESSIONALGORITHM IN ORDER TO FIT DATA POINTS. SELECT APPROPRIATE DATA SET FOR YOUR EXPERIMENT AND DRAW GRAPHS. SOLUTION NO DATASETlab10.pyfrom math import ceilimport numpy as npfrom scipy import linalgdef lowess(x, y, f, iterations):    n = len(x)    r = int(ceil(f * n))    h = [np.sort(np.abs(x – x[i]))[r] for i in ..

Read more

5. WRITE A PROGRAM TO IMPLEMENT THE NAÏVE BAYESIAN CLASSIFIER FOR A SAMPLE TRAINING DATA SET STORED AS A.CSV FILE. COMPUTE THE ACCURACY OF THE CLASSIFIER, CONSIDERING FEW TEST DATASETS. SOLUTION tennisdata.csv Outlook Temperature Humidity Windy PlayTennis Sunny Hot High FALSE No Sunny Hot High TRUE No Overcast Hot High FALSE Yes Rainy Mild High FALSE Yes Rainy ..

Read more

8. APPLY EM ALGORITHM TO CLUSTER A SET OF DATA STORED IN A.CSV FILE. USE THE SAME DATA SET FOR CLUSTERING USING K-MEANS ALGORITHM. COMPARE THE RESULTS OF THESE TWO ALGORITHMS AND COMMENT ON THE QUALITY OF CLUSTERING. YOU CAN ADD JAVA/PYTHON ML LIBRARY CLASSES/API IN THE PROGRAM.  SOLUTION  NO DATASET FOR SOLUTION  REQUIRES INTERNET lab8.pyfrom sklearn.cluster import KMeansfrom ..

Read more

9. WRITE A PROGRAM TO IMPLEMENT K-NEAREST NEIGHBOUR ALGORITHM TO CLASSIFY THE IRIS DATA SET. PRINT BOTH CORRECT AND WRONG PREDICTIONS. JAVA/PYTHON ML LIBRARY CLASSES CAN BE USED FOR THIS PROBLEM. SOLUTION 1  NO DATASET FOR SOLUTION 1  REQUIRES INTERNET lab9.pyfrom sklearn.datasets import load_irisfrom sklearn.neighbors import KNeighborsClassifierfrom sklearn.model_selection import train_test_splitimport numpy as np dataset=load_iris()X_train,X_test,y_train,y_test=train_test_split(dataset[“data”],dataset[“target”],random_state=0) kn=KNeighborsClassifier(n_neighbors=1)kn.fit(X_train,y_train) for i in range(len(X_test)):    x=X_test[i]  ..

Read more

2. FOR A GIVEN SET OF TRAINING DATA EXAMPLES STORED IN A .CSV FILE, IMPLEMENT AND DEMONSTRATE THE CANDIDATE-ELIMINATION ALGORITHM TO OUTPUT A DESCRIPTION OF THE SET OF ALL HYPOTHESES CONSISTENT WITH THE TRAINING EXAMPLES.SOLUTION  1 trainingdata.csv Sunny Warm Normal Strong Warm Same Yes Sunny Warm High Strong Warm Same Yes Rainy Cold High Strong Warm Change ..

Read more

3. WRITE A PROGRAM TO DEMONSTRATE THE WORKING OF THE DECISION TREE BASED ID3 ALGORITHM. USE AN APPROPRIATE DATA SET FOR BUILDING THE DECISION TREE AND APPLY THIS KNOWLEDGE TO CLASSIFY A NEW SAMPLE. SOLUTION 1  ( with packages) (given by Lokesh sir)tennisdata.csv Outlook Temperature Humidity Windy PlayTennis Sunny Hot High FALSE No Sunny Hot High TRUE ..

Read more

4. BUILD AN ARTIFICIAL NEURAL NETWORK BY IMPLEMENTING THE BACKPROPAGATION ALGORITHM AND TEST THE SAME USING APPROPRIATE DATASETS. SOLUTION NO DATASETlab4.pyimport numpy as npX = np.array(([2, 9], [1, 5], [3, 6]), dtype=float)y = np.array(([92], [86], [89]), dtype=float)X = X/np.amax(X, axis=0)y = y/100class Neural_Network(object):    def __init__(self):        self.inputSize = 2        self.outputSize = 1  ..

Read more

1. IMPLEMENT AND DEMONSTRATE THE FIND-S ALGORITHM FOR FINDING THE MOST SPECIFIC HYPOTHESIS BASED ON A GIVEN SET OF TRAINING DATA SAMPLES. READ THE TRAINING DATA FROM A.CSV FILE.SOLUTION  1 – To display only the final outputtrainingdata.csv Sunny Warm Normal Strong Warm Same Yes Sunny Warm High Strong Warm Same Yes Rainy Cold High Strong Warm ..

Read more