绘图 matplotlib使用

该博客介绍了如何使用matplotlib进行图形绘制,包括正弦曲线的绘制和简单的点划线图表。同时,展示了如何结合sklearn库,利用线性回归模型对波士顿房价数据集进行交叉验证预测,并将测量值与预测值进行可视化展示。
摘要由CSDN通过智能技术生成
#!/usr/bin/env python
# encoding: utf-8

import numpy as np
import matplotlib.pyplot as plt

def test_plot():
	x = np.arange(0, 5, 0.1);
	print type(x),x
	y = np.sin(x)
	plt.plot(x, y)
	plt.show()

def test_plot_simple():
	#根据点划线:两点间用线连接
	print ''

	'''
		plot 


	return :
		(lags, c, line, b) : where:
			lags are a length 2`maxlags+1 lag vector.
			c is the 2`maxlags+1 auto correlation vectorI
			line is a Line2D instance returned by plot.
			b is the x-axis.
	'''
	x=[1,4,2,3]
	y=[2,4,6,8]
	print x
	print y
	#plt.plot(x, y)
	plt.plot(x)
	plt.show()




def test_dataset_ml_draw():
	print '画数据集,及分类结果'
	from sklearn import datasets
	from sklearn.model_selection import cross_val_predict
	from sklearn import linear_model
	import matplotlib.pyplot as plt

	lr = linear_model.LinearRegression()
	boston = datasets.load_boston()
	y = boston.target

	# cross_val_pr
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值