<jupyter_start><jupyter_text>환경 설정 : 1번만 필요* 1. 아래 명령 실행 후 브라우저 Refresh 필요.* 2. Menu → Settings → Extension Manager 클릭해서 Extension Manager 활성화 필요.<jupyter_code>!curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
!bash nodesource_setup.sh
!apt-get install -y nodejs

!pip install ipywidgets
!jupyter nbextension enable --py widgetsnbextension
!jupyter labextension install @jupyter-widgets/jupyterlab-manager
!initctl restart jupyter-server --no-wait<jupyter_output><empty_output><jupyter_text>Callback 방식<jupyter_code>from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
def f(x):
    return x
interact(f, x=10);<jupyter_output><empty_output><jupyter_text>Decorator 방식<jupyter_code>@interact(x=True, y=1.0)
def g(x, y):
    return (x, y)<jupyter_output><empty_output><jupyter_text>그래프 예제<jupyter_code>%matplotlib inline
from ipywidgets import interactive
import matplotlib.pyplot as plt
import numpy as np

def f(m, b):
    plt.figure(2)
    x = np.linspace(-10, 10, num=1000)
    plt.plot(x, m * x + b)
    plt.ylim(-5, 5)
    plt.show()

interactive_plot = interactive(f, m=(-2.0, 2.0), b=(-3, 3, 0.5))
output = interactive_plot.children[-1]
output.layout.height = '350px'
interactive_plot<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11942554799697656, 'fraction_numerical': 0.02418745275888133, 'mean_word_length': 5.587064676616915, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '302212', 'license': 'Apache-2.0', 'n_tokens_mistral': 561, 'n_tokens_neox': 575, 'n_words': 120, 'path': '4.ModelEvaluation/Interact.ipynb', 'repo_name': 'dnworry/AICentroPreLab', 'size': '1323'}