Implement GitHub User Activity Predictions
We need to implement a set of Python functions to analyze and predict GitHub user activity based on their historical data. These functions will use metrics such as total contributions, active days, account creation date, and current year activity to make predictions about the user’s future behavior, consistency, and milestones.
This feature will help us:
- Predict future contributions and active days.
- Identify trends in user activity (e.g., increasing or decreasing).
- Estimate milestone achievement (e.g., 10,000 contributions).
- Measure user consistency and productivity.
Acceptance Criteria
The following functions must be implemented and tested:
-
predict_long_term_activity
- Input:
total_contributions, github_days, current_year_contributions, active_days
- Output: Lifetime and current daily contribution rates, and trend (increasing/decreasing).
-
predict_future_active_days
- Input:
active_days, github_days, remaining_days
- Output: Predicted number of active days for the rest of the year.
-
predict_burnout
- Input:
active_days_by_year (list of active days per year)
- Output: Trend analysis (e.g., "Activity is decreasing").
-
predict_consistency
- Input:
active_days, github_days
- Output: Consistency score and classification (e.g., "Sporadic contributor").
-
predict_account_longevity
- Input:
active_days_by_year
- Output: Estimated time until activity ceases (e.g., "Account activity may cease in ~2 years").
-
predict_effective_rate
- Input:
total_contributions, active_days, github_days
- Output: Effective contribution rate (weighted by activity frequency).
-
predict_milestone
- Input:
current_contributions, milestone, lifetime_rate
- Output: Days required to reach the milestone.
-
run_all_predictions
- Input:
user_data (dictionary with all required fields)
- Output: Dictionary containing all predictions.
Steps to Implement
- Create a new Python file (e.g.,
github_predictions.py).
- Implement the functions as described above.
- Write unit tests for each function to ensure accuracy.
- Add documentation (docstrings) for each function.
- Provide an example usage script to demonstrate how the functions work.
Example Input
user_data = {
"created_at": "2015-01-01", # Account creation date
"active_days": 200, # Total active days since account creation
"total_contributions": 5000, # Total contributions (commits, PRs, issues, etc.)
"current_year_contributions": 115, # Contributions this year
"current_year_active_days": 37, # Active days this year
"active_days_by_year": [150, 100, 50], # Active days per year (e.g., last 3 years)
"milestone": 10000 # Optional: Milestone to predict (e.g., 10,000 contributions)
}
Example Output
{
"long_term_activity": {
"lifetime_rate": 1.37,
"current_rate": 3.11,
"trend": "increasing"
},
"future_active_days": 65.6,
"burnout": "Activity is decreasing.",
"consistency": "Sporadic contributor.",
"account_longevity": "Account activity may cease in ~2.0 years.",
"effective_rate": 1.37,
"milestone": 3650.0
}
Additional Context
- The functions should be modular and reusable.
- Use Python’s
datetime module for date calculations.
- Include error handling for edge cases (e.g., missing data).
- Add comments and docstrings to explain the logic and inputs/outputs.
Testing
- Write unit tests for each function using
pytest or unittest.
- Test edge cases (e.g., zero active days, missing data).
- Ensure the functions handle invalid inputs gracefully.
Implement GitHub User Activity Predictions
We need to implement a set of Python functions to analyze and predict GitHub user activity based on their historical data. These functions will use metrics such as
total contributions,active days,account creation date, andcurrent year activityto make predictions about the user’s future behavior, consistency, and milestones.This feature will help us:
Acceptance Criteria
The following functions must be implemented and tested:
predict_long_term_activitytotal_contributions,github_days,current_year_contributions,active_dayspredict_future_active_daysactive_days,github_days,remaining_dayspredict_burnoutactive_days_by_year(list of active days per year)predict_consistencyactive_days,github_dayspredict_account_longevityactive_days_by_yearpredict_effective_ratetotal_contributions,active_days,github_dayspredict_milestonecurrent_contributions,milestone,lifetime_raterun_all_predictionsuser_data(dictionary with all required fields)Steps to Implement
github_predictions.py).Example Input
Example Output
{ "long_term_activity": { "lifetime_rate": 1.37, "current_rate": 3.11, "trend": "increasing" }, "future_active_days": 65.6, "burnout": "Activity is decreasing.", "consistency": "Sporadic contributor.", "account_longevity": "Account activity may cease in ~2.0 years.", "effective_rate": 1.37, "milestone": 3650.0 }Additional Context
datetimemodule for date calculations.Testing
pytestorunittest.