Skip to content

Conversation

@Aaryan-549
Copy link

Pull Request Description

📋 Description

Fixes: #17

Added comprehensive Google-style docstrings to all functions in src/model/models.py to improve code documentation and make it easier for new contributors to understand function parameters, return values, and usage patterns.

🔄 Changes Made

Added

  • Comprehensive Google-style docstrings to 16 functions including normalize_features(), plot_feature_importance(), plot_loss_curve(), and all model training functions
  • Detailed parameter descriptions with types for all function arguments
  • Return value descriptions with types for all functions
  • Usage examples for each function demonstrating practical implementation

Updated

  • Documentation for utility functions (normalize_features, plot_feature_importance, plot_loss_curve)
  • Documentation for prediction functions (predict_duration, compare_predictions, to_submission)
  • Documentation for all individual model trainers:
    • train_linear_regression
    • train_ridge_regression
    • train_lasso_regression
    • train_svr
    • train_xgb
    • train_random_forest
    • train_neural_network
  • Documentation for pipeline functions (run_regression_models, hyperparameter_tuning_xgb, run_complete_pipeline)

🧪 Testing

  • Tested manually:
    • Test case 1: Verified all docstrings follow Google-style format with proper Args, Returns, and Examples sections
    • Test case 2: Confirmed no syntax errors introduced - file structure and functionality remain intact
    • Test case 3: Validated that docstrings accurately describe function behavior, parameters, and return values
    • Test case 4: Checked that examples provided are realistic and helpful for understanding function usage

✅ Checklist

  • My code follows the project's coding standards.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have verified that no API keys or other secrets are committed.
  • I have updated .env.example with any new environment variables.

📝 Example Docstring Format

def normalize_features(X):
    """
    Normalize features into different ranges for model training.
    
    This function applies different normalization ranges to different feature groups:
    coordinates, distances, precipitation, time features, and binary flags.
    
    Args:
        X (pd.DataFrame): Input features containing coordinates (start_lng, start_lat, 
                         end_lng, end_lat), distances (manhattan, euclidean, gmaps_distance, 
                         gmaps_duration), precipitation, time features (weekday, hour), 
                         and flags (holiday, airport, citycenter, standalone, routing_error, 
                         short_trip).
    
    Returns:
        pd.DataFrame: Normalized features with:
            - Coordinates scaled to (-1, 1)
            - Distances scaled to (0, 10)
            - Precipitation scaled to (0, 1)
            - Time features scaled to (0, 5)
            - Flags left unchanged
    
    Examples:
        >>> X_normalized = normalize_features(train_df.drop('duration', axis=1))
        >>> print(X_normalized.shape)
        (10000, 18)
    """

@netlify
Copy link

netlify bot commented Oct 8, 2025

Deploy Preview for gopredict failed.

Name Link
🔨 Latest commit e7d1847
🔍 Latest deploy log https://app.netlify.com/projects/gopredict/deploys/68e652bd923e1100086954f1

@harshitaphadtare
Copy link
Owner

@Aaryan-549 check errors!

@harshitaphadtare
Copy link
Owner

hi @Aaryan-549 is there any update? since only 4 hours remain for this to be accepted under hacktoberfest..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add detailed docstrings to all functions in src/model/models.py

3 participants