资源简介
机器学习 python 候选消除算法实现

代码片段和文件信息
class Holder:
factors={} #Initialize an empty dictionary
attributes = () #declaration of dictionaries parameters with an arbitrary length
‘‘‘
Constructor of class Holder holding two parameters
self refers to the instance of the class
‘‘‘
def __init__(selfattr): #
self.attributes = attr
for i in attr:
self.factors[i]=[]
def add_values(selffactorvalues):
self.factors[factor]=values
class CandidateElimination:
Positive={} #Initialize positive empty dictionary
Negative={} #Initialize negative empty dictionary
def __init__(selfdatafact):
self.num_factors = len(data[0][0])
self.factors = fact.factors
self.attr = fact.attributes
self.dataset = data
#print self.attr
def run_algorithm(self):
# print self.dataset
‘‘‘
Initialize the specific and general boundaries and loop the dataset against the algorithm
‘‘‘
G = self.initializeG()
S = self.initializeS()
‘‘‘
Programmatically populate list in the iterating variable trial_set
‘‘‘
count=0
for trial_set in self.dataset:
if self.is_positive(trial_set): #if trial set/example consists of positive examples
G = self.remove_inconsistent_G(Gtrial_set[0]) #remove inconsitent data from the general boundary
S_new = S[:] #initialize the dictionary with no key-value pair
print S_new
for s in S:
if not self.consistent(strial_set[0]):
S_new.remove(s)
generalization = self.generalize_inconsistent_S(strial_set[0])
generalization = self.get_general(generalizationG)
if generalization:
S_new.append(generalization)
S = S_new[:]
S = self.remove_more_general(S)
print S
else:#if it is negative
S = self.remove_inconsistent_S(Strial_set[0]) #remove inconsitent data from the specific boundary
G_new = G[:] #initialize the dictionary with no key-value pair (dataset can take any value)
print G_new
for g in G:
if self.consistent(gtrial_set[0]):
G_new.remove(g)
specializations = self.specialize_inconsistent_G(gtrial_set[0])
specializationss = self.get_specific(specializationsS)
if specializations != []:
G_new += specializations
G = G_new[:]
print G
G = self.remove_more_specific(G)
print S
print G
def initializeS(self):
‘‘‘ Initiali
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-07-25 07:44 Machine-learning-candidate-elimination-algrorithm-master\
文件 11161 2015-07-25 07:44 Machine-learning-candidate-elimination-algrorithm-master\candidate-elimination.py
相关资源
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
评论
共有 条评论