<jupyter_start><jupyter_text>https://github.com/tirthajyoti/Interactive_Machine_Learning  Simple interactive widget demo<jupyter_code>from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
from IPython.display import display

import numpy as np
import matplotlib.pyplot as plt
#%matplotlib inline

import pandas as pd<jupyter_output><empty_output><jupyter_text>Variables<jupyter_code>N_samples = 25
x=np.linspace(-2,2,N_samples)<jupyter_output><empty_output><jupyter_text>Function definitions (ideal fitting function and actual data generating function with noise)<jupyter_code>def f(x,a,mu,sigma):
    r=a*np.exp(-(x-mu)**2/(2*sigma**2))
    return (r)
def func(amplitude,ideal_mu,ideal_sigma,noise_sd,noise_mean):
    r=amplitude*np.exp(-(x-ideal_mu)**2/(2*ideal_sigma**2))
    plt.figure(figsize=(8,5))
    plt.plot(x,r,c='k',lw=3)
    r= r+np.random.normal(loc=noise_mean,scale=noise_sd,size=N_samples)
    plt.scatter(x,r,edgecolors='k',c='yellow',s=60)
    plt.grid(True)
    plt.show()
    return (r)<jupyter_output><empty_output><jupyter_text>Call the 'interactive' widget with the data generating function, which also plots the data real-time** Play with the *'noise_sd'* and *'noise_mean'* parameters to see how they impact the estimation (curve-fit) accuracy **We get nice widgets in Jupyter. Re-implement in scriptedforms<jupyter_code>y=interactive(func,amplitude=[1,2,3,4,5],ideal_mu=(-5,5,0.5),
              ideal_sigma=(0,2,0.2),
              noise_sd=(0,1,0.1),noise_mean=(-1,1,0.2))
display(y)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.138801261829653, 'fraction_numerical': 0.022712933753943218, 'mean_word_length': 6.552380952380952, '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': '450076', 'license': 'MIT', 'n_tokens_mistral': 611, 'n_tokens_neox': 583, 'n_words': 104, 'path': 'scriptedforms/interactive_plot/Curve_fit_widget_1.ipynb', 'repo_name': 'afcarl/Useful-python', 'size': '1585'}