资源简介
机器学习 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
相关资源
- 上下文无关文法转乔姆斯基范式CFG2
- Python端口扫描器
- 将mat文件转换成lmdb文件,用于caffe
- 简易版植物大战僵尸 用python写的
- python读取wav时频谱绘制
- 计算二面角的python小程序
- 基于python语言的坐标信息转换为shap
- 麦子学院python视频
- jpype1for python3.5
- 历史天气爬虫
- YouMoney有钱记账一个python写的开源的个
- PyYAML-3.12.tar.gz
- 基于opencv2的骨架提取代码 python实现
- json资料(python and c)
- B站用户数据爬取
- python3+Tkinter+GUI界面+pyserial+串口+串口
- Arcgis 基于Python的高斯扩散模型代码
- Python.CLF
- python实现2048游戏
- 大学排名爬虫
- annoy-1.15.2-cp36-cp36m-win_amd64.whl
- python矩阵乘法小程序
- python 音乐播放器
- Python分词系统jieba代码有注释,无报错
- Python生成3D图,饼图,合图,散点图,
- 树莓派目标跟踪代码python
- 简单的Python蚁群算法
- Python爬虫教程千万别错过
- get_wuyou.zip
- python入门到精通某智付费课程超级完
评论
共有 条评论