import numpy as np
import pandas as pd

def candidate_elimination_from_csv(csv_path):
    dataset = pd.read_csv(csv_path)
    concepts = np.array(dataset.iloc[:, 0:-1])
    target = np.array(dataset.iloc[:, -1])
    def learn(concepts, target):
        specific_h = concepts[0].copy()
        general_h = [['?' for _ in range(len(specific_h))] for _ in range(len(specific_h))]
        for i, h in enumerate(concepts):
            if target[i].lower() == 'yes':
                for x in range(len(specific_h)):
                    if h[x] != specific_h[x]:
                        specific_h[x] = '?'
                        general_h[x][x] = '?'
            elif target[i].lower() == 'no':
                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] = '?'
        general_h = [g for g in general_h if g != ['?'] * len(specific_h)]
        return specific_h, general_h
    return learn(concepts, target)
