1. tensorflow dataset

https://www.tensorflow.org/datasets

 

TensorFlow Datasets

TensorFlow와 함께 사용할 준비가 된 데이터 세트 모음입니다.

www.tensorflow.org

https://www.tensorflow.org/datasets/catalog/overview#all_datasets

 

데이터 세트  |  TensorFlow Datasets

이 페이지는 Cloud Translation API를 통해 번역되었습니다. Switch to English [{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"필요한 정보가 없음" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label

www.tensorflow.org

위에서 모든 데이터 세트를 확인할 수 있다. 가이드를 통해서 사용법을 익히자. 

 

**numpy iterator

dataset을 다운 받고, 하나씩 원소를 확인해보면 tf.tensor( 1, shape = (), dtype) 이런 식으로 구성된 것을 확인할 수 있다. 이때, as_numpy_iterator()을 사용해주면 iterator을 반환해줘서 1, 2, 3 이런 식으로 값만 확인할 수 있게 된다.

 

**bytes to string: map(lambda x: int(x.decode('utf-8'))이용하기

https://stackoverflow.com/questions/606191/convert-bytes-to-a-string

 

Convert bytes to a string

I'm using this code to get standard output from an external program: >>> from subprocess import * >>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0] The

stackoverflow.com

 

2. tensorflow hub

 

3. tensorflow 

 

4. sklearn.metrics.pairwise import cosine_similarity & linear_kernel

코사인 유사도를 사용하면 정규화가 된다.

리니어 커널은 정규화 없이 표현된다.

 

5. random sampling

dataframe.sample(frac = 1, radom_state = random_state)

데이터 프레임의 데이터가 랜덤으로 뒤죽박죽 섞이게 된다.

 

6. loc, iloc 함수

https://devpouch.tistory.com/47

 

판다스(pandas) - 행단위 데이터 읽기 (loc, iloc)

판다스에서 데이터를 행단위로 가져오려면 판다스에서 제공하는 함수를 사용해야 합니다. 제공하는 함수는 아래와 같이 두가지입니다. 속성 설명 loc 인덱스 기준으로 행 데이터 읽기 iloc 행 번

devpouch.tistory.com

 

*행번호와 인덱스의 차이점을 알아야한다.

loc은 인덱스를 기준으로 행 데이터를 읽는다.

iloc은 행번호를 기준으로 행 데이터를 읽는다.

 

근데 열 데이터도 읽어올 수 있다. [ , ]를 사용하면 된다.

 

즉, 행과 열의 데이터를 읽어올 수 있는 함수가 loc, iloc이고 인덱스 기준, 행번호 기준으로 데이터를 가져올 수 있다.

 

 

7. df.stack(), unstack() 함수

stack() 와이드한 행렬같은 데이터프레임을 롱한 시리즈로 바꿔준다. 이때, column은 Index가 된다.

unstack()은 반대의 역할을 한다.

 

 

8. reset_index()

인덱스를 없애버리거나 혹은 인덱스에서 컬럼으로 옮겨준다.

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.reset_index.html

 

pandas.DataFrame.reset_index — pandas 1.2.4 documentation

If the columns have multiple levels, determines which level the labels are inserted into. By default it is inserted into the first level.

pandas.pydata.org

 

+ Recent posts