This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def factorial(n: int) -> float: | |
| """ | |
| Given a positive integer, calculate its factorial | |
| """ | |
| if not isinstance(n, int): | |
| raise TypeError('n must be an integer') | |
| if n < 0: | |
| raise ValueError("n must be positive") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the base class | |
| from algorithms.BaseClass import BaseClass | |
| class InsertionSort(BaseClass): | |
| def __init__( | |
| self, | |
| arr: list | |
| ): | |
| # Inheriting the base class constructor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the base class | |
| from algorithms.BaseClass import BaseClass | |
| class SelectionSort(BaseClass): | |
| def __init__( | |
| self, | |
| arr:list | |
| ): | |
| # Inheriting the base class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BaseClass: | |
| def __init__( | |
| self, | |
| arr: list = [float] | |
| ): | |
| """ | |
| The base class for all the algorithms to inherit from | |
| """ | |
| # Ensuring the correct type | |
| if type(arr) != list: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Maximum number of array length | |
| _max_length = 50 | |
| # Defining the amount of expiremnts in each test | |
| _n_experiments = 200 | |
| # Iteration results | |
| _iter_results = [] | |
| for i in range(_max_length + 1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Base class | |
| from algorithms.BaseClass import BaseClass | |
| class BubbleSort(BaseClass): | |
| def __init__(self, arr: list): | |
| """ | |
| Object constructor | |
| Arguments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the function to test | |
| from pipeline.modules.read_data import read_json | |
| # Dir traversal | |
| import os | |
| def test_data_reading(): | |
| """ | |
| Tests the data reading functionality of the pipeline | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the main pipeline function | |
| from pipeline.pipeline import pipeline | |
| # Directory traversal | |
| import os | |
| # Data frame objects | |
| import pandas as pd | |
| # Defining the test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Main frameworks to test out | |
| from pipeline.modules.read_data import read_json | |
| from pipeline.modules.clean_data import clean_text | |
| # Directory traversals | |
| import os | |
| def test_reading_cleaning(): | |
| # Arrange | |
| _path_to_data = os.path.join( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing all the methods for the pipeline | |
| from pipeline.modules.read_data import read_json | |
| from pipeline.modules.clean_data import clean_text | |
| from pipeline.modules.model_input_preparation import create_X_Y, apply_train_test_split | |
| from pipeline.modules.model_fitting import TextCLF | |
| from pipeline.modules.evaluate_model import eval_model | |
| # Directory traversal | |
| import os |