- 博客(20)
- 收藏
- 关注
原创 (十九)Sklearn
题目:思路: 1、数据集的建立使用函数:datasets.make_classification(n_samples,n_features,n_informative,n_redundant,n_repeated,n_classes) 2、使用10倍交叉验证分割数据集使用函数:cross_validation.KFold(length,n_folds,shuffle) 3、算法的...
2018-06-19 15:53:57 152
原创 (十八
题目:利用安斯库姆四重奏实验中的数据进行分析,计算每个表x和y的平均值,方差,相关系数和回归直线拟合,并做出图像。题目参考网址:https://nbviewer.jupyter.org/github/schmit/cme193-ipython-notebooks-lecture/blob/master/Exercises.ipynb代码:import randomimport numpy as ...
2018-06-11 22:39:57 334
原创 (十七)scipy
题目一:思路:与上周的11.2相似,通过函数numpy.lstsq来利用最小二乘法的方法求出系数向量b的估计值。代码:from cmath import *import numpy as npm=20n=10A=np.random.normal(0,1,[m,n])b=np.random.randn(m)least= np.linalg.lstsq(A, b,rcond=0)pr...
2018-06-02 19:51:16 391
原创 (十六)matplotlib
题目一: 思路:构造一个表示该方程的函数,然后利用plot打印。代码:from cmath import *import numpy as npimport matplotlib.pyplot as pltfrom scipy.optimize import leastsqimport seaborndef f(x): temp=-1*pow(x,2) return np.sin(x-...
2018-05-29 16:53:35 143
原创 (十五)Numpy
本次作业的主角毫无疑问就是numpy了。所以首先要做的就是将numpy加载进来,所以简单起见,也将此模块加载进来,还有之后产生随机数和记录时间的功能,所以还需要添加random和time:import numpy as npimport timeimport random 接下来就是对含有正态矩阵A的构建以及托普利兹矩阵B的构建:矩阵A利用np.random.normal来构建,第一个参数是平均值...
2018-05-22 00:10:23 183
原创 作业十四(leetcode第四题)
题目:3Sum ClosestGiven 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 ea...
2018-05-02 23:15:24 253
原创 作业十三(LeetCode第三题)
题目:Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two nu...
2018-04-30 17:11:59 188
原创 作业十二(leetCode第二题)
题目:Longest Palindromic Substring 最长回文串Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.code:class Solution(object): def longestPali...
2018-04-30 04:52:08 75
原创 作业十一(let)
题目:11. Container With Most Waterarray类 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 ...
2018-04-30 03:12:22 100
原创 作业十
本章新学模块:unittest 使用方法:首先创建一个unittest.TestCase的继承类,在类中定义测试函数,函数中利用self.assertEqual(你运行函数得到的结果,你期望的函数结果)来判断是否正确运行/class son(unittest.TestCase): def test(self): answer=your_function(par1,par2) self.asse...
2018-04-09 09:40:52 121
原创 作业九
本章需要注意的指令:with restrip() readline() open() json.dump() json.load()10-1 在一个新建文档中写下python的便利之处,在将其打印出来(新建文件名称为“new 1.txt”)with open("C:\\Users\\bigelow\\Desktop\\文档\\new 1.txt") as file_object: lines=...
2018-04-07 10:34:41 125
原创 作业八
9-1 餐馆--创建一个名为Restaurant的类并设置一些小功能class Restaurant(): def __init__(self,name,type): self.name=name self.type=type def describe_restaurant(self): #打印饭店属性 print("The restaurant is called "+...
2018-04-04 20:35:59 142
原创 作业7(第八章)
8-1 消息 利用函数显示一条表示本章你在学啥的信息 def study(): print("I study function in this chapter") study()8-3 T恤 编写一个make_shirt()函数,形参为尺码和T恤上的字样 def make_shirt(shirt_size,shirt_word): print("The t-shirt is "+str(shi...
2018-03-30 00:56:51 128
原创 作业六(第七章)
7-3 10的整数倍--判断用户输入的一个数字是否为10的倍数 num=input("Please input a number:") num=int(num) if num%10==0: print("Yes!") else: print("...
2018-03-26 08:34:28 129
原创 作业五(字典)
6-1 人--创建一个人的信息(字典) person={"first_name":"Gao", "last_name":"Erji", "age":233, "city":"Guangzhou"} 6-6 调查
2018-03-21 20:18:15 604
原创 作业四
5-1 条件测试things=['apple','dog','I','You','he','she','friends']print('Is 'cat' in things? I guess no!')'cat' in things #False,因为things列表中没有'cat'这项print('Is 'dog' in things? I guess no!')'dog' in things ...
2018-03-20 22:23:16 367
原创 作业三
4-2 动物:打印一个有关动物的列表animals=['dog','cat','turtle']for animal in animals: print('A '+animal+' would make a great pet')print('Any of them would make a great pet!') 在for后面注意缩进,有缩进的就在for的管辖领域,没有for的则不...
2018-03-19 09:27:24 198
原创 作业二
3-4 :嘉宾名单——选择邀请共享晚餐的人 person=["GaoErJi","NiuDun","liuZi","God"] #创建人名列表 print(person[0].title()+", "+person[1].title()+", "+person[2].title()+" and "+person[3].title()+", cou
2018-03-12 23:14:07 135
原创 作业一
2-1 简单消息:将一条消息存储到变量中,再将其打印出来。 str="bigelow" print (str) 2-2 多条简单消息:将一条消息存储到变量中,将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。 str="bigelow" print(str) str="change" print(...
2018-03-11 11:52:17 180
原创 在学习python前(高级编程技术)
一、拜访官网 这学期将在高级编程技术这门课中学习python的使用,在正式开始学习之前,从官网开始了解python是一个怎么样的语言。 进入官网后,可以看出python官网对于新学者满满的关怀:这里有针对新学者的教程。有具体的安装方法和一些推荐读物,还有网上交互式的问答网站,并且python的大部分包都可以在“Python Package Index”中找到,在以后的学习中一定会起到很大的...
2018-03-06 20:14:37 137
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人