<jupyter_start><jupyter_text>This demonstrates scikit-learn regression for comparison with Tribuo regression, although these resulting regression models were not used in the final comparisons<jupyter_code>import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
from sklearn.linear_model import SGDRegressor
from sklearn.linear_model import LinearRegression
from sklearn.tree import DecisionTreeRegressor
from sklearn.metrics import mean_squared_error
# This dataset is generated in the notebook: scikit-learn Regressor Example - Data Cleanup
df = pd.read_csv('../../data/cleanedBottle.csv')
print(df)
X = np.array(df[['depth', 'salinity']])
y = np.array(df['temp'])

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)
print('Training data size = %d, number of features = %d' % (len(X_train), len(df.columns) - 1))
print('Testing data size = %d, number of features = %d' % (len(X_test), len(df.columns) - 1))
# optimiser=AdaGrad(initialLearningRate=0.01,epsilon=1.0E-6,initialValue=0.0),epochs=10,minibatchSize=1,seed=1)
# sdg = SGDRegressor(learning_rate='adaptive', epsilon=0.1, eta0=0.01, tol=1e-3)
# sgd = SGDRegressor(learning_rate='adaptive', epsilon=0.1, eta0=0.01)
sgd = SGDRegressor()
%time sdg = sgd.fit(X_train, y_train)
predicted = sgd.predict(X_test)

# predicted = cart.predict(X_test)
lr = LinearRegression()
%time lr = lr.fit(X_train,y_train)
predicted = lr.predict(X_test)
cart = DecisionTreeRegressor(max_depth=6)
%time cart = cart.fit(X_train,y_train)
predicted = cart.predict(X_test)
# Compare the first 3 
print('actual: %.2f, predicted: %.2f' % (y_test[0], predicted[0]))
print('actual: %.2f, predicted: %.2f' % (y_test[1], predicted[1]))
print('actual: %.2f, predicted: %.2f' % (y_test[2], predicted[2]))
# Compare 3 more from the middle 
print('actual: %.2f, predicted: %.2f' % (y_test[1000], predicted[1000]))
print('actual: %.2f, predicted: %.2f' % (y_test[2000], predicted[2000]))
print('actual: %.2f, predicted: %.2f' % (y_test[3000], predicted[3000]))
# note the use of the squared param, which gives RMSE

print('RMSE: %.2f' % mean_squared_error(y_test, predicted, squared=False))<jupyter_output>RMSE: 1.68
{'fraction_non_alphanumeric': 0.14846188140882746, 'fraction_numerical': 0.03566651805617477, 'mean_word_length': 6.555555555555555, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '413796', 'license': 'Apache-2.0', 'n_tokens_mistral': 865, 'n_tokens_neox': 804, 'n_words': 198, 'path': 'notebooks/regressor/scikit-learn Regressor Example.ipynb', 'repo_name': 'geoffreydstewart/JavaVsPythonMLlibs', 'size': '2243'}