您当前的位置: 首页 > 
  • 0浏览

    0关注

    2393博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

DL之perceptron:利用perceptron感知机对股票实现预测

一个处女座的程序猿 发布时间:2018-11-19 09:24:29 ,浏览量:0

DL之perceptron:利用perceptron感知机对股票实现预测

 

 

目录

输出结果

实现代码

 

 

 

输出结果

更新……

 

 

实现代码
import numpy as np
import operator
import os

# create a dataset which contains 3 samples with 2 classes
def createDataSet():
    # create a matrix: each row as a sample
    group = np.array([[20,2], [50,1], [10,3],[60,0.5]])
    labels = [1, -1, 1,-1] # four samples and two classes
    return group, labels

#classify using perceptron
def perceptronClassify(trainGroup,trainLabels):
    global w, b
    isFind = False  #the flag of find the best w and b
    numSamples = trainGroup.shape[0]    #计算矩阵的行数
    mLenth = trainGroup.shape[1]    #计算矩阵的列数
    w = [0]*mLenth  #初始化w
    b = 0   #初始化b
    while(not isFind):  #定义迭代计算w和b的循环
        for i in range(numSamples):
            if cal(trainGroup[i],trainLabels[i])             
关注
打赏
1664196048
查看更多评论
0.0450s