- 博客(20)
- 收藏
- 关注
原创 scikit-learn作业题
作业题目:解题思路:1.用sklearn的datasets中的make_classification函数创建一个数据集,根据所给提示,我们设置n_samples=1000, n_features=10;2.用交叉验证分离数据集为10份,用cross_validation的KFolds函数;3.分别使用三种训练算法:朴素贝叶斯、支持向量机和随机森林;4.分别使用三种指标评估交叉验证的性能:精确率、F...
2018-06-19 13:49:25 372
原创 Jupyter练习题
按照题目所给代码:import randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport statsmodels.formula.api as ...
2018-06-12 21:47:25 1988
原创 SciPy作业题
import numpy as npA = np.random.randint(-20, 20, size = 30 * 20).reshape(30, 20)b = np.random.randint(-20, 20, size = 30 * 1).reshape(30, 1)x = np.dot(np.dot(np.linalg.inv(np.dot(A.T, A)), A.T), b...
2018-06-02 22:42:51 231
原创 Matplotlib作业题
from scipy import linalgimport numpy as npfrom matplotlib import pyplotx = np.arange(0, 2, 0.05) #起点,终点,步长y = np.sin((x - 2) * np.exp(-x ** 2)) ** 2pyplot.plot(x, y)pyplot.title("Plotting a fun...
2018-05-26 22:20:54 433
原创 NumPy作业题
from scipy import linalgimport numpy as npA = np.random.normal(0,1,100000).reshape(200,500)B = linalg.toeplitz(list(range(1,500)))print(A + A)print(np.dot(A, A.T))print(np.dot(A.T, A))print(n...
2018-05-19 22:57:47 404
原创 Leetcode - 2.Add Two Numbers题解
题目:You 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 numbers and retur...
2018-05-05 21:08:51 182
原创 Leetcode - 1.Two Sum题解
题目:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same...
2018-05-05 19:29:11 194
原创 Leetcode - 35. Search Insert Position 题解
题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.E...
2018-04-25 21:37:57 145
原创 Leetcode -19. Remove Nth Node From End of List 题解
题目:Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the...
2018-04-25 21:26:25 169
原创 《Python编程——从入门到实践》第十一章部分习题解
# 11-1.city_functions.pydef city(city, country): return(city.title() + ', ' + country.title())test_cities.pyimport unittestfrom city_functions import cityclass TestCase(unittest.TestCase): de...
2018-04-11 21:47:19 825
原创 《Python编程——从入门到实践》第十章部分习题解
# 10-1with open('learning_python.txt') as file_object: contents = file_object.read() print(contents) for line in file_object: print(line) lines = file_object.readlines()for line in lines: pri...
2018-04-04 23:24:06 382
原创 《Python编程——从入门到实践》第九章部分习题解
# 9-1class Restaurant(): def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print(se...
2018-04-04 21:57:56 312
原创 《Python编程——从入门到实践》第八章部分习题解
# 8-2def favorite_book(title): print('One of my favorite book is ' + title)title_temp = input("What's your favorite book?")favorite_book(title_temp)# 8-5def describe_city(city,country='China'): ...
2018-03-29 22:20:03 262
原创 《Python编程——从入门到实践》第七章部分习题解
# 7-2num = input('How many people are going to have dinner?')num = int(num)if num >= 8: print('There is no empty table.')else: print('There are some empty tables.')# 7-5while True: age = in...
2018-03-29 21:45:33 251
原创 《Python编程——从入门到实践》第六章部分习题解
# 6-3words = {'int' : 'integer', 'char' : 'character', 'long' : 'long integer', 'float' : 'single-precision floating-point', 'double' : 'double-precision floating-point'}for noun, means in words.ite...
2018-03-21 22:06:16 441
原创 《Python编程——从入门到实践》第五章部分习题解
# 5-2str1 = 'Basketball'str2 = 'Football'print(str1 == str2)print(str1 != str2)print(str1.lower() == str1)print(str2.lower() != str2)num = 35print(num == 35)print(num != 30)print(num > 11...
2018-03-21 21:29:19 418
原创 《Python编程——从入门到实践》第四章部分习题解
# 4-2animals = ['cat' , 'tiger' , 'leopard']for animal in animals: print(animal)for animal in animals: print('A ' + animal + ' is a Felidae')print('Any of these animals is Felidae')# 4-9cubic ...
2018-03-14 21:55:25 445
原创 《Python编程——从入门到实践》第三章部分习题解
# 3-3traffic_tools = ['bicycle' , 'car' , 'motorcycle']print('I would like to own a ' + traffic_tools[0])print('I would like to own a ' + traffic_tools[1])print('I would like to own a ' + traffic_...
2018-03-14 21:37:11 511
原创 《Python编程——从入门到实践》第二章习题解
# 2-1 简单消息message = "Hello World !"print( message )# 2-2 多条简单消息message = "Hello World !"print( message )message = "Hello Python !"print( message )# 2-3 个性化消息user_name = input()print( "Hello E...
2018-03-07 22:20:55 285
原创 有关于Python主页的观察收获以及对未来的展望
在开始学习python之前,首要任务便是了解python。为此,我特地去python的官网主页阅览了一番。 作为一个相当热门的机器语言,学习python正是大势所趋。在python的主页,四个主要模块我都仔细阅读了一番:latest news、upcoming events、success stories以及use python for...。latest news是...
2018-03-07 21:28:20 369
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人