<jupyter_start><jupyter_text><jupyter_code>import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
import seaborn as sns

from sklearn.linear_model import LinearRegression

# For reproducibility
np.random.seed(1000)


if __name__ == '__main__':
    # Create the dataset
    T = np.expand_dims(np.linspace(0.0, 10.0, num=100), axis=1)
    
    X = (T * np.random.uniform(1.0, 1.5, size=(100, 1))) + np.random.normal(0.0, 3.5, size=(100, 1))

    df = pd.DataFrame(np.concatenate([T, X], axis=1), columns=['t', 'x'])
    print(df)
    # Perform the linear regression
    lr = LinearRegression(n_jobs=10)
    lr.fit(T, X)

    # Print the equation
    print('x(t) = {0:.3f}t + {1:.3f}'.format(lr.coef_[0][0], lr.intercept_[0]))

    # Show the diagram
    sns.set(style="whitegrid", palette="Accent_r", color_codes=True)
    ax = sns.lmplot(data=df, x='t', y='x', height=8)
    plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16970998925886144, 'fraction_numerical': 0.04296455424274973, 'mean_word_length': 3.931216931216931, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '582529', 'license': 'MIT', 'n_tokens_mistral': 403, 'n_tokens_neox': 372, 'n_words': 78, 'path': 'chapter01/supervised_helloworld.ipynb', 'repo_name': 'saratkv/HandsOn_Unsupervised_Learning_with_Python', 'size': '931'}