<jupyter_start><jupyter_text>A simple OOP structure with inheritance for data science* Inspired from https://github.com/tirthajyoti/Machine-Learning-with-Python/blob/master/OOP_in_ML/Class_MyLinearRegression.py* With this method, we can directly pass "self" as an argument! * The model inherits all the characteristics from the Config class!* We can return self in spite all returning a specific object! Table of Contents1&nbsp;&nbsp;Creation of a configuration class2&nbsp;&nbsp;Two classes to define some 'low level' methods3&nbsp;&nbsp;Model4&nbsp;&nbsp;Testing the functionnalities of the model  Creation of a configuration class<jupyter_code>class Config:
    """Configuration"""
    magic_number = 3<jupyter_output><empty_output><jupyter_text>Two classes to define some 'low level' methods<jupyter_code>class DataCleaning():
    """Data cleaning methods"""
    
    # self.data and self.x defined later in the model class
    # Config.magic_number from the Config class (no need to create the object!)
    
    def __init__():
        pass
    
    def _remove_magic_nb(self):
        self.data=[x for x in self.data if x != Config.magic_number]
        self.x =[x for x in self.x if x != Config.magic_number] 
        return self
class Multiply:
    """Multiplying data methods"""
    
    # self.data and self.x defined later in the model class
    
    def __init__(self):
        pass
    
    def _double(self):
        self.data = [x*2 for x in self.data]
        self.x = [x*2 for x in self.x]
        return self
    
    def _triple(self):
        self.data = [x*3 for x in self.data]
        self.x = [x*3 for x in self.x]
        return self<jupyter_output><empty_output><jupyter_text>Model Creation of the model itself, which inherits the configuration class `Config`, and the methods contained in the `DataCleaning` and `Multiply` class. This approach helps to keep the essential parts inly in the model with clearly understandable actions<jupyter_code>class Model(Config, DataCleaning, Multiply):
    """ Creation of a model which inherits the DataCleaning and Multiply methods."""
    
    def __init__(self, data, x):
        self.data = data
        self.x = x
        
    def _data_cleaning(self):
        """Data cleaning using the DataCleaning class methods"""
        self = DataCleaning._remove_magic_nb(self)
        
    def _data_processing(self):
        """Data Processing using the Multiply class methods"""
        self = Multiply._double(self)
        self = Multiply._triple(self)<jupyter_output><empty_output><jupyter_text>Testing the functionnalities of the model<jupyter_code># Instantiation of the model
model = Model(data = [1,2,0,0,3,7], x = [3, 3, 7, 14])
# Performing model actions
model._data_cleaning()
model._data_processing()
# Displaying the results
print(model.data)
print(model.x)<jupyter_output>[6, 12, 0, 0, 42]
[42, 84]
{'fraction_non_alphanumeric': 0.09321739130434782, 'fraction_numerical': 0.010782608695652174, 'mean_word_length': 3.6016, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '231904', 'license': 'MIT', 'n_tokens_mistral': 896, 'n_tokens_neox': 854, 'n_words': 292, 'path': 'notebooks/.ipynb_checkpoints/A simple OOP structure with inheritance for data science-checkpoint.ipynb', 'repo_name': 'amc-econ/nlp-emerging-technologies', 'size': '2875'}