zoukankan      html  css  js  c++  java
  • 【Todo】用python进行机器学习数据模拟及逻辑回归实验

    参考了这个网页:http://blog.csdn.net/han_xiaoyang/article/details/49123419

    数据用了 https://pan.baidu.com/s/1pKxJl1p#list/path=%2F 这里面的data1 (已经转存到自己的网盘)

    代码如下:

    from numpy import loadtxt, where
    from pylab import scatter, show, legend, xlabel, ylabel
    
    #load the dataset
    data = loadtxt('data1.txt', delimiter=',')
    
    X = data[:, 0:2]
    y = data[:, 2]
    
    pos = where(y == 1)
    neg = where(y == 0)
    
    scatter(X[pos, 0], X[pos, 1], marker='o', c='b')
    scatter(X[neg, 0], X[neg, 1], marker='x', c='r')
    xlabel('Feature1/Exam1 score')
    ylabel('Feature2/Exam2 score')
    legend(['Fail', 'Pass'])
    show()

    运行命令,得到结果:

    $ python lr_show.py 

    准备画线,代码参考:https://github.com/HanXiaoyang/ML_examples/tree/master/logistic_regression

    看代码,里面的numpy里面有reshape函数,是把多维函数能够变成其他维度,可以参考

    http://blog.csdn.net/u012005313/article/details/49383551

    但是看代码不太看的懂。换换脑子。先看看其他的吧。

  • 相关阅读:
    泛型集合的变化
    c#中结构与类的区别
    C# where子句
    C# 泛型学习
    about osgeo中国
    about codeplex
    content in map
    a excellent website for javascrpt & dhtml:
    MapGuide open source开发系列教程四: 体系结构(转贴)
    about NetTopologySuite
  • 原文地址:https://www.cnblogs.com/charlesblc/p/6210921.html
Copyright © 2011-2022 走看看