zoukankan      html  css  js  c++  java
  • python_机器学习—sklearn_win_64-3.6安装&&测试

    下载网址:http://www.lfd.uci.edu/~gohlke/pythonlibs/

    在之前numpyscipy基础上,安装sklearn_win_64-3.6

     pip install D:python3.6.1Scriptsscikit_learn-0.18.1-cp36-cp36m-win_amd64.whl

     另外,发现之前的numpy与sklearn 不是同一网站下载,故进行了重装

    最后进行测试:

    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.collections import LineCollection
    
    from sklearn.linear_model import LinearRegression
    from sklearn.isotonic import IsotonicRegression
    from sklearn.utils import check_random_state
    
    n = 100
    x = np.arange(n)
    rs = check_random_state(0)
    y = rs.randint(-50, 50, size=(n,)) + 50. * np.log(1 + np.arange(n))
    ir = IsotonicRegression()
    
    y_ = ir.fit_transform(x, y)
    
    lr = LinearRegression()
    lr.fit(x[:, np.newaxis], y)  # x needs to be 2d for LinearRegression
    segments = [[[i, y[i]], [i, y_[i]]] for i in range(n)]
    lc = LineCollection(segments, zorder=0)
    lc.set_array(np.ones(len(y)))
    lc.set_linewidths(0.5 * np.ones(n))
    
    fig = plt.figure()
    plt.plot(x, y, 'r.', markersize=12)
    plt.plot(x, y_, 'g.-', markersize=12)
    plt.plot(x, lr.predict(x[:, np.newaxis]), 'b-')
    plt.gca().add_collection(lc)
    plt.legend(('Data', 'Isotonic Fit', 'Linear Fit'), loc='lower right')
    plt.title('Isotonic regression')
    plt.show()
    

     结果:

     

  • 相关阅读:
    概率期望训练之五
    概率期望训练之四
    JavaScript Source Map详解
    JSON.parse、JSON.stringify
    Linux cp命令直接覆盖不提示方法
    Service Worker
    HTML5 应用程序缓存
    二分图
    Tarjan
    FFT迭代加深 & NTT 多项式求逆
  • 原文地址:https://www.cnblogs.com/lwbjyp/p/6913234.html
Copyright © 2011-2022 走看看