Python

    [Math] Cartesian Product (or Descartes Product, Product Set)

    Cartesian Product (or Descartes Product) 공집합(empty set, null set)이 아닌 여러 sets를 이용하여 새로운 set을 만드는 연산. Cartesian product는 operand인 여러 집합들의 각 elements를 원소(component, element)로 하는 tuple을 element(원소)로 하는 set을 반환함. 2개의 집합 $A$, $B$의 Cartesian product $A\times B$는 다음과 같음. $$A\times B= \{ (a,b) | a \in A, b\in B\}$$ $n$ 개의 집합 $A_1, A_2, \dots, A_n$의 Cartesian Product는 다음과 같이 정의됨. $$\displaystyle \prod^n_..

    [ML] Time Series 란?

    시계열 데이터라고 불리는 time series data는 쉽게 생각해서 일정한 시간 간격으로 배치된 seqence (수열) 을 가르킨다. 이는 엄밀하게 애기하면 discrete time series data라고 생각할 수 있다. continuous time series data의 경우엔 sampling interval $T_0=0$인 경우를 가르킨다. tiem series data는 순서가 의미를 가지는 sequential data의 일종이다. 2023.07.21 - [.../Math] - [Math] Sequence (수열) and Series (급수) [Math] Sequence (수열) and Series (급수) Sequence 수열, 열 이라고 불림. numbers나 objects 들이 순서를 ..

    [Python] for statement

    for statement는 loop를 위한 control structure의 대표격이다. Python에서는 iterable 객체 (주로 collection type의 객체들)이 가지고 있는 item들을 iterate하는 용도로 사용된다. 프로그래밍을 배울 때, 구구단 출력과 같은 고전적인 예를 통해 배우고, 정말 기본 중의 기본으로 활용된다. 단, NumPy등을 익히게 되면서 loop가 아닌 matrix 를 이용한 처리 (쉽게 생각하면 많은 memory를 이용하여 반복을 덜하는 방식이라고 할 수 있음)가 보다 효율적이기 때문에 정말 필요한 경우 아니면 쓰지 말라고 애기를 하게 되지만... for statement는 정말 기본 중의 기본이다. (반복을 얼마나 효율적으로 하느냐가 성능 뿐 아니라 유지보수의 ..

    [Python] Regular Expression : re 요약

    Regular Expression : re 요약 정규표현식(正規表現式, Regular Expression)은 문자열을 처리하는 방법 중의 하나로 특정한 조건의 substring(문자열)을 '검색'하거나 '치환'하는 과정을 특정 문자열의 pattern을 기술하는 expression을 이용하여 매우 간편하게 처리 할 수 있도록 해준다. 주요 Tasks RE를 통해 수행되는 것은 크게 다음의 세가지임. searching splitting replacing 이들 모두 특정 substring pattern에 대한 matching을 사용한다. 즉, matching, searching, splitting, replacing을 하는 방법에 대한 이해를 하면 RE를 효과적으로 사용가능하다. compiled pattern..

    [Python] str : Overloaded Operators

    Concatenation + opeartor combines its two operands. 다음과 같이, 두 문자열이 붙은 새로운 문자열을 반환한다. >>> a = 'test1' + 'test2' >>> a 'test1test1' + opeartor does not add any space between two operand strings to concate, contrast to the case of print method. print 함수에서 argument 사이에 space가 포함되는 것과 달리 문자열 그대로 사용하여 결합만이 이루어짐. Duplication 곱하기가 아닌 앞의 operand 인 str이 뒤의 operand로 주어진 숫자만큼 반복되어 concatenation이 됨. >>> 'one..

    [Python] f-String

    Python : f-String Python 3.6 이후 도입됨. 기존의 중괄호 {}과 format 메소드를 사용하여 문자열 포매팅을 설정하는 방식들과 유사하지만, 더 직관적으로 문자열을 포맷팅할 수 있는 기능으로 현재는 다른 방법들보다 권장됨 이를 formatted string literals라고도 부르며, 더 간결한(succinct) 구문을 가지고 있음. Syntax Python에서 문자열을 만드는 방식과 거의 유사하나 문자열을 싸고 있는 single or double quotes에서 시작하는 quote앞에 f 나 F를 붙여주면 됨. "simple text" : 일반적인 Python 문자열 f"formatted string lietera" : f-String How to print variables ..