https://github.com/xre22zax/linear-regression-website-sample
Linear regression and prediction for website
https://github.com/xre22zax/linear-regression-website-sample
linear-models linear-regression predective-modeling predictive-analysis predictive-analytics regression-analysis regression-model
Last synced: 4 days ago
JSON representation
Linear regression and prediction for website
- Host: GitHub
- URL: https://github.com/xre22zax/linear-regression-website-sample
- Owner: xre22zax
- Created: 2023-10-22T09:39:04.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-17T11:02:45.000Z (over 1 year ago)
- Last Synced: 2025-02-17T15:16:26.459Z (3 months ago)
- Topics: linear-models, linear-regression, predective-modeling, predictive-analysis, predictive-analytics, regression-analysis, regression-model
- Language: Jupyter Notebook
- Homepage:
- Size: 74.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Linear Regression Analysis of Website Usage Time
This repository contains Python code that explores factors influencing time spent on a website using linear regression.
## Key Findings
- Age and time spent on the website are positively correlated.
- Chrome users tend to spend longer on the website than Safari users.## Files
- website.csv: Contains data on user age, browser type, and time spent on the website (in seconds).
- linear_regression.py: Python script for analysis, including:
- Loading and exploring data
- Building and fitting linear regression models
- Visualizing results
- Making predictions## Dependencies
- pandas
- numpy
- matplotlib.pyplot
- statsmodels.api## Usage
1. Install dependencies: `pip install pandas numpy matplotlib statsmodels`
2. Run the script: `python linear_regression.py`## Key Code Snippets
```python
# Load data
website = pd.read_csv('website.csv')# Model 1: Time vs. Age
model = sm.OLS.from_formula('time_seconds ~ age', website)
results = model.fit()# Model 2: Time vs. Browser
model = sm.OLS.from_formula('time_seconds ~ browser', website)
results = model.fit()# Prediction for 40-year-old
pred40 = results.params[0] + results.params[1]*40
```## Contributing
Feel free to submit issues or pull requests for improvements or additions.
---
## Author
[Reza Sadeghi](https://github.com/xre22zax/)