본문 바로가기

python 및 머신러닝/Coding The Matrix6

[Coding The Matrix] 코딩 더 매트릭스 - Chapter 3 벡터 # -*- coding: utf-8 -*- ''' Created on 2015. 8. 17. @author: Administrator ''' ''' chapter 3 vector ''' from myutil import consolePrintWithLineNumber as c from plotting import plot # 73p L = [[2, 2], [3, 2], [1.75, 1], [2, 1], [2.25, 1], [2.5, 1], [2.5, 1], [2.75, 1], [3, 1], [3.25, 1]] # plot(L, 4) # 74p def add2(v, w): return [v[0] + w[0], v[1] + w[1]] c(add2([4, 4], [1, 2])) c(add2([-4, -4], .. 2015. 8. 18.
파이썬을 사용하면서 발생한 이슈 1. list 라는 단어는 파이썬에서 list(...) 로 사용되는 기본 함수명이다. 보통 자바같으면 변수로 사용할 수 없는 키워드이다. 그런데 파이썬에서는 변수로 사용가능하다.-_- 그래서 간혹 같은 구간에서 list = [] 로 사용하다가 list(...)로 사용하려면 에러가 난다. 함수가 변수로 오버라이딩 되버린듯 하다. 당연하다. 파이썬에서 사용되는 키워드는 되도록 사용하지 않아야 실수를 줄인다. 2.컬렉션 초기화 s = {} if(len(s) == 0): // else: // l = [] d = {} if word in d: // else: // * 집합과 딕셔너리 초기화가 같다... 이렇게 쓰는게 맞나? s = set() s.add(1) d = dict() d['a'] = 1 l = list(.. 2015. 8. 17.
[Coding The Matrix] 코딩 더 매트릭스 - Chapter 2 필드 # -*- coding: utf-8 -*- from myutil import consolePrintWithLineNumber as c ''' Created on 2015. 8. 12. @author: Administrator ''' ''' ch02 필드 ''' # 46p from math import e from math import pi from GF2 import one from image import color2gray from image import file2image from plotting import plot c(1 + 3j) c(1j) c((1 + 3j) + (2 + 2j)) x = 1 + 3j c(x ** 2) c(x.real) c(x.imag) c(type(1 + 2j)) # class.. 2015. 8. 13.
[Coding The Matrix] 코딩 더 매트릭스 - Chapter 1.6 역 인덱스 # -*- coding: utf-8 -*- from myutil import consolePrintWithLineNumber as c ''' Created on 2015. 8. 12. @author: Administrator ''' # 35p # 1.6 Lab: 파이썬-모듈 및 제어 구조-역 인덱스 import math from random import randint import dictutil # helc(math) #도움말 페이지 c(math.sqrt(3)) # 36p # c(math.sqrt(-1)) # ValueError: math domain error c(math.cos(math.pi)) c(math.log(math.e)) c(randint(1, 5)) # Task1.6.2 문제 이해 안됨;;.. 2015. 8. 13.
[Coding The Matrix] 코딩 더 매트릭스 - 준비 코딩 더 매트릭스 Philip N. Klein 원저/필립 클라인 저/마이클 역 | 루비페이퍼 | 원제 : Coding the Matrix 1.python 3.4 설치 2.numpy, matplotlib, six, python-dateutil, pyparsing 설치 - 2장부터 사용 아래 사이트에서 다운로드 가능 http://www.lfd.uci.edu/~gohlke/pythonlibs/ 3.이클립스 pyDev 플러그인 설치 현재폴더가 import 가 되지 않는다면, 프로젝트 프로퍼티 > PyDev - PYTHONPATH >External Libraries 에 현재 폴더 추가 루비페이퍼 : http://www.rubypaper.co.kr/ 책에 대한 댓글 : http://www.rubypaper.co.k.. 2015. 8. 13.
[Coding The Matrix] 코딩 더 매트릭스 - Chapter 1 함수 # -*- coding: utf-8 -*- from myutil import consolePrintWithLineNumber as c # 파이썬이 자동으로 제공해주는 print 함수 대신 사용한다. ''' Created on 2015. 8. 11. @author: Administrator ''' ''' 1p Chapter 1 함수 1.1 집합 중괄호 무한집합 유한집합 1.2 카테시안 곱 2p 1.3 함수 출력 : 입력의 상(image) 입력 : 출력의 원상(pre-image) 3p f : 정의역 -> 공역(치역) 공역 : 함수값이 선택되는 집합(가능한 출력의 집합) 치역 : 모든 정의역 원소들에 대한 함수값들의 집합(실제로 함수값이 되는 공역 원소들의 집합) Example 1.3.5 하지만 정의역의 어떤.. 2015. 8. 11.