
Numpy
北辰Rick
学生学生学生!
展开
-
NonLinear Regression & Lasso & Homotopy Method
Part One : Coordinate Descent for LassoThe Lasso optimization problem can be formulated asw^∈argminw∈Rd∑i=1m(hw(xi)−yi)2+λ∥w∥1,\hat{w}\in{ argmin_{w\in R^{d}}\sum_{i=1}^{m}(h_{w}(x_{i})-y_{i})^{2}+...原创 2019-02-21 06:03:52 · 573 阅读 · 0 评论 -
NonLinear Regression Problem & Ridge Regression
Part One : Basis for Nonlinear RegressionIn this part we’re going to investigate how to use linear regression to approximate and estimate complicated functions. For example, suppose we want to fit th...原创 2019-02-18 00:18:08 · 764 阅读 · 0 评论 -
Linear Regression Practice
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltImport other modules from sklearn import linear_modelfrom sklearn.metrics import mean_squared_errorfrom sklearn.metrics impor...原创 2019-02-15 05:56:53 · 571 阅读 · 0 评论 -
Python Numpy学习(六)随机数生成
import numpy as np一、随机数构造np.random.rand(3,2)array([[0.6372113 , 0.27436914], [0.91140569, 0.95159513], [0.86491427, 0.58310291]])np.random.randint(10,size =(5,4))array([[3, 8, 1...原创 2019-01-31 05:47:46 · 299 阅读 · 0 评论 -
Python Numpy学习(五)四则运算
import numpy as np一、向量相乘x = np.array([5,5])y = np.array([2,2])1、对应位置相乘np.multiply(x,y)array([10, 10])2、向量内积np.dot(x,y)203、矩阵相乘x.shape = 1,2y.shape = 2,1np.dot(x,y)array([[20]])...原创 2019-01-31 05:24:22 · 746 阅读 · 0 评论 -
Python Numpy学习(四)数组生成方式
import numpy as npnp.array([1,2,3])array([1, 2, 3])一、Arange结构np.arange(10)array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])np.arange(2,20,2)array([ 2, 4, 6, 8, 10, 12, 14, 16, 18])从哪个数开始+到哪个数截止+...原创 2019-01-30 04:57:35 · 1299 阅读 · 0 评论 -
Python Numpy学习(三)数组形状操作
import numpy as npa_array = np.arange(10)a_arrayarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])一、数组结构改变a_array.shape(10,)a_array.shape = 2,5a_arrayarray([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]...原创 2019-01-30 04:34:00 · 1109 阅读 · 0 评论 -
Python Numpy学习(二)排序
一、简单排序import numpy as npa_array = np.array([[1.5,1.3,7.5], [5.6,7.8,1.2]])a_arrayarray([[1.5, 1.3, 7.5], [5.6, 7.8, 1.2]])按行排序np.sort(a_array)array([[1.3, 1.5, 7.5]...原创 2019-01-25 11:27:48 · 251 阅读 · 0 评论 -
Python Numpy学习(一)数组结构
首先导入Nunpyimport numpy as np一、数组基础操作数组内元素加法array =np.array([1,2,3,4,5])print(type(array))<class 'numpy.ndarray'>array += 1arrayarray([2, 3, 4, 5, 6])array2 = array +1array2array...原创 2019-01-24 23:52:35 · 734 阅读 · 0 评论