Exemplo n.º 1
0
def test(inx, path):
    '''
    :param inx: 待测向量
    :param path: 数据路径
    :return: 结果
    '''
    da = ParseData(path)
    dataset = da.dataset()
    labels = da.labels()
    p0vect, p1vect, negative_prop, positive_prob = actual_trainnb0(
        dataset, labels)
    result = classifyNB(inx, p0vect, p1vect, negative_prop, positive_prob)
    return result
Exemplo n.º 2
0
from classification.decision_tree.tree import createtree
from parsedata.parsedata import ParseData

file_path = r'F:\machine\file\Book1.xlsx'
labels = ['a', 'b', 'c', 'd']
da = ParseData(file_path)
data = da.entry_data()
# dataset是整个数据,labels是特征,因为numpy不会显示特征名字,所以另外输入
result = createtree(data, labels)
print(result)
Exemplo n.º 3
0
from simplify_data.simple_svd.svd import recommend
from parsedata.parsedata import ParseData
import numpy

file_path = r'F:\machine\file\hyxd_movie_01newdata4.xlsx'
data = ParseData(file_path)
da = numpy.mat(data.dataset())
print(recommend(
    da,
    1,
))
Exemplo n.º 4
0
import numpy
import pandas

from classification.adaboost.adboost_tree import adaclassify
from classification.adaboost.adboost_tree import addbosttrainds
from parsedata.parsedata import ParseData

inx = numpy.array([])
file_path = r'F:\machine\file\hyxd_movie_01newdata4.xlsx'
da = ParseData(file_path)
data = da.dataset()
# classlabels=da.labels()
classlabels = numpy.mat(
    pandas.read_excel(file_path).iloc[:, [-1]])  #过一会改parsedata,两个返回的维度不一样
classifierarr = addbosttrainds(data, classlabels)
print(classifierarr)
print(adaclassify(inx, classifierarr))
Exemplo n.º 5
0
from unsupervised.kmean.kme import kmeans
from unsupervised.kmean.dichotomy_tree import dichmeans
from parsedata.parsedata import ParseData
import numpy


file_path=r'F:\machine\file\hyxd_movie_01newdata4.xlsx'
test_path=r'F:\machine\file\hyxd_movie_01newdata3.xlsx'
da = ParseData(test_path)
data=da.entry_data()[:107,:]
print(kmeans(data,2))
print(dichmeans(numpy.array(data),5))#这样就对了,好奇怪,明天专门研究一下这些格式问题和相互赋值问题

# data=[[1,2,3],[23,35,56,],[34,1],[23,45,78,],[12,289,],[12,56,17],[34,67,89,],[3,34,12],[16,47,89,],[45,78,89]]
# print(dichmeans(numpy.mat(data),5))#这样是对的,奇怪

Exemplo n.º 6
0
from tree_logistic.cart_tree import creattree

from parsedata.parsedata import ParseData
from predict_value.tree_logistic.prune import prune

file_path = r'F:\machine\file\hyxd_movie_01newdata4.xlsx'
test_path = r'F:\machine\file\hyxd_movie_01newdata5.xlsx'
da = ParseData(file_path)
data = da.entry_data()
test = ParseData(test_path)
testdata = test.entry_data()
tree = creattree(data)
print(tree)
print(prune(tree, testdata))
Exemplo n.º 7
0
import numpy as np

from classification.k_neighborhood.knn import classify
from parsedata.parsedata import ParseData

file_path=r'F:\machine\file\Book1.xlsx'
file_path1=r'F:\machine\file\yob1893.txt'
da=ParseData(file_path)
dataset=da.dataset()
labels=da.labels()
inx=np.array([1,2,3,5])
classify(inx,dataset,labels,3)


Exemplo n.º 8
0
from parsedata.parsedata import autonorm
from parsedata.parsedata import ParseData
from predict_value.logistics_value.stand_logis import standRegres

file_path = r'F:\machine\file\hyxd_movie_01newdata4.xlsx'
da = ParseData(file_path)
datamatin = da.dataset()
datamatin = autonorm(datamatin)
classlabels = da.labels()
print(standRegres(datamatin, classlabels))