# A Machine Learning App for Studying the U.S. Supreme Court Database
[![Static Badge](https://img.shields.io/badge/pypi-v1.3.0-blue)](https://pypi.org/project/SCDB-ML-app/1.3.0/)
[![Static Badge](https://img.shields.io/badge/license-APGL3.0-green)](https://github.com/havurquijo/Project-SCDB/blob/v1.0.1-alpha/LICENSE.txt)
[![Static Badge](https://img.shields.io/badge/data_analyzed%3A-SCDB-AD1313)](http://scdb.wustl.edu/about.php)
[![Static Badge](https://img.shields.io/badge/running_on%3A-AWS(ec2)-red)](http://18.222.133.83:5000/)
## Technologies and programming languages utilized
1. Python -> Mining and processing data, also creating the predictive model and web page app.
2. Flask -> Based in python for creating the web page.
3. HTML -> Structuring the web page.
4. CSS -> To style the web page.
5. JavaScript -> Triguering actions like notifications.
6. Versioning -> PyPi and Github
7. Deployment -> Server in AWS EC2 technology
# Table of Contents
1. [Introduction](#introduction)
2. [Features](#features)
3. [Installation](#installation)
4. [Usage](#usage)
1. [Running the App](#running-the-app)
2. [Endpoints](#endpoints)
5. [Data](#data)
1. [Dataset Description](#dataset-description)
2. [Preprocessing](#preprocessing)
6. [Machine Learning Model](#machine-learning-model)
1. [Model Selection](#model-selection)
2. [Training the Model](#training-the-model)
3. [Model Evaluation](#model-evaluation)
7. [Prediction](#prediction)
1. [DecisionDirection Variable](#decisiondirection-variable)
2. [Prediction Accuracy](#prediction-accuracy)
8. [Deployment](#deployment)
9. [Contributing](#contributing)
10. [License](#license)
11. [Contact](#contact)
# Introduction
This application leverages machine learning techniques to analyze the U.S. Supreme Court Database. Built with Python and Flask, this app utilizes the scikit-learn library, specifically the Decision Tree Classifier, to predict the variable `decisionDirection` with up to 96% accuracy. The primary goal of this project is to provide insights into the Supreme Court's decisions and to offer a predictive model for legal researchers, students, and enthusiasts.
By integrating Flask for the web framework and scikit-learn for machine learning, the application offers a user-friendly interface and robust analytical capabilities. Users can interact with the app to train the model and generate predictions based on the data provided by the Supreme Court site. This README.md provides detailed instructions on installation, usage, and the underlying methodologies used in this project.
This project is also deployd into a AWS server running online. See the link in the section befor the table of content (#a-machine-learning-app-for-studying-the-u.s.-supreme-court-database)
# Features
- **Historical Data Analysis**: Explore and analyze historical Supreme Court decisions using various filters and parameters (incoming in future releases).
- **Predictive Modeling**: Utilize the Decision Tree Classifier to predict the outcome of Supreme Court decisions (`decisionDirection` variable) with up to 96% accuracy. (In future releases, other machine learning models may be used).
- **Interactive Dashboard**: A user-friendly interface that allows users to interact with the data, view trends, and generate visualizations.
- **Data Visualization**: Generate charts and graphs to visualize decision trends, justice voting patterns, and other relevant statistics (incoming in future releases).
- **Custom Predictions**: Train the model with different parameters to generate custom predictions on Supreme Court decisions.
- **Model Insights**: Understand the model's decision-making process with feature importance and decision tree visualization.
- **Responsive Design**: Ensure the app is accessible on various devices, including desktops, tablets, and smartphones.
- **Documentation and Tutorials**: Provide comprehensive documentation and tutorials to help users understand and use the application effectively.
# Installation
You can install this application in your machine and access the webpage in your localhost by installing it throught PyPi installer,
```shell
pip install SCDB-ML-app
```
For installing an specific version use:
```shell
pip install SCDB-ML-app==version(like 1.0.0)
```
For updating to the lattest version use teh following code:
```shell
pip install --update SCDB-ML-app
```
# Usage
## Running the App
If installed you should import it and then run it into a python enviroment as:
```python
from scdb_ml_app import SCDB_ML_app as flskapp
if __name__ == "__main__":
flaskapp.app.run('0.0.0.0')
```
This will run the aplication in all the available address at the port 5000.
If you download the aplication via [Github](https://github.com/havurquijo/Project-SCDB) then, after unzip it go to the main directory and run the app as:
In the powershell of Windows,
```shell
py -m scdb_ml_app.SCDB_ML_app
```
That way it's granted to run the app as a module of python and the internal relative imports will work.
# Data
## Dataset Description
The Supreme Court Database is the definitive source for researchers, students, journalists, and citizens interested in the U.S. Supreme Court. The Database contains over two hundred pieces of information about each case decided by the Court between the 1791 and 2022 terms. Examples include the identity of the court whose decision the Supreme Court reviewed, the parties to the suit, the legal provisions considered in the case, and the votes of the Justices.[Database webpage](http://scdb.wustl.edu/index.php)
The data we are using in this application is the Modern release and includes terms from 1946 up to 2022. It contains 82,538 records of the votes of the 9 judges for each case, covering more than 9,000 cases. Each column has an attributed variable which has a numerical value for all registers, those variables are:
1. caseId
2. docketId
3. caseIssuesId
4. voteId
5. dateDecision
6. decisionType
7. usCite
8. sctCite
9. ledCite
10. lexisCite
11. term
12. naturalCourt
13. chief
14. docket
15. caseName
16. dateArgument
17. dateRearg
18. petitioner
19. petitionerState
20. respondent
21. respondentState
22. jurisdiction
23. adminAction
24. adminActionState
25. threeJudgeFdc
26. caseOrigin
27. caseOriginState
28. caseSource
29. caseSourceState
30. lcDisagreement
31. certReason
32. lcDisposition
33. lcDispositionDirection
34. declarationUncon
35. caseDisposition
36. caseDispositionUnusual
37. partyWinning
38. precedentAlteration
39. voteUnclear
40. issue
41. issueArea
42. decisionDirection
43. decisionDirectionDissent
44. authorityDecision1
45. authorityDecision2
46. lawType
47. lawSupp
48. lawMinor
49. majOpinWriter
50. majOpinAssigner
51. splitVote
52. majVotes
53. minVotes
54. justice
55. justiceName
56. vote
57. opinion
58. direction
59. majority
60. firstAgreement
61. secondAgreement
## Preprocessing
If the data provided by the site is not downloaded to the server when trying to train the model, the application will redirect to a page to execute the download. After that, the application will take the variables used in the Decision Tree Classifier machine learning algorithm and produce a file with the extension *.csv containing the chosen variables. Additionally, a process to eliminate NaN values will occur.
The variable we want to analyze is the `decisionDirection`, which indicates the direction of each judge's decision for each case. It can take up to three values that indicate the political direction of each decision:
1. If it's liberal
2. If it's conservative
3. If it isn't specified
For simplicity, we deleted the unspecified values of this variable during preprocessing. A few registers survive the preprocessing process, but enought to make a prediction model.
# Machine Learning Model
## Model Selection
## Training the Model
## Model Evaluation
# Prediction
## DecisionDirection Variable
## Prediction Accuracy
# Deployment
# Contributing
# License
SCDB-ML-app is a deployed app to analyze the U.S. Supreme Court Database
Copyright (C) 2024 HERMES A. V. URQUIJO
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
# Contact
Raw data
{
"_id": null,
"home_page": "https://github.com/havurquijo/Project-SCDB",
"name": "SCDB-ML-app",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "MACHINE, LEARNING, SCDB, SUPREME, COURT, WEBPAGE",
"author": "HERMES A V URQUIJO",
"author_email": "hvurquijo@gmail.com",
"download_url": "https://github.com/havurquijo/Project-SCDB/archive/refs/tags/v1.0.0-alpha.tar.gz",
"platform": null,
"description": "# A Machine Learning App for Studying the U.S. Supreme Court Database\r\n[![Static Badge](https://img.shields.io/badge/pypi-v1.3.0-blue)](https://pypi.org/project/SCDB-ML-app/1.3.0/) \r\n[![Static Badge](https://img.shields.io/badge/license-APGL3.0-green)](https://github.com/havurquijo/Project-SCDB/blob/v1.0.1-alpha/LICENSE.txt) \r\n[![Static Badge](https://img.shields.io/badge/data_analyzed%3A-SCDB-AD1313)](http://scdb.wustl.edu/about.php) \r\n[![Static Badge](https://img.shields.io/badge/running_on%3A-AWS(ec2)-red)](http://18.222.133.83:5000/) \r\n\r\n## Technologies and programming languages utilized\r\n1. Python -> Mining and processing data, also creating the predictive model and web page app.\r\n2. Flask -> Based in python for creating the web page.\r\n3. HTML -> Structuring the web page.\r\n4. CSS -> To style the web page.\r\n5. JavaScript -> Triguering actions like notifications.\r\n6. Versioning -> PyPi and Github\r\n7. Deployment -> Server in AWS EC2 technology\r\n\r\n# Table of Contents\r\n\r\n1. [Introduction](#introduction)\r\n2. [Features](#features)\r\n3. [Installation](#installation)\r\n4. [Usage](#usage)\r\n 1. [Running the App](#running-the-app)\r\n 2. [Endpoints](#endpoints)\r\n5. [Data](#data)\r\n 1. [Dataset Description](#dataset-description)\r\n 2. [Preprocessing](#preprocessing)\r\n6. [Machine Learning Model](#machine-learning-model)\r\n 1. [Model Selection](#model-selection)\r\n 2. [Training the Model](#training-the-model)\r\n 3. [Model Evaluation](#model-evaluation)\r\n7. [Prediction](#prediction)\r\n 1. [DecisionDirection Variable](#decisiondirection-variable)\r\n 2. [Prediction Accuracy](#prediction-accuracy)\r\n8. [Deployment](#deployment)\r\n9. [Contributing](#contributing)\r\n10. [License](#license)\r\n11. [Contact](#contact)\r\n\r\n# Introduction\r\n\r\nThis application leverages machine learning techniques to analyze the U.S. Supreme Court Database. Built with Python and Flask, this app utilizes the scikit-learn library, specifically the Decision Tree Classifier, to predict the variable `decisionDirection` with up to 96% accuracy. The primary goal of this project is to provide insights into the Supreme Court's decisions and to offer a predictive model for legal researchers, students, and enthusiasts.\r\n\r\nBy integrating Flask for the web framework and scikit-learn for machine learning, the application offers a user-friendly interface and robust analytical capabilities. Users can interact with the app to train the model and generate predictions based on the data provided by the Supreme Court site. This README.md provides detailed instructions on installation, usage, and the underlying methodologies used in this project.\r\n\r\nThis project is also deployd into a AWS server running online. See the link in the section befor the table of content (#a-machine-learning-app-for-studying-the-u.s.-supreme-court-database)\r\n\r\n\r\n# Features\r\n\r\n- **Historical Data Analysis**: Explore and analyze historical Supreme Court decisions using various filters and parameters (incoming in future releases).\r\n- **Predictive Modeling**: Utilize the Decision Tree Classifier to predict the outcome of Supreme Court decisions (`decisionDirection` variable) with up to 96% accuracy. (In future releases, other machine learning models may be used).\r\n- **Interactive Dashboard**: A user-friendly interface that allows users to interact with the data, view trends, and generate visualizations.\r\n- **Data Visualization**: Generate charts and graphs to visualize decision trends, justice voting patterns, and other relevant statistics (incoming in future releases).\r\n- **Custom Predictions**: Train the model with different parameters to generate custom predictions on Supreme Court decisions.\r\n- **Model Insights**: Understand the model's decision-making process with feature importance and decision tree visualization.\r\n- **Responsive Design**: Ensure the app is accessible on various devices, including desktops, tablets, and smartphones.\r\n- **Documentation and Tutorials**: Provide comprehensive documentation and tutorials to help users understand and use the application effectively.\r\n\r\n\r\n# Installation\r\nYou can install this application in your machine and access the webpage in your localhost by installing it throught PyPi installer,\r\n\r\n```shell\r\npip install SCDB-ML-app\r\n```\r\nFor installing an specific version use:\r\n```shell\r\npip install SCDB-ML-app==version(like 1.0.0)\r\n```\r\nFor updating to the lattest version use teh following code:\r\n```shell\r\npip install --update SCDB-ML-app\r\n```\r\n\r\n# Usage\r\n## Running the App\r\nIf installed you should import it and then run it into a python enviroment as:\r\n```python\r\nfrom scdb_ml_app import SCDB_ML_app as flskapp\r\n\r\nif __name__ == \"__main__\":\r\n flaskapp.app.run('0.0.0.0')\r\n```\r\nThis will run the aplication in all the available address at the port 5000.\r\n\r\nIf you download the aplication via [Github](https://github.com/havurquijo/Project-SCDB) then, after unzip it go to the main directory and run the app as:\r\nIn the powershell of Windows,\r\n```shell\r\npy -m scdb_ml_app.SCDB_ML_app \r\n```\r\nThat way it's granted to run the app as a module of python and the internal relative imports will work.\r\n\r\n\r\n# Data\r\n## Dataset Description\r\nThe Supreme Court Database is the definitive source for researchers, students, journalists, and citizens interested in the U.S. Supreme Court. The Database contains over two hundred pieces of information about each case decided by the Court between the 1791 and 2022 terms. Examples include the identity of the court whose decision the Supreme Court reviewed, the parties to the suit, the legal provisions considered in the case, and the votes of the Justices.[Database webpage](http://scdb.wustl.edu/index.php)\r\n\r\nThe data we are using in this application is the Modern release and includes terms from 1946 up to 2022. It contains 82,538 records of the votes of the 9 judges for each case, covering more than 9,000 cases. Each column has an attributed variable which has a numerical value for all registers, those variables are:\r\n\r\n1. caseId \r\n2. docketId\r\n3. caseIssuesId\r\n4. voteId\r\n5. dateDecision\r\n6. decisionType\r\n7. usCite\r\n8. sctCite\r\n9. ledCite\r\n10. lexisCite\r\n11. term\r\n12. naturalCourt\r\n13. chief\r\n14. docket\r\n15. caseName\r\n16. dateArgument\r\n17. dateRearg\r\n18. petitioner\r\n19. petitionerState\r\n20. respondent\r\n21. respondentState\r\n22. jurisdiction\r\n23. adminAction\r\n24. adminActionState\r\n25. threeJudgeFdc\r\n26. caseOrigin\r\n27. caseOriginState\r\n28. caseSource\r\n29. caseSourceState\r\n30. lcDisagreement\r\n31. certReason\r\n32. lcDisposition\r\n33. lcDispositionDirection\r\n34. declarationUncon\r\n35. caseDisposition\r\n36. caseDispositionUnusual\r\n37. partyWinning\r\n38. precedentAlteration\r\n39. voteUnclear\r\n40. issue\r\n41. issueArea\r\n42. decisionDirection\r\n43. decisionDirectionDissent\r\n44. authorityDecision1\r\n45. authorityDecision2\r\n46. lawType\r\n47. lawSupp\r\n48. lawMinor\r\n49. majOpinWriter\r\n50. majOpinAssigner\r\n51. splitVote\r\n52. majVotes\r\n53. minVotes\r\n54. justice\r\n55. justiceName\r\n56. vote\r\n57. opinion\r\n58. direction\r\n59. majority\r\n60. firstAgreement\r\n61. secondAgreement\r\n\r\n## Preprocessing\r\nIf the data provided by the site is not downloaded to the server when trying to train the model, the application will redirect to a page to execute the download. After that, the application will take the variables used in the Decision Tree Classifier machine learning algorithm and produce a file with the extension *.csv containing the chosen variables. Additionally, a process to eliminate NaN values will occur.\r\n\r\nThe variable we want to analyze is the `decisionDirection`, which indicates the direction of each judge's decision for each case. It can take up to three values that indicate the political direction of each decision:\r\n\r\n1. If it's liberal\r\n2. If it's conservative\r\n3. If it isn't specified\r\n\r\nFor simplicity, we deleted the unspecified values of this variable during preprocessing. A few registers survive the preprocessing process, but enought to make a prediction model.\r\n\r\n\r\n# Machine Learning Model\r\n## Model Selection\r\n\r\n\r\n## Training the Model\r\n\r\n\r\n## Model Evaluation\r\n\r\n\r\n# Prediction\r\n## DecisionDirection Variable\r\n\r\n\r\n## Prediction Accuracy\r\n\r\n\r\n# Deployment\r\n\r\n\r\n# Contributing\r\n\r\n\r\n# License\r\nSCDB-ML-app is a deployed app to analyze the U.S. Supreme Court Database\r\nCopyright (C) 2024 HERMES A. V. URQUIJO\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU Affero General Public License as\r\npublished by the Free Software Foundation, either version 3 of the\r\nLicense, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\nGNU Affero General Public License for more details.\r\n\r\nYou should have received a copy of the GNU Affero General Public License\r\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\r\n\r\n# Contact\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "AGPL 3.0",
"summary": "A MACHINE LEARNING ANALYZER DEPLOYED INTO A WEBPAGE",
"version": "1.3.1",
"project_urls": {
"Download": "https://github.com/havurquijo/Project-SCDB/archive/refs/tags/v1.0.0-alpha.tar.gz",
"Homepage": "https://github.com/havurquijo/Project-SCDB"
},
"split_keywords": [
"machine",
" learning",
" scdb",
" supreme",
" court",
" webpage"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e37710aeee3298db744b27c0b48e2c87b70370e5f80ff852aa33cdeeb1865297",
"md5": "1240e91982db2c9e4478dbf411746c05",
"sha256": "8427ebb4a69af35fa97c4c0826c49c68c49b3c489e8167e56f12fc9d47a5d9ec"
},
"downloads": -1,
"filename": "SCDB_ML_app-1.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1240e91982db2c9e4478dbf411746c05",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5511997,
"upload_time": "2024-06-06T04:18:12",
"upload_time_iso_8601": "2024-06-06T04:18:12.637162Z",
"url": "https://files.pythonhosted.org/packages/e3/77/10aeee3298db744b27c0b48e2c87b70370e5f80ff852aa33cdeeb1865297/SCDB_ML_app-1.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-06 04:18:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "havurquijo",
"github_project": "Project-SCDB",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "scdb-ml-app"
}