<jupyter_start><jupyter_text>Tree Regression CS/DSA 5970<jupyter_code>import pandas as pd
import numpy as np
import re
import matplotlib.pyplot as plt
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import cross_val_predict
from sklearn.metrics import mean_squared_error
from sklearn.metrics import confusion_matrix
from sklearn.metrics import log_loss
from sklearn.metrics import roc_curve, auc
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.linear_model import SGDClassifier, LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC, LinearSVR, SVR
from sklearn.tree import DecisionTreeRegressor, export_graphviz
import pickle as pkl
from mpl_toolkits.mplot3d import Axes3D


##################
# Default parameters
FIGURESIZE=(10,6)
FONTSIZE=18

plt.rcParams['figure.figsize'] = FIGURESIZE
plt.rcParams['font.size'] = FONTSIZE

plt.rcParams['xtick.labelsize'] = 18
plt.rcParams['ytick.labelsize'] = 18
def plot_3d(ins, pred):
    '''
    Plot pred as a function of the 2 dimensions of ins
    '''
    fig = plt.figure(figsize=FIGURESIZE)
    ax = fig.gca(projection='3d')
    ax.plot_trisurf(ins[:,0], ins[:,1], pred, cmap=plt.cm.jet)<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>fname = '../ml_practices/imports/datasets/misc/svr_data.pkl'
fp = open(fname, 'rb')
ins = pkl.load(fp).T
outs = pkl.load(fp).flatten()
fp.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10421994884910486, 'fraction_numerical': 0.01278772378516624, 'mean_word_length': 6.4170616113744074, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '275343', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 560, 'n_tokens_neox': 537, 'n_words': 127, 'path': 'skeletons/tree_regression-skel.ipynb', 'repo_name': 'ahfagg/mlp_2021', 'size': '1564'}