Find-S algorithm

Find-S algorithm program in machine learning.

import pandas as pd

import numpy as np

data=pd.read_csv('finds.csv')


con=np.array(data.iloc[:,0:-1])

target=np.array(data.iloc[:,-1])

def train(con,target):

    for i,val in enumerate(target):
        if val=="Yes":
            spec=con[i]
            break
            
    for i,h in enumerate(con):
        if target[i]=="Yes":
            for x in range(len(spec)):
                if h[x]==spec[x]:
                    pass
                else:
                    spec[x]="?"
    return spec

print(train(con,target))

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

Data Sets->

Sky,Airtemp,Humidity,Wind,Water,Forecast,WaterSport
Sunny,Warm,Normal,Strong,Warm,Same,Yes
Sunny,Warm,High,Strong,Warm,Same,Yes
Cloudy,Cold,High,Strong,Warm,Change,No
Sunny,Warm,High,Strong,Cool,Change,Yes


Output->
['Sunny' 'Warm' '?' 'Strong' '?' '?']

Comments

Popular posts from this blog

How to set image in carousel using flask?

Invalid syntax , perhaps you forgot a comma? Error in Python

How to run PL/SQL Code With Command Line?