<jupyter_start><jupyter_text>Notebook that explores some specific behavior from the used exampleSee: https://www.mlflow.org/docs/latest/tutorials-and-examples/tutorial.html<jupyter_code>%load_ext autoreload
%autoreload 2
from sklearn.linear_model import ElasticNet, LogisticRegression, LinearRegression
from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
df = pd.read_csv("src_dvc-example_wine-quality.csv")<jupyter_output><empty_output><jupyter_text>train and test are still DataFrame<jupyter_code>train, test = train_test_split(df)<jupyter_output><empty_output><jupyter_text>Cool: sklearn can handle DataFrames transparently, and even numpy.dot() can(!!), but below we extract the numpy arrays (foo.values) to make life a biteasier<jupyter_code>X_train = train.drop("quality", axis=1).values
X_test = test.drop("quality", axis=1).values
y_train = train["quality"].values
y_test = test["quality"].values
model = LinearRegression().fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>$\hat{y} = w_0 + X w$<jupyter_code>y_pred = model.predict(X_train)
print(y_pred)<jupyter_output><empty_output><jupyter_text>sanity check<jupyter_code>y_pred.shape<jupyter_output><empty_output><jupyter_text>$w$<jupyter_code>w = model.coef_
print(w)<jupyter_output><empty_output><jupyter_text>$w_0$<jupyter_code>w0 = model.intercept_
print(w0)<jupyter_output><empty_output><jupyter_text>Difference $\hat{y} - (w_0 + X w)$ should be zero (up to numerical noise)<jupyter_code>d = y_pred - (w0 + np.dot(X_train, w))
print(d)
# print(np.linalg.norm(d))
print(np.sqrt(np.dot(d,d)))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1291895185862279, 'fraction_numerical': 0.005484460694698354, 'mean_word_length': 9.2625, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '328918', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 633, 'n_tokens_neox': 613, 'n_words': 103, 'path': 'Content/example_clarify.ipynb', 'repo_name': 'hzdr/mlops_comparison', 'size': '1641'}