机器学习和深度学习用的最多的语言就是Python了,Python真是神通广大,而起丰富的工具库支撑起了机器学习的大厦。这里介绍几个最有用的
创建numpy 数组
a = np.array[1,2,3]
b = np.arrange(0,10,2)
c =np.zeros((5,5))
d=np.ones((2,4))
e = np.random.randint(0,10,(3,3))
np.linspace(0,10,6)
操作数组
mat = np.arange(0,100).reshape(10,10)
row = 0
col = 1
mat=[row, cal]
mat=[:,cal]
mat=[row,:]
mat=[0:3,0:3]
Masking
mat[mat >5]
读取csv 文件
df = pd.read_csv("xxx/xxx/xxx.csv")
pd 数据类型
type(df) -->pandas.core.frame.DataFrame
type(df['Name']) --->pandas.core.series.Series
type(df[['Name','Salary']]) -->pandas.core.frame.DataFrame
读取colums
df.columns -->Index(['Name', 'Salary', 'Age'], dtype='object')
Masking
df[df['Age'] > 30]
Apply label
census['income_bracket'].apply(lambda label: int(label==' <=50K'))
导入Matplotlib
import matplotlib.pyplot as plt
%matplotlib inline #for jupyter notebook
画图
plt.plot(x,y)
plt.imshow(mat)
Pandas 作图
df.plot(x='xxx', y='yyy',kind ='scatter')
导入
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split