ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 데이터 시각화 (Data Visualization) 워드클라우드 기법
    Data Analysis & EDA 2022. 4. 12. 00:28

     

    데이터 시각화란

    너무 많은 데이터가 있을때 데이터로부터 유용한 정보를 얻기가 어렵다.

    이를 해결하기 위해 데이터 시각화를 하게되면

    세분화된 데이터를 쉽게 이해하며 시각적으로 설득력 있고 유용한 비즈니스 정보로 전환할 수 있다.

     

    가장 쉬운 예로

    주식 그래프를 살펴보자.

    삼성전자 주식

    주식을 하다 보면 위와 같은 차트를 쉽게 볼 수 있다.

    하지만, 초 단위로 빠르게 이루어지는 거래를 매번 숫자로 표시가 된다면 한 눈에 파악하기가 불편할 것이다.

    그렇기에 우리는 조금더 빠르고 간결하게 파악하기 위해 시각화를 이용하는겁니다.

     

     

    워드클라우드

    워드 클라우드란 키워드, 개념 등을 직관적으로 파악할 수 있도록 핵심 단어를 시각화하는 기법이다.

    직접 실습을 통해 확인을 할테지만,

    보다싶이 제일 크게 확인할 수 있는 단어가 몇가지 보인다.

     

    """The Python Tutorial
    Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
    
    The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python Web site, https://www.python.org/, and may be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation.
    
    The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). Python is also suitable as an extension language for customizable applications.
    
    This tutorial introduces the reader informally to the basic concepts and features of the Python language and system. It helps to have a Python interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well.
    
    For a description of standard objects and modules, see The Python Standard Library. The Python Language Reference gives a more formal definition of the language. To write extensions in C or C++, read Extending and Embedding the Python Interpreter and Python/C API Reference Manual. There are also several books covering Python in depth.
    
    This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. Instead, it introduces many of Python’s most noteworthy features, and will give you a good idea of the language’s flavor and style. After reading it, you will be able to read and write Python modules and programs, and you will be ready to learn more about the various Python library modules described in The Python Standard Library."""

    위 코드는 파이썬 공식문서에서 발췌한 것이다.

     

    워드 클라우드란

    많이 언급될수록 단어를 크게 표현해 한눈에 들어올 수 있게 하는 기법 등이 있다.

    주로 빅데이터(big data)를 분석할 때 데이터의 특징을 도출하기 위해 활용한다.

     

    직접 실습을 통해 확인 해 보자.

     

    !pip install wordcloud

    pip 는 라이브러리를 설치하는 명령어 이다.

    설치 명령어 앞에 ! 를 붙이는 이유는, 해당 셀을 명령프롬프트로 인식하게끔 변경 해 주는 의미를 갖고 있다.

    ( ! 를 붙이지 않게 되면 오류 발생)

     

    from wordcloud import WordCloud
    import matplotlib.pyplot as plt

    다음으로 from 은 해당 라이브러리에서 일부만 사용하겠다는 의미이며,

    import 는 해당 라이브러리 전체를 사용하겠다는 의미로 이해할 수 있다.

     

    상단의 예제 문서를 [ tutorial_contents ] 에 담아주도록 하겠다.

    wordcloud = WordCloud(background_color='white', width=800, height=600).generate_from_text(tutorial_contents)
    
    plt.figure(figsize=(22,22)) #이미지 사이즈 지정
    plt.imshow(wordcloud, interpolation='lanczos') #이미지의 부드럽기 정도
    plt.axis('off') #x y 축 숫자 제거
    plt.show()

    다음으로 .show() 함수를 이용하면 아래와 같은 데이터를 확인 할 수 있다.

    댓글

Designed by Tistory.