{"id":15064028,"url":"https://github.com/manojkarthick/pcregression","last_synced_at":"2025-04-10T11:50:41.296Z","repository":{"id":57451361,"uuid":"127510353","full_name":"manojkarthick/PCRegression","owner":"manojkarthick","description":"Python package to build principal components regression model using the scikit-learn library.","archived":false,"fork":false,"pushed_at":"2018-04-01T22:57:07.000Z","size":14,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T10:38:52.021Z","etag":null,"topics":["machine-learning","python","scikit-learn"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manojkarthick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-31T07:39:33.000Z","updated_at":"2024-07-24T14:12:58.000Z","dependencies_parsed_at":"2022-09-04T10:11:10.509Z","dependency_job_id":null,"html_url":"https://github.com/manojkarthick/PCRegression","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manojkarthick%2FPCRegression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manojkarthick%2FPCRegression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manojkarthick%2FPCRegression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manojkarthick%2FPCRegression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manojkarthick","download_url":"https://codeload.github.com/manojkarthick/PCRegression/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248215192,"owners_count":21066619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["machine-learning","python","scikit-learn"],"created_at":"2024-09-25T00:10:33.641Z","updated_at":"2025-04-10T11:50:41.262Z","avatar_url":"https://github.com/manojkarthick.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PCRegression\r\nPython package to build principal components regression models using the scikit-learn library. This package follows the same principles as the scikit-learn API and exposes similar `fit` and `predict` methods.\r\n\r\nView it on PyPI at: https://pypi.org/project/PCRegression/\r\n\r\n### Installation\r\nThis tool has been built with python3. Install from PyPI using pip.\r\n\r\n```shell\r\n# If Python3 is your default python, use\r\n$ pip3 install PCRegression\r\n\r\n# If Python 3.x is not your primary version of python, then use\r\n$ pip install PCRegression\r\n```\r\n**NOTE**:   You can check your python version using `python -V`.\r\n\r\n### Examples\r\n\r\nGeneral fit and predict API:\r\n\r\n```python\r\n\r\nX_train, X_test , y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=1)\r\npcr = PCR(n_components = 7)\r\npcr.fit(scale(X_train), y_train) # Scale your predictors for best results.\r\npredictions = pcr.predict(scale(X_test))\r\n```\r\nK-Fold Cross validation using PCR:\r\n\r\n```python\r\nfrom sklearn.model_selection import KFold, cross_val_score\r\npcr = PCR(n_components=7)\r\n\r\nkf_10 = KFold( n_splits=10, shuffle=True, random_state=1)\r\n\r\npcr.fit(scale(X_train), y_train)\r\nX_reduced_train = pcr.get_transformed_data()\r\nregr = pcr.get_regression_model()\r\nn = len(X_reduced_train)\r\n\r\nmse = list()\r\n\r\nscore = -1*cross_val_score(regr, np.ones((n,1)), y_train.ravel(), cv=kf_10, scoring='neg_mean_squared_error').mean()    \r\nmse.append(score)\r\n\r\nfor i in np.arange(1, n):\r\n    score = -1*cross_val_score(regr, X_reduced_train[:,:i], y_train.ravel(), cv=kf_10, scoring='neg_mean_squared_error').mean()\r\n    mse.append(score)\r\n\r\nprint(mse)\r\n```\r\n\r\n### Important Parameters\r\n\r\n* `n_components` : Number of components to keep.\r\n* `copy` : Keep a copy of the data passed to the fit method()\r\n* `random_state` : The seed used by the random number generator\r\n* `fit_intercept` : Whether to calculate the intercept for this model\r\n* `normalize` : If True, the regressors X will be normalized before regression.\r\n\r\n\r\n### Requirements\r\n1. scikit-learn \u003e= 0.13.3\r\n2. numpy \u003e= 1.8.2\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanojkarthick%2Fpcregression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanojkarthick%2Fpcregression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanojkarthick%2Fpcregression/lists"}