
Python学习笔记
田纳尔多
今天不学习,明天变垃圾!
展开
-
10个Python编程小技巧
1. 变量交换a = 1b = 2a, b = b, a # 实现了对两个数的交换a, b(2, 1)2. 字符串格式化name = 'Jack'country = 'China'age = 18# 1. 传统的字符串拼接(很繁杂)print("Hi, I'm " + name + ". I'm from " + country + ". And I'm " + str(age) + " years old.")# 2. 百分号语法print("Hi, I'm %s. .原创 2020-07-02 13:19:30 · 327 阅读 · 0 评论 -
模式识别与机器学习作业——决策树(Python实现)
Decision TreeHomework 4Report:ID3CARTCodeID3CartReference:Homework 4Report:ID3(a) (20 points) Build a decision tree based on the this table using ID3ID3ID3 algorithm (Please use the entropy impurity).The result:(based on ID3ID3ID3)CART(b) Bu.原创 2020-06-10 08:47:24 · 3582 阅读 · 4 评论 -
Day_16、17 —— 算法8种时间复杂度全面总结
1. The SummaryTo recap time complexity estimates how an algorithm performs regardless kind of machine it runs on. You can get the time complexity by “counting” the number of operations performed by your code. This time complexity is defined as a function.原创 2020-06-07 22:59:34 · 756 阅读 · 2 评论 -
模式识别与机器学习作业——SVM(Python实现)
Homework 3报告:Problem 1 Support Vector Machine (SVMSVMSVM)In this problem, we will write a program to implement the SVM algorithm. Let us start with a toy example (which can be found at SVM_matlab_Prof_olga_Veksler.pdf) and then work on more complicated.原创 2020-06-08 13:31:29 · 3686 阅读 · 2 评论 -
Pandas学习笔记——综合练习
Task06:综合练习(1天)Pandas基础一、2002 年——2018 年上海机动车拍照拍卖问题二、2007 年——2019 年俄罗斯机场货运航班运载量问题参考内容import numpy as npimport pandas as pd# 加上这两行可以一次性输出多个变量而不用printfrom IPython.core.interactiveshell import Inte...原创 2020-05-01 21:39:55 · 579 阅读 · 5 评论 -
Pandas学习笔记5——合并
Task05:合并(2天)Pandas基础合并一、append与assign1. append方法(a)利用序列添加行(必须指定name)(b)用DataFrame添加表2. assign方法该方法主要用于添加列,列名直接由参数指定:可以一次添加多个列:二、combine与update1. comine方法comine和update都是用于表的填充函数,可以根据某种规则填充(a)填充对象可以看...原创 2020-04-30 21:38:54 · 687 阅读 · 3 评论 -
Pandas学习笔记4——变形
Task04:变形(2天)Pandas基础变形一、透视表1. pivot一般状态下,数据在DataFrame会以压缩(stacked)状态存放,例如上面的Gender,两个类别被叠在一列中,pivot函数可将某一列作为新的cols:然而pivot函数具有很强的局限性,除了功能上较少之外,还不允许values中出现重复的行列索引对(pair),例如下面的语句就会报错:因此,更多的时候会选择使用强...原创 2020-04-28 17:35:39 · 1313 阅读 · 4 评论 -
Pandas学习笔记3——分组
Task03:分组(2天)Pandas基础关于分组groupby函数聚合、过滤和变换聚合(Aggregation)过滤(Filteration)变换(Transformation)apply练习练习一练习二参考内容关于分组对数据集进行分类,然后方便对每一组的数据进行统计分析。分组运算过程:split(分割)、apply(应用)、combine(合并)。切割:根据什么数据进行分组;应用...原创 2020-04-26 22:55:20 · 829 阅读 · 4 评论 -
Pandas学习笔记2——索引
Task02:索引(3天)Pandas基础单级索引loc方法、iloc方法、[]操作符loc方法iloc方法单级索引loc方法、iloc方法、[]操作符最常用的索引方法可能就是这三类,其中iloc表示位置索引,loc表示标签索引,[]也具有很大的便利性,各有特点。总结成一句话就是,行用loc,列用[],位置用iloc。loc方法loc的适用条件:只有在index 或者column 为...原创 2020-04-23 22:26:02 · 417 阅读 · 4 评论