Skip to content

Commit

Permalink
added docstrings to functions and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ollie-Gullery committed Apr 12, 2024
1 parent 8c6145a commit f1ff649
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/pynyairbnb/pynyairbnb.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ def build_clf_model(model, preprocessor, tbl_out_dir, X_train, y_train, X_test,


def knn_param_optimization(knn_model, tbl_out_dir, X_train, y_train, X_test, y_test,replacement_dict):
"""_summary_
Performs Hyperparameter optimization for KNN model
Args:
knn_model (_type_): KNN Model Built with Sklearn Library
tbl_out_dir (_type_): Data Input
X_train (_type_): training data input features
y_train (_type_): training data target variable
X_test (_type_): testing data input features
y_test (_type_): testing data target variable
replacement_dict (_type_): Dictionary with proper Formatting for classification report
output_file_name (str): The name to save the output as, will be a .csv file
Output:
Saves output of model to csv file defined in output_file_name
"""
# KNN Hyperparameter Optimization
param_dist = {
'kneighborsclassifier__n_neighbors': randint(1, 30),
Expand Down
7 changes: 7 additions & 0 deletions tests/test_pynyairbnb.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def test_transformer_assignment():
assert transformers.get('countvectorizer') == CountVectorizer

def test_preprocessor():
"""_summary_
Tests the functionality of build preprocessor method
"""
# Create an artificial dataset
np.random.seed(0) # For reproducibility
data = pd.DataFrame({
Expand Down Expand Up @@ -73,6 +77,9 @@ def test_preprocessor():


def test_build_clf_model():
"""_summary_
Tests the build clf model and ensures output file is correctly created
"""
preprocessor = StandardScaler()
model = KNeighborsClassifier()
tbl_out_dir = "./test_outputs"
Expand Down

0 comments on commit f1ff649

Please # to comment.