Numerical computation in Python data mining

Source: Internet
Author: User

First, environmental installation

Environment configuration:

os:red Hat 4.4.7-11

View command: uname-a: Information about the computer and the operating system

Cat/proc/version: Running kernel version

Cat/etc/issue: Release Release information

Installing the NumPy plugin: Yum install NumPy

The installation package information obtained is as follows:

=============================================================================================================== =
Package Arch Version Repository Size
=============================================================================================================== =
Installing:
NumPy x86_64 1.4.1-9.EL6 Base 2.3 M
Installing for dependencies:
Atlas x86_64 3.8.4-2.EL6 Base 2.8 M
Libgfortran x86_64 4.4.7-16.el6 Base 267 k
Python-nose Noarch 0.10.4-3.1.el6 Base K
Python-setuptools Noarch 0.6.10-3.el6 base 336 k

Transaction Summary
=============================================================================================================== =
Install 5 Package (s)

Total Download size:6.0 M
Installed size:24 M
Is this OK [y/n]: Y

Second, numerical operation

1. Calculate the Euclidean distance between two vectors

Vector_one = Array ([0,1,1,0,0,0])

Vector_two = Array ([1,0,0,1,0,0])

Dist = Linalg.norm (vector_one-vector_two) # # #result = 2.0

2. Create a matrix

Martix = Array ([[[1,0,0,0,0,0],[0,1,0,0,0,0],[0,0,1,0,0,0],[0,0,0,1,0,0],[0,0,0,0,1,0],[0,0,0,0,0,1],[1,1,1,1,1,1 ]])

Get the number of rows and columns of the matrix:

Number of rows: martix.shape[0] columns: martix.shape[1]

Numerical computation in Python data mining

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.