Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dms-codes/mean-squared-error
https://github.com/dms-codes/mean-squared-error
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dms-codes/mean-squared-error
- Owner: dms-codes
- Created: 2024-12-07T02:11:29.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-12-07T02:11:57.000Z (about 1 month ago)
- Last Synced: 2024-12-07T03:19:01.770Z (about 1 month ago)
- Language: Python
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mean Squared Error (MSE) Calculation
This file demonstrates two ways to calculate the Mean Squared Error (MSE) between two lists of values:
1. **Manual Calculation:**
- The `mean_squared_error` function calculates the MSE directly by:
- Checking for equal lengths of input lists.
- Calculating the squared difference between corresponding values.
- Summing the squared errors.
- Dividing the sum of squared errors by the number of data points.2. **Using scikit-learn:**
- The `calculate_mse` function leverages the `mean_squared_error` function from the scikit-learn library for efficient and concise MSE calculation.## Example Usage
Both functions can be used as follows:
```python
actual = [2, 3, 5, 5, 9]
calculated = [3, 3, 8, 7, 6]# Manual Calculation
mse_manual = mean_squared_error(actual, calculated)
print(f"Mean Squared Error (Manual): {mse_manual}")# Using scikit-learn
mse_sklearn = calculate_mse(actual, calculated)
print(f"Mean Squared Error (scikit-learn): {mse_sklearn}")