MachineLearningInAction-第一章

关于numpy的学习;

1、随机array的产生,from numpy import *

random.rand(4, 4)

array 和 matrix是由区别的,上述操作只产生array,通过mat(random.rand(4,4))产生矩阵

看上去没什么区别,但是实际上还是有差别的,比如求逆,上述matrix就可以,但是array不可以,

from numpy import *
a = 100*random.rand(4, 4)
# a1 = a.I
print('a =', a, '\n', 'a.shape =', a.shape)


b = mat(random.rand(4, 4))
b1 = b.I
print('b =', b, '\n', 'b.shape =', b.shape, '\n', "对b求逆 =", b1)

c = eye(4)
print('c =', c)

结果展示:

a = [[76.85152131 14.99735427  6.85834832 29.67180422]
 [91.6979122  32.6047075   2.32941828 31.20946478]
 [23.8556794  67.10700449 48.49510026 22.40238346]
 [45.91045544 16.53090615 66.71346077 57.11425283]] 
 a.shape = (4, 4)
b = [[0.21406897 0.69462993 0.41353914 0.97983807]
 [0.91408446 0.21732001 0.99534469 0.39283777]
 [0.85695195 0.72362135 0.48983071 0.93596663]
 [0.08755973 0.65319038 0.25694018 0.73399583]] 
 b.shape = (4, 4) 
 对b求逆 = [[-0.89119067 -0.25944864  1.75984132 -0.91554878]
 [-6.14590383  0.45367467  0.27349585  7.6128321 ]
 [-0.04669989  1.49797574 -1.73694012  1.47550548]
 [ 5.59196201 -0.89715609  0.15470607 -5.81962459]]
c = [[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]

 

 

mat(random.rand(4, 4)).I                 (.I的操作是求逆)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Machine Learning in Action is unique book that blends the foundational theories of machine learning with the practical realities of building tools for everyday data analysis. You'll use the flexible Python programming language to build programs that implement algorithms for data classification, forecasting, recommendations, and higher-level features like summarization and simplification. About the Book A machine is said to learn when its performance improves with experience. Learning requires algorithms and programs that capture data and ferret out the interesting or useful patterns. Once the specialized domain of analysts and mathematicians, machine learning is becoming a skill needed by many. Machine Learning in Action is a clearly written tutorial for developers. It avoids academic language and takes you straight to the techniques you'll use in your day-to-day work. Many (Python) examples present the core algorithms of statistical data processing, data analysis, and data visualization in code you can reuse. You'll understand the concepts and how they fit in with tactical tasks like classification, forecasting, recommendations, and higher-level features like summarization and simplification. Readers need no prior experience with machine learning or statistical processing. Familiarity with Python is helpful. What's InsideA no-nonsense introduction Examples showing common ML tasks Everyday data analysis Implementing classic algorithms like Apriori and Adaboos =================================== Table of ContentsPART 1 CLASSIFICATION Machine learning basics Classifying with k-Nearest Neighbors Splitting datasets one feature at a time: decision trees Classifying with probability theory: naïve Bayes Logistic regression Support vector machines Improving classification with the AdaBoost meta algorithm PART 2 FORECASTING NUMERIC VALUES WITH REGRESSION Predicting numeric values: regression Tree-based regression PART 3 UNSUPERVISED LEARNING Grouping unlabeled items using k-means clustering Association analysis with the Apriori algorithm Efficiently finding frequent itemsets with FP-growth PART 4 ADDITIONAL TOOLS Using principal component analysis to simplify data Simplifying data with the singular value decomposition Big data and MapReduce

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值