{"id":20937679,"url":"https://github.com/dnlbb/my-linear-regression","last_synced_at":"2026-04-20T16:03:49.503Z","repository":{"id":330851675,"uuid":"794210939","full_name":"Dnlbb/My-linear-regression","owner":"Dnlbb","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-02T22:28:56.000Z","size":106,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T02:33:26.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dnlbb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-30T17:07:48.000Z","updated_at":"2025-04-10T07:54:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Dnlbb/My-linear-regression","commit_stats":null,"previous_names":["dnlbb/my-linear-regression"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Dnlbb/My-linear-regression","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FMy-linear-regression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FMy-linear-regression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FMy-linear-regression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FMy-linear-regression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dnlbb","download_url":"https://codeload.github.com/Dnlbb/My-linear-regression/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FMy-linear-regression/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32054611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T11:35:06.609Z","status":"ssl_error","status_checked_at":"2026-04-20T11:34:48.899Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T22:38:59.559Z","updated_at":"2026-04-20T16:03:49.498Z","avatar_url":"https://github.com/Dnlbb.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mercedes-Benz USA Price Prediction Model\n\n## Project Overview\n\nThis project is centered around the independent implementation of a linear regression model to predict the prices of Mercedes-Benz cars in the USA. The model is crafted from scratch using NumPy and Python, highlighting the principles of linear regression and gradient descent optimization. Additionally, this project compares the results of our custom model with scikit-learn's built-in LinearRegression model to validate our implementation's effectiveness.\n\n## Data Preparation\n\nThe data includes details such as mileage, user ratings, review counts, and car prices. Here are the steps taken to prepare the data for modeling:\n\n1. Load the data from a CSV file.\n2. Clean and preprocess the data by removing non-numeric characters and converting strings to numerical values.\n3. Filter out entries without pricing data and handle missing values to ensure quality inputs for modeling.\n\n## Implementation Details\n\n### Custom Linear Regression Implementation\n\nThe focus of this project is on the custom implementation of the linear regression algorithm. This process involves manually coding the calculation of the Mean Squared Error (MSE) and its gradient, as well as implementing the gradient descent algorithm to optimize the model parameters.\n\n```python\nimport numpy as np\nimport pandas as pd\n\n# Load and preprocess data\ndf = pd.read_csv('/path/to/usa_mercedes_benz_prices.csv')\ndf['Mileage'] = df['Mileage'].astype(str).str.replace(' mi.', '').str.replace(',', '').astype(float)\ndf['Review Count'] = df['Review Count'].str.replace(',', '').astype(float)\ndf = df.dropna(subset=['Rating'])\ndf = df[df['Price'] != 'Not Priced']\ndf['Price'] = df['Price'].str.replace('$', '').str.replace(',', '').astype(float)\n```\n\n# Prepare features and target\n```python\nfeatures = df[['Mileage', 'Rating', 'Review Count']].values\ntarget = df['Price'].values\n```\n# Custom linear regression functions\n```python\ndef MseError_mat(X, w, y):\n    y_pred = X @ w\n    return np.sum((y - y_pred) ** 2) / len(y_pred)\n\ndef gr_MseError_mat(X, w, y):\n    y_pred = X @ w\n    return 2 / len(X) * X.T @ (y_pred - y)\n\nweights = np.zeros(features.shape[1])\nlearning_rate = 0.000000001\neps = 0.0001\n```\n# Gradient descent for weight optimization\n```python\nfor i in range(1000):\n    cur_weights = weights\n    weights -= learning_rate * gr_MseError_mat(features, cur_weights, target)\n    if np.linalg.norm(cur_weights - weights, ord=2) \u003c= eps:\n        break\n```\n## This project demonstrates the robustness of a self-implemented linear regression model in predicting car prices, backed by a comparative analysis with a well-established machine learning library. The process highlights the educational value of building models from the ground up and understanding the underlying mechanics of machine learning algorithms.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnlbb%2Fmy-linear-regression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnlbb%2Fmy-linear-regression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnlbb%2Fmy-linear-regression/lists"}