A MACHINE LEARNING ANALYZER DEPLOYED INTO A WEBPAGE
Project description
A Machine Learning App for Studying the U.S. Supreme Court Database
Technologies and programming languages utilized
Table of Contents
- Introduction
- Features
- Installation
- Usage
- Data
- Machine Learning Model
- Prediction
- Deployment
- Contributing
- License
- 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 (
decisionDirectionvariable) 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,
pip install SCDB-ML-app
For installing an specific version use:
pip install SCDB-ML-app==version(like 1.0.0)
For updating to the lattest version use teh following code:
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:
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 then, after unzip it go to the main directory and run the app as: In the powershell of Windows,
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
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:
- caseId
- docketId
- caseIssuesId
- voteId
- dateDecision
- decisionType
- usCite
- sctCite
- ledCite
- lexisCite
- term
- naturalCourt
- chief
- docket
- caseName
- dateArgument
- dateRearg
- petitioner
- petitionerState
- respondent
- respondentState
- jurisdiction
- adminAction
- adminActionState
- threeJudgeFdc
- caseOrigin
- caseOriginState
- caseSource
- caseSourceState
- lcDisagreement
- certReason
- lcDisposition
- lcDispositionDirection
- declarationUncon
- caseDisposition
- caseDispositionUnusual
- partyWinning
- precedentAlteration
- voteUnclear
- issue
- issueArea
- decisionDirection
- decisionDirectionDissent
- authorityDecision1
- authorityDecision2
- lawType
- lawSupp
- lawMinor
- majOpinWriter
- majOpinAssigner
- splitVote
- majVotes
- minVotes
- justice
- justiceName
- vote
- opinion
- direction
- majority
- firstAgreement
- 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:
- If it's liberal
- If it's conservative
- 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file SCDB_ML_app-1.1.4-py3-none-any.whl.
File metadata
- Download URL: SCDB_ML_app-1.1.4-py3-none-any.whl
- Upload date:
- Size: 3.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85aa0c40c64660e515f63f04cbd8138b459f31d80d88299222f83d17a97be6bb
|
|
| MD5 |
3f7ff18eb76abf01ccadf6d62c110be0
|
|
| BLAKE2b-256 |
752fb65f890af345487f6d6e9e58a8350d1150b41920943a7e9737d81f2a7491
|