<jupyter_start><jupyter_text>kNN model on kaggle-pet competition we are following Stanford CS231n, and trying to apply their assignements to this competition. CS231N: http://cs231n.github.io/assignments2018/assignment1/sci-kit knn: https://scikit-learn.org/stable/modules/neighbors.html Main differences between assignment and this notebook:    - we will be using Knn for regression task, and not for classification    - we will be using sci-kit implementation of knn and not written by us<jupyter_code>import pandas as pd
import os
os.listdir('../data')
assert 'out_breed.csv' in os.listdir('../data') # this assert breaks if the data is configured uncorrectly
breeds = pd.read_csv('../data/out_breed.csv')
colors = pd.read_csv('../data/out_color.csv')
states = pd.read_csv('../data/out_state.csv')
train  = pd.read_csv('../data/out_train.csv')
test   = pd.read_csv('../data/out_test.csv')
sub    = pd.read_csv('../data/out_submission.csv')
class PredictiveModel(object):
    """
    this is the base class for the prediction task of Adoption Prediction competition
    """
    
    def __init__(self, name):
        self.name = name
        self.model = None
        from time import ctime
        print("{} [{}.__init__] initialized succesfully".format(ctime(), self.name))
        
    def train(self, X, Y):
        """
        train method, feature generation is inside here, data cleaning outside
        
        Args:
            X: pandas.DataFrame, shape = (, 24)
            Y: pandas.Series
        Returns:
            model (also saved in self.model)
        """
        
    def predict(self, X):
        """
        predict method, feature generation is inside here, data cleaning outside
        
        Args:
            X: pandas.DataFrame, shape = (, 24)
        Returns:
            Y: pandas.Series
            
        Raise:
            .not trained
        """
train.shape
train.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11071060762100927, 'fraction_numerical': 0.009268795056642637, 'mean_word_length': 2.5199275362318843, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '544609', 'license': 'MIT', 'n_tokens_mistral': 587, 'n_tokens_neox': 561, 'n_words': 170, 'path': 'models/.ipynb_checkpoints/kNN-checkpoint.ipynb', 'repo_name': 'ferrucc-io/kaggle-pets', 'size': '1942'}