"candidate elimination algorithm python code" Code Answer's

You're definitely familiar with the best coding language CSS that developers use to develop their projects and they get all their queries like "candidate elimination algorithm python code" answered properly. Developers are finding an appropriate answer about candidate elimination algorithm python code related to the CSS coding language. By visiting this online portal developers get answers concerning CSS codes question like candidate elimination algorithm python code. Enter your desired code related query in the search bar and get every piece of information about CSS code related question on candidate elimination algorithm python code. 

candidate elimination algorithm python code

By Dangerous DuckDangerous Duck on Jan 25, 2021
import numpy as np 
import pandas as pd

data = pd.read_csv(path+'/enjoysport.csv')
concepts = np.array(data.iloc[:,0:-1])
print("\nInstances are:\n",concepts)
target = np.array(data.iloc[:,-1])
print("\nTarget Values are: ",target)

def learn(concepts, target): 
    specific_h = concepts[0].copy()
    print("\nInitialization of specific_h and genearal_h")
    print("\nSpecific Boundary: ", specific_h)
    general_h = [["?" for i in range(len(specific_h))] for i in range(len(specific_h))]
    print("\nGeneric Boundary: ",general_h)  

    for i, h in enumerate(concepts):
        print("\nInstance", i+1 , "is ", h)
        if target[i] == "yes":
            print("Instance is Positive ")
            for x in range(len(specific_h)): 
                if h[x]!= specific_h[x]:                    
                    specific_h[x] ='?'                     
                    general_h[x][x] ='?'
                   
        if target[i] == "no":            
            print("Instance is Negative ")
            for x in range(len(specific_h)): 
                if h[x]!= specific_h[x]:                    
                    general_h[x][x] = specific_h[x]                
                else:                    
                    general_h[x][x] = '?'        
        
        print("Specific Bundary after ", i+1, "Instance is ", specific_h)         
        print("Generic Boundary after ", i+1, "Instance is ", general_h)
        print("\n")

    indices = [i for i, val in enumerate(general_h) if val == ['?', '?', '?', '?', '?', '?']]    
    for i in indices:   
        general_h.remove(['?', '?', '?', '?', '?', '?']) 
    return specific_h, general_h 

s_final, g_final = learn(concepts, target)

print("Final Specific_h: ", s_final, sep="\n")
print("Final General_h: ", g_final, sep="\n")

Source: www.vtupulse.com

Add Comment

0

All those coders who are working on the CSS based application and are stuck on candidate elimination algorithm python code can get a collection of related answers to their query. Programmers need to enter their query on candidate elimination algorithm python code related to CSS code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about candidate elimination algorithm python code for the programmers working on CSS code while coding their module. Coders are also allowed to rectify already present answers of candidate elimination algorithm python code while working on the CSS language code. Developers can add up suggestions if they deem fit any other answer relating to "candidate elimination algorithm python code". Visit this developer's friendly online web community, CodeProZone, and get your queries like candidate elimination algorithm python code resolved professionally and stay updated to the latest CSS updates. 

CSS answers related to "candidate elimination algorithm python code"

View All CSS queries

CSS queries related to "candidate elimination algorithm python code"

Browse Other Code Languages

CodeProZone