<jupyter_start><jupyter_text>xaddon example: linear regression* <NAME> (<EMAIL>)<jupyter_code>import xarray as xr, numpy as np, pandas as pd
import matplotlib.pyplot as plt

import xaddon
%config InlineBackend.figure_format ='retina'
plt.rcParams['figure.dpi'] = 128<jupyter_output><empty_output><jupyter_text>data<jupyter_code># data
np.random.seed(0)
da_x = xr.DataArray(np.random.randn(100) , dims='time') 
np.random.seed(1)
err = xr.DataArray(np.random.randn(100) , dims='time')
da_y = da_x * 2 + 1 + err

# plot
pd.DataFrame(dict(x=da_x, y=da_y)).plot()
plt.ylabel(' ')

# scatter plot
pd.DataFrame(dict(x=da_x, y=da_y)).plot.scatter('x', 'y')<jupyter_output><empty_output><jupyter_text>linear regression<jupyter_code># linear regression
reg = da_y.linregress.on(da_x, dim='time')
reg
# plot
ax = pd.DataFrame(dict(x=da_x, y=da_y)).plot.scatter('x', 'y')
pd.DataFrame(dict(x=da_x, y=reg.predicted)).plot('x', 'y', ax=ax, label='linear regression')

plt.text(-0.5, -3, f'true slope: 2; predicted: {reg.slope.item():.02f}')
plt.text(-0.5, -4, f'true intercept: 1; predicted: {reg.intercept.item():.02f}')

ax.autoscale()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18907198612315698, 'fraction_numerical': 0.02168256721595837, 'mean_word_length': 6.904109589041096, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '235849', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 518, 'n_tokens_neox': 495, 'n_words': 82, 'path': 'example/xaddon_example_linear_regression.ipynb', 'repo_name': 'wy2136/xaddon', 'size': '1175'}