<jupyter_start><jupyter_text>[Intuition] Test how the algorithm reacts to differetly scaled inputInvestigate numerical stability... just from plain eyesight, this does not seem to affect the hypothesis in the constant case.<jupyter_code>import os, sys
os.chdir(os.path.join('..','..','..')) # set working directory to root of github repo
%matplotlib inline
import matplotlib.pyplot as plt
from active_learning.evaluation import *
# rate according to different constant values

algorithm = UncertaintySamplingAlgorithm
algo_params_length = {'hypothesis': 'Gaussian Process', 'hypothesis_params':{'transformation':'length'}}
algo_params_tfidf = {'hypothesis': 'Gaussian Process', 'hypothesis_params':{'transformation':'tfidf'}}

def rating_func_constant(c):
    return lambda x: c

for c in [0.01,0.02,1,2,4,8,16,32,64]:
    rating_func = rating_func_constant(c)
    stats_length = Evaluator(algorithm=algorithm, algo_params=algo_params_length,
                     oracle=FunctionalOracle, oracle_params={'rating_func':rating_func},
                     batch_size=1, dataset_name='Rotten Tomato').compute()
    stats_tfidf = Evaluator(algorithm=algorithm, algo_params=algo_params_tfidf,
                     oracle=FunctionalOracle, oracle_params={'rating_func':rating_func},
                     batch_size=1, dataset_name='Rotten Tomato').compute()
    print("Constant: {}".format(c))
    stats_length['mse'].plot()
    stats_tfidf['mse'].plot()
    plt.show()
# rate according to the length of the path multiplied by a constant

algorithm = UncertaintySamplingAlgorithm
algo_params_length = {'hypothesis': 'Gaussian Process', 'hypothesis_params':{'transformation':'length'}}
algo_params_tfidf = {'hypothesis': 'Gaussian Process', 'hypothesis_params':{'transformation':'tfidf'}}

def rating_func_length_for_constant(c):
    return lambda x: len(x) * c

for c in [0.01,0.02,1,2,4,8,16,32,64]:
    rating_func = rating_func_length_for_constant(c)
    stats_length = Evaluator(algorithm=algorithm, algo_params=algo_params_length,
                     oracle=FunctionalOracle, oracle_params={'rating_func':rating_func},
                     batch_size=1, dataset_name='<NAME>').compute()
    stats_tfidf = Evaluator(algorithm=algorithm, algo_params=algo_params_tfidf,
                     oracle=FunctionalOracle, oracle_params={'rating_func':rating_func},
                     batch_size=1, dataset_name='<NAME>').compute()
    print("Constant: {}".format(c))
    stats_length['mse'].plot()
    stats_tfidf['mse'].plot()
    plt.show()<jupyter_output>C:\Users\Freya\Anaconda3\envs\Basic\lib\site-packages\sklearn\gaussian_process\gpr.py:308: UserWarning: Predicted variances smaller than 0. Setting those variances to 0.
  warnings.warn("Predicted variances smaller than 0. "
{'fraction_non_alphanumeric': 0.1232876712328767, 'fraction_numerical': 0.015501081470800288, 'mean_word_length': 4.829831932773109, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '41864', 'license': 'MIT', 'n_tokens_mistral': 911, 'n_tokens_neox': 858, 'n_words': 171, 'path': 'notebooks/active_learning/fb-02-rating-functions/06-intution_for_numerical_stability_of_gaussian_regressor.ipynb', 'repo_name': 'MetaExp/backend', 'size': '2788'}