自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 sklearn

题目:题意:1.用sklearn的datasets中的make_classification函数创建一个数据集2.用交叉验证分离数据集为10份,用cross_validation的KFolds函数;3.分别使用三种训练算法:朴素贝叶斯、支持向量机和随机森林;4.分别使用三种指标评估交叉验证的性能:精确率、F1值、AUC ROC曲线。代码:from sklearn import datasetsf...

2018-06-19 22:18:26 145

原创 6.12 jupyter题目

代码:1.输出x和y的平均数和方差2.输出x和y的相关系数3.计算线性回归线β0 = 3.0013, β1 = 0.4999代码:

2018-06-12 17:14:43 244

原创 Scipy

题目要求使用最小二乘法求解Ax=b,并打印出残差的范数,这里我们设m=20,n=10,并生成一个随机矩阵和随机向量使用scipy.linalg.lstsq求解代码如下:import numpy as npfrom scipy import linalgm=20n=10A=np.random.rand(m,n)b=np.random.rand(m,1)x=linalg.lstsq(A,b...

2018-06-05 22:07:42 287

原创 Matplotlib

1.import matplotlib . pyplot as pltimport numpy as npf,ax=plt.subplots(1,1,figsize=(5,4))x=np.linspace(0,2)y=np.power(np.sin(x-2),2)*np.exp(-1*np.power(x,2))ax.plot(x, y)ax.set_xlim((0, 2))ax.s...

2018-05-29 21:50:51 144

原创 Numpy

import numpy as npn=200m=500A=np.random.randn(n,m)#构造高斯矩阵a=np.random.rand(2*m)B=np.zeros([m,m])for col in range(m):#构造Gaussian矩阵 row=0 first=True while row<m: b=col ...

2018-05-19 15:57:33 119

原创 leetcode:Unique Paths II

题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the b...

2018-05-12 15:12:05 76

原创 leetcode: Jump Game

题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you...

2018-04-29 22:04:56 67

原创 leetcode:3Sum Closest

题目:Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input wou...

2018-04-29 21:19:43 92

原创 leetcode:Container With Most Water

原题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find ...

2018-04-25 20:11:40 76

原创 作业十2018.4.15

11-1import unittestdef city_country(city,country): return city+', '+countryclass Nametest(unittest.TestCase): def test_city_country(self): string=city_country('Santiago','Chile') ...

2018-04-15 19:53:03 89

原创 作业九2018.4.4

10-1filename='learning_python.txt'with open(filename) as file: content=file.read()with open(filename) as file: for line in file: print('In python I can '+line.rstrip())with open(fil...

2018-04-04 20:40:24 79

原创 作业八2018.4.4

9-1class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.name=restaurant_name self.type=cuisine_type self.number_served=0 def describe_restaurant(se...

2018-04-04 20:03:55 107

原创 作业七2018.4.1

8-1def display_message(): print('We learn about function in this chapter')display_message()输出:We learn about function in this chapter8-2def favorite_book(title): print('One of my favorite boo...

2018-04-01 21:23:03 68

原创 作业六2018.3.26

7-1car=input("What car do you want to rent?")print("Let me see if I can find you a "+car)输入:Subaru输出:What car do you want to rent?SubaruLet me see if I can find you a Subaru7-2number=input("How man...

2018-03-26 09:09:10 150

原创 作业五2018.3.23

6-1message={'first_name':'James','last_name':'Mike','age':23,'city':'Hong Kong'}print(message)输出:{'first_name': 'James', 'last_name': 'Mike', 'age': 23, 'city': 'Hong Kong'}6-5rivers={'nile':'egypt'...

2018-03-23 13:27:37 102

原创 作业四 2018.3.19

5-3通过测试:alien_color='green'if alien_color=='green': print('You get five points')输出:You get five points没有通过测试:alien_color='red'if alien_color=='green': print('You get five points')无输出5-4alie...

2018-03-19 08:26:19 91

原创 作业三2018.3.16

4-2animals=['dog','cat','parrot']for animal in animals: print(animal)for animal in animals: print("A "+animal+" would make a great pet")print("Any of these animals would make a great pet!")...

2018-03-16 12:48:06 124

原创 作业二2018.3.14

3-1friends=['Mike','Tina','Tom','Tim']for friend in friends: print(friend.title()3-4friends=['Mike','Tina','tom','Tim']for friend in friends:     print(friend.title()+', would you like to have di...

2018-03-14 10:56:32 108

原创 作业一 2018.3.11

2-1message="hello"print(message)2-2message="hello"print(message)message="error"print(message)2-4name="Eric"print(name.lower())print(name.upper())print(name.title())2-6famous_person="Albert E...

2018-03-11 12:03:23 111

原创 关于python主页的发现和收获以及未来的目标

  浏览过Python主页之后,首先给人的感觉是非常朴素与简洁,除了下载、新闻等内容没有其他非常多余的纯在,一目了然。另外,主页还贴上了滚动式的基础语法以及相关说明,简单的几行代码便让使用者感受到它与其他语言的不同之处:十分简洁流畅,没有多余的东西,作用也明显如下:能够让使用者快速工作并更加有效地整合系统。除此之外,主页上还有使用python的成功案例,并在不断更新中。其中有一段令人印象深刻的是p...

2018-03-05 22:28:14 136

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除