documentation/blog/2025-08-04-mcp-jupyter-server/demo.ipynb
!uv pip install numpy pandas scikit-learn seaborn matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.linear_model import LinearRegression
# Generate some sample data
np.random.seed(0)
X = 2 * np.random.rand(100, 1)
y = 4 + 3 * X + np.random.randn(100, 1)
# Create a DataFrame
df = pd.DataFrame(data=np.hstack((X, y)), columns=["X", "y"])
# Train a simple linear regression model
model = LinearRegression()
model.fit(df[["X"]], df["y"])
# Print the coefficients
print(f"Intercept: {model.intercept_}")
print(f"Coefficient: {model.coef_[0]}")
# Plot the data and the regression line using seaborn
sns.set(style="whitegrid")
plt.figure(figsize=(8, 6))
sns.scatterplot(data=df, x="X", y="y", label="Data Points")
plt.plot(df[["X"]], model.predict(df[["X"]]), color="red", label="Regression Line")
plt.title("Linear Regression Example")
plt.xlabel("X")
plt.ylabel("y")
plt.legend()
plt.show()