diff --git a/README.md b/README.md index 45bcbc4..b762468 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-24ddc0f5d75046c5622901739e7c5dd533143b0c8e959d652212380cedb1ea36.svg)](https://classroom.github.com/a/2OGTtL0Y) # Junior Seminar (CMPSC 580) Own Project Repository ## Semester: Spring 2024 @@ -62,69 +63,69 @@ requirements and it is expected that an exceptional project will exceed these requirements. - **General Project Requirements** - - [ ] The project prototype and proposal were submitted on time on GitHub - - [ ] The pitch slides were submitted on time via the [Google Slides](https://docs.google.com/presentation/d/154V9XquBwLsIVaasJO24e4KglLS9eeVW5e-3mX2OjWc/edit?usp=sharing) - - [ ] The prototype demo video was submitted on time via the [Google Form](https://forms.gle/7UebHZU4CFzfTrY57) - - [ ] The GitHub repository of the project contains evidence of many commits (multiple commits each week) - - [ ] The GitHub repository of the project has a passing build status in GitHub Actions - - [ ] The proposal has the correct format created through the use of Markdown and includes the sections outlined in the provided template - - [ ] The title of the project is both interesting and appropriate - - [ ] The project proposal cites at least ten references, with five references being published, peer-reviewed articles - - [ ] The project proposal consists of at least `2000` words - - [ ] The project proposal follows a logical flow at the level of sections, + - [X] The project prototype and proposal were submitted on time on GitHub + - [X] The pitch slides were submitted on time via the [Google Slides](https://docs.google.com/presentation/d/154V9XquBwLsIVaasJO24e4KglLS9eeVW5e-3mX2OjWc/edit?usp=sharing) + - [X] The prototype demo video was submitted on time via the [Google Form](https://forms.gle/7UebHZU4CFzfTrY57) + - [X] The GitHub repository of the project contains evidence of many commits (multiple commits each week) + - [X] The GitHub repository of the project has a passing build status in GitHub Actions + - [X] The proposal has the correct format created through the use of Markdown and includes the sections outlined in the provided template + - [X] The title of the project is both interesting and appropriate + - [X] The project proposal cites at least ten references, with five references being published, peer-reviewed articles + - [X] The project proposal consists of at least `2000` words + - [X] The project proposal follows a logical flow at the level of sections, subsections, and individual paragraphs - - [ ] The project proposal includes appropriate visual aids, which fall under the broad + - [X] The project proposal includes appropriate visual aids, which fall under the broad categories of: * `image` * `figure` * `table` * `graph` - - [ ] The project proposal highlights and explains the societal impacts and ethical + - [X] The project proposal highlights and explains the societal impacts and ethical implications of the completed research - - [ ] There are no typographical or grammatical errors in the proposal - - [ ] There is no extraneous text in the proposal - - [ ] Prototype contains a README outlining its key features, software and hardware requirements needed to use the prototype, and steps necessary to run the prototype - - [ ] Prototype works as intended - - [ ] Prototype's implementation contains appropriate documentation (comments) + - [X] There are no typographical or grammatical errors in the proposal + - [X] There is no extraneous text in the proposal + - [X] Prototype contains a README outlining its key features, software and hardware requirements needed to use the prototype, and steps necessary to run the prototype + - [X] Prototype works as intended + - [X] Prototype's implementation contains appropriate documentation (comments) The project proposal is required to contain the following five sections: - **Introduction Section Requirements** - - [ ] The introduction section clearly describes the proposed project - - [ ] The introduction section motivates the proposed project work - - [ ] The introduction section contains specific project goals and/or research questions that the project aims to answer + - [X] The introduction section clearly describes the proposed project + - [X] The introduction section motivates the proposed project work + - [X] The introduction section contains specific project goals and/or research questions that the project aims to answer - **Related Work Section Requirements** - - [ ] The related work section references and describes relevant literature - - [ ] The related work section contains concise, scholarly review of the literature + - [X] The related work section references and describes relevant literature + - [X] The related work section contains concise, scholarly review of the literature explaining the background to the proposed research - - [ ] The related work section explains how relevant literature connects to the proposed project and provides the context for the aims of the proposed project in relation to existing work on the topic - - [ ] The related work section does not provide a "laundry list" of the related literature - - [ ] The related work section situates the proposed project in the broader scope + - [X] The related work section explains how relevant literature connects to the proposed project and provides the context for the aims of the proposed project in relation to existing work on the topic + - [X] The related work section does not provide a "laundry list" of the related literature + - [X] The related work section situates the proposed project in the broader scope - **Prototype Section Requirements** - - [ ] The prototype section explains the process utilized in the completed study - - [ ] The prototype section addresses as many of the necessary methodology used in the prototype development. For example, the following may be relevant to the project: + - [X] The prototype section explains the process utilized in the completed study + - [X] The prototype section addresses as many of the necessary methodology used in the prototype development. For example, the following may be relevant to the project: * `description of algorithms` * `programming languages` * `libraries` * `platforms` * `software tools` * `hardware` - - [ ] The prototype section explains how the developed proof-of-concept prototype demonstrates project feasibility (given your prototype, how can we be sure that the full artifact of the proposed project can be successfully completed by you in two semesters) + - [X] The prototype section explains how the developed proof-of-concept prototype demonstrates project feasibility (given your prototype, how can we be sure that the full artifact of the proposed project can be successfully completed by you in two semesters) - **Preliminary Results and Outcomes Section Requirements** - - [ ] The preliminary results and outcomes section describes how the work is validated - - [ ] The preliminary results and outcomes results section includes a description of experiments + - [X] The preliminary results and outcomes section describes how the work is validated + - [X] The preliminary results and outcomes results section includes a description of experiments such that a reader should be able to reproduce them or other results/outcomes as relevant to the prototype - - [ ] The preliminary results and outcomes contains at least one graph, table of data, or + - [X] The preliminary results and outcomes contains at least one graph, table of data, or some other relevant presentation of the results from the experimental study - **Conclusions and Future Work Section Requirements** - - [ ] The conclusions and future Work section provides a summary of the proposed research and its preliminary outcomes - - [ ] The conclusions and future Work section discusses the impact of the proposed research project - - [ ] The conclusions and future Work outlines, with sufficient depth and detail, further and future work that is necessary to fully complete the proposed project - - [ ] The conclusions and future Work includes an literature/evidence- or results-based appraisal of ethical issues related to the proposed research + - [X] The conclusions and future Work section provides a summary of the proposed research and its preliminary outcomes + - [X] The conclusions and future Work section discusses the impact of the proposed research project + - [X] The conclusions and future Work outlines, with sufficient depth and detail, further and future work that is necessary to fully complete the proposed project + - [X] The conclusions and future Work includes an literature/evidence- or results-based appraisal of ethical issues related to the proposed research ## GatorGrade diff --git a/project_proposal.md b/project_proposal.md index 3ec4600..f9a16d4 100644 --- a/project_proposal.md +++ b/project_proposal.md @@ -4,38 +4,65 @@ This document is to contain your project proposal. __As you complete each of the below sections in this document, please be sure to remove all preamble text so that it does not appear in your work.__ -## GitHub Handle: Add Your Name Here +## GitHub Handle: wolff01 -## Name: Add Your Name Here +## Name: William Wolff -## Major: TODO (choose: CS, DS, INFM, SE) +## Major: Computer Science -## Project Title: Enter The Name Of Your Project - -TODO: Create an interesting title for your proposed project that bring a freshness and excitement to the area of this project. Consider using a name that carries some information about what the project and provides some hint at what the project does without being too wordy. +## Project Title: Perfect Timing --- ## Introduction -TODO: Introduce the proposed project, providing a concise summary of the project goals, its key elements, offering the reader a quick understanding of the research's scope. The section continues to outline the main topics, research questions, hypotheses, and /or theories in a clear and meaningful language to provide a type of roadmap for the reader to navigate the forthcoming details of the project. This section also needs to motivate the project by providing context for the study, outlining the current state of knowledge in the field, and highlighting any gaps or limitations in existing research. The section serves as a foundational guide that enables the reader to grasp the context of the study, in addition to its structure, before moving into a more technically-based discussion in the following sections of the article. In short, the "Introduction" section needs to answer the `what` and `why` questions, that is `what is the project?` and `why is the project important?` +The project, Perfect Timing, is a tool that helps analyze the statistics of all qualified batters and what percent of the swings they took were truly efficient swings. In baseball, having the perfect swing is almost impossible to have consistently as it is tough from a physics standpoint. When looking at hitters in Major League Baseball, they have almost great swings and with analytic and metric tracking today, we are able to see what a hitter does on a regular basis. When we take a look at statistics, we see all these numbers that are very deeply thought out but a lot of the statistics do not use facts based around matric results. That is where the tool comes into play. The tool creates the merging factor between given metrics and statistics. It helps as well display who is a valuable hitter and how valuable they are and can be. The person with the more efficient swing should be brought to light and there are more ideas of what can be valued in trading and signing players in the off season. A tool of this type should be valued in the world of baseball to know more for what you can get out of a hitter. This adds another level of importance of what needs to be done when scouting baseball. Most statistics now are very valuable tools and a big part of a hitter to be scouted is consistency. This tool displays the consistency that a player has with his swing being perfect. When seeing other statistics that are used in baseball today, we see a trend of statistics becoming more intertwined with metrics. Metrics are all shown for how the player moves, how the ball goes off his bat. Merging statistics with metrics in baseball can give a better look into what general managers want in a player and using a tool like this can really drive value for players that are being traded. Managers in baseball can also benefit from using this by having the knowledge of who is statistically gonna have the swing to do damage in the line up. Many players can show results of growth and how they are producing in many ways but we can be given a tool that can help in ways that can be a big factor for the game of baseball. ## Literature Review -TODO (10 source minimum, with 5 of those being published peer-reviewed articles): Conduct literature review by describing relevant work related to the project and hence providing an overview of the state of the art in the area of the project. This section serves to contextualize the study within the existing body of literature, presenting a thorough review of relevant prior research and scholarly contributions. In clear and meaningful language, this section aims to demonstrate the problems, gaps, controversies, or unanswered questions that are associated with the current understanding of the topic. In addition, this section serves to highlight the current study's unique contribution to the field. By summarizing and critiquing existing works, this section provides a foundation for readers to appreciate the novelty and significance of the study in relation to the broader academic discourse. The "Literature Review" section further (in detail) contributes to the `why is the project important?` question. +When reading on what can be beneficial for baseball and how statistics have a big impact on the game of baseball, I wanted to further understand what makes statistics valuable and what statistics are truly valued in the game. The article, “Evaluating Baseball Statistics by Predicting Playoff Teams”, by Rohan Nakra and Ryan Kimes explains the correlation of baseball statistics to how a team makes it to the postseason in baseball. The stats that they used and tried to display were mainly team on base percentage, slugging percentage, and earned run average but they could not find a true correlation but understanding the fact of these statistics having a correlation between each other brought a clear understanding of needing to have a correlation of statistics for creating an understanding. Other articles such as “The Relationship between Cognition, Preseason Hitting Assessments, and In-Game Batting Performance in Collegiate Baseball and Softball Players” as well as “Which Statistics in Baseball Are Most Important for Winning?” help gave more reassurance of what statistics and looking into each area more valuably, there was a clear understanding that more statistics can be clearly understood. “Using Real-Life Major League BaseballData in an Introductory Statistics Course” gave clear knowledge of statistical knowledge to be used in this field as well as “Disturbance in Hitting Accuracy by Professional and Collegiate Baseball Players due to Intentional Change of Target Position” which gave an explanation into the flaws of hitting. In addition to this, reading, “Evaluating plate discipline in Major League Baseball with Bayesian Additive Regression Trees”, this clears any confusion when wondering about how a hitter’s vision can affect how valuable his swing could be. Seeing a clear model for how the ball can be missed on the bat from being perfect was crucial and knowing that I had a clear gauge for the data that would be necessary to know before going about making the prototype clear and easy to process. After reading, the first step was to acquire the data that was needed to produce my statistical results. After reading more about what data is the most important and trustworthy, the option was to go with StatCast. Being a Major League Baseball used data tracker created by Google, there is a dashboard created in baseballsavant.com which gives the choice of what data can be used. After selecting the necessary parts of data, the next step was to use stream lit in order to display my results as well as use pandas too to display the final results. ## Prototype -TODO: Discuss the methods of the project to be able to answer the `how` question (`how was this project completed?`). For this section, you must describe the methodology behind your implemented prototype. The methods section in an academic research outlines the specific procedures, techniques, and methodologies employed to conduct the study, offering a transparent and replicable framework for the research. It details the resources behind the work, in terms of, for example, the design of the algorithm and the experiment(s), data collection methods, applied software libraries, required tools, the types of statistical analyses and models which are applied to ensure the rigor and validity of the study. This section provides clarity for other researchers to understand and potentially replicate the study, contributing to the overall reliability and credibility of the research findings. +When thinking about this project and how to go about creating this. First laying out a plan that was going to keep a clear mind set if the goal ahead. The first part of the plan was to make a mathematical equation that can give the correct output and be realistic. The first issue was here as there are so many statistics that exist that could be us but are not the most useful in this case. After trial and error and understanding each statistical measurement for where the statistics that were being used to contribute to this was found and how they were measured, the most efficient to be used in this case, and make the most impact on this were sweet spot percentage and hard hit percentage. Hard hit percentage is calculated as the percent of baseballs that were hit with an exit velocity of 95 miles an hour or harder off the bat. Sweet spot percentage is measured as baseballs that were hit off the bat at any angle between 8 degrees and 32 degrees. When taking a look at a hitter’s hard hit percentage, multiplying that number with the amount of balls hit in play, you get the total number of hard hit balls that a player had that were put in play. Then taking the total amount of swings a player takes in the strike zone and out of the strike zone. We then take that number and divide the amount of hard hit balls in play by total number of swings, we get the percentage of hard hit balls in play per total swings. Then doing that same process but using sweet spot percentage instead of hard hit percentage, we get the percentage of sweet spot hit balls in play per total swings. Taking those two percentages and multiplying the values together we are able to get the percentage of efficient swings a hitter has in a total season. Each part of the equation is clearly labeled when looking in the main.py file and they are all put into a streamlit table and you are given the option to sort the table by either the name of the player in descending order or by swing efficiency percentage in descending order as well. In the main we can see that the creation of each part is split up individually. This also is explained in each comment and docstring written that details every for loop, if statement, and function’s purpose. ## Preliminary Results and Outcomes -TODO: Discuss the outcomes of your project in this section. Depending on the project type, the presented results and outcomes will vary. In some projects, you will be asked to present a theoretical analysis, and in others your experimental study and its results. In this section, you are also to demonstrate an enhanced version of your artifact by showing its capabilities and applications, in light of the evaluation metrics for assessing the artifact +The result of the code came out to create a chart that is 134 lines long and as well display both the results of the math as well as the names of the player that correlates with the results. The outcome was to be expected as that was the intended goal was to display these metrics. The outputs when first creating this code were led to be in a different fashion as before the implementation of the stream lit function, the results were printed through running the python code. While working on this, there were several encounters of flaws in the code such as not being able to display the data properly and manipulating the code to run the correct mathematical equation. The mathematical portion was created in several different parts in order to know exactly how each part would behave in the running of this code. The parts being the addition, multiplication, and division. In the division though it includes the features of the results and how they will be displayed in the code. The more that was inputted into the code.The python code needed to be able to withstand a large inputted csv code from the downloaded baseball savant data. As shown in the example below, it shows the results of a small portion of the data + +|---|------------------|--------------------| +| |Names | Swing Efficiency % | +|---|------------------|--------------------| +|35 |Yoshida, Masataka |2.7721 | +|---|------------------|--------------------| +|97 |Yelich, Christian |1.9420 | +|---|------------------|--------------------| +|107| Witt Jr., Bobby|2.3629 | +|---|------------------|--------------------| +|72 |Walker, Christian |1.6783 | +|---|------------------|--------------------| +|106|Wade Jr., LaMonte |2.2650 | +|---|------------------|--------------------| +|133| Volpe, Anthony |1.7327 | +|---|------------------|--------------------| +|119| Vierling, Matt |2.1328 | +|---|------------------|--------------------| +|99 |Verdugo, Alex |2.9859 | +|---|------------------|--------------------| ## Conclusions and Future Work -TODO: Summarize your work and outline future steps needed to complete to take the project to the next stage (for example, if you were to continue with this project in 600/610). You must also address ethical implications of your project, especially as pertains to the public release or use of your software or methods. +In conclusion, the code runs a parsed set of data given in the form of a csv file and extracts each needed part of the csv file. The will then add the necessary swings in and outside of the zone and have those ready to be part of both quotients later on. Then the code multiplies the total number of balls hit in play twice, once using hard hit percentage and another using sweet spot percentage. Taking each of the products we then go and insert them into the quotient where they each will be divided by the total number of swings and that will give us our answer needed. This code as well displays its results in the form of a chart in stream lit with the help of pandas. This code can have the potential to be very impactful in the world of baseball. Taking part in each of these key ideas is very important and when the product itself is ready to fully be produced it will become a great tool and useful all around. In the future, this project should include more recent data as the 2024 Major League Baseball season has become and as well there should be implementation of data from other years as well. The more data that is put into this code, the more that it will have a chance to display its full potential. Furthermore, there should be a way to implement the code to further read and interpret a single player as an option. Having to isolate the data of one player would be an interesting feature as it can make it more accessible to one person who wants to try and learn more about the value of that player. These features can make it so a person of scouting desire sees this they are able to make intentional moves that can further their team to be successful whether that be reading more into how an opponent is or how they can have the most successful team on the field. ## References -TODO: Add references in the [ACM style](https://www.acm.org/publications/authors/reference-formatting). All references must be cited in the proposal. +Amanda Carrol, Tonya Krupp, Kara Tucker, Nicholas J. Siekirk, and Bradley J. Kendall. 2023. The relationship between cognition, preseason hitting assessments, and in-game batting performance in collegiate baseball and softball players. (January 2023). Retrieved May 3, 2024 from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC10124730/ +Anon. Fundamentals of collecting and analyzing baseball data. Retrieved May 3, 2024a from https://bookdown.org/jjovanovic/jjovanovic/statcast.html +Anon. Pandas. Retrieved May 3, 2024b from https://pandas.pydata.org/ +Anon. Statcast custom leaderboards. Retrieved May 3, 2024c from https://baseballsavant.mlb.com/leaderboard/custom?year=2023&type=batter&filter=&min=600&selections=b_hit_into_play%2Csweet_spot_percent%2Chard_hit_percent%2Cout_zone_swing%2Cin_zone_swing&chart=false&x=b_hit_into_play&y=b_hit_into_play&r=no&chartType=beeswarm&sort=year&sortDir=asc +Anon.Retrieved May 3, 2024e from https://www.jsr.org/hs/index.php/path/article/view/5763/2619 +Anon.Retrieved May 4, 2024d from https://streamlit.io +Clark Ballou-Crawford. 2023. Which statistics in baseball are most important for winning? John Heinrichs Scholarly & Creative Activities Day (2023). DOI:http://dx.doi.org/10.58809/obzv3646 +Ryan Yee and Sameer K. Deshpande. 2024. Evaluating plate discipline in Major League Baseball with bayesian additive regression trees. (March 2024). Retrieved May 3, 2024 from https://www.degruyter.com/document/doi/10.1515/jqas-2023-0048/html +Samuel Wathen and Nicholas D. Rhew. 2019. Using Real‐Life Major League Baseball Data in an introductory statistics course. Decision Sciences Journal of Innovative Education 17, 3 (July 2019), 194–213. DOI:http://dx.doi.org/10.1111/dsji.12185 +Takatoshi Higuchi, Tomoyuki Nagami, Jun Morohoshi, Hiroki Nakata, and Kazuyuki Kanosue. 2013. Disturbance in hitting accuracy by professional and collegiate baseball players due to intentional change of target position. Perceptual and Motor Skills 116, 2 (April 2013), 627–639. DOI:http://dx.doi.org/10.2466/30.23.25.pms.116.2.627-639 diff --git a/src/README.md b/src/README.md index 624d4f0..7910d78 100644 --- a/src/README.md +++ b/src/README.md @@ -1,17 +1,34 @@ # Project Prototype -TODO: The result of your work will be the delivery of some type of proof-of-concept prototype which will likely contain software programming solutions (i.e., Python code, HTML pages, or similar). All source code for the prototype must be stored in this directory. If your prototype uses data, please create `data/` subdirectory in `src/` and include your data file(s) in `src/data/` directory. +The result of your work will be the delivery of some type of proof-of-concept prototype which will likely contain software programming solutions (i.e., Python code, HTML pages, or similar). All source code for the prototype must be stored in this directory. If your prototype uses data, please create `data/` subdirectory in `src/` and include your data file(s) in `src/data/` directory. To allow the user to experience and execute your prototype, you must first explain how to set up the initial conditions to run or use the artifact. Be sure to offer explicit details and instructions regarding the installation of the necessary foundational libraries, drivers, external software projects, containers and similar types of tertiary software which are involved in executing your artifact. Once these initial software installations have been completed, then you are asked to offer the necessary instructions for actually executing the artifact. For this, please provide all command line parameters or associated bash commands for execution. Please remember that users are unwilling to "figure-out" how to use code in absence of the essential instructions concerning the execution of project artifacts. ## Key Features -TODO: Outline the main technical features of your prototype. +The code in the prototype consists of 4 main functions. The addition, multiplication, division, and row range. When running, this code will display the options to the viewer a chart of the data. This data being ran is very significant and points out the value of a hitter's swing and what percent of his swing are truly a perfect ## Requirements -TODO: Include the software and hardware needed to run your prototype. Be sure to specify the versions of software used in your prototype. +Versions needed to run the code: + +Python: 3.10.6 or higher +Streamlit: 1.31.1 ## Using the Prototype -TODO: Provide details for how to run your artifact. Include specific commands and step by step instructions. +In order to use the artifact you must first install the follwing parts: + +```python + +pip install streamlit + +``` + +In order to run the code, you must run: + +```python + +streamlit run main.py + +``` diff --git a/src/data.csv b/src/data.csv new file mode 100644 index 0000000..714d7ea --- /dev/null +++ b/src/data.csv @@ -0,0 +1,135 @@ +"last_name, first_name","player_id","year","b_hit_into_play","sweet_spot_percent","hard_hit_percent","out_zone_swing","in_zone_swing" +"Grisham, Trent","663757","2023","320",".328",".40","245","728" +"Hoerner, Nico","663538","2023","542",".332",".334","383","776" +"LeMahieu, DJ","518934","2023","374",".316",".43","252","632" +"Rodríguez, Julio","677594","2023","481",".318",".52","492","861" +"Springer III, George","543807","2023","491",".322",".399","279","967" +"Raleigh, Cal","663728","2023","356",".365",".41","394","768" +"Smith, Will","669257","2023","387",".375",".416","297","751" +"Hernández, Teoscar","606192","2023","421",".352",".494","483","951" +"Santander, Anthony","623993","2023","443",".33",".46","522","833" +"Acuña Jr., Ronald","660670","2023","562",".336",".552","321","965" +"Casas, Triston","671213","2023","305",".361",".466","234","666" +"Cronenworth, Jake","630105","2023","367",".357",".332","261","720" +"Bogaerts, Xander","593428","2023","492",".283",".346","324","802" +"Varsho, Daulton","662139","2023","396",".343",".361","314","844" +"Bellinger, Cody","641355","2023","424",".38",".314","326","751" +"Marte, Ketel","606466","2023","465",".308",".428","308","823" +"McMahon, Ryan","641857","2023","360",".394",".442","334","966" +"Realmuto, J.T.","592663","2023","357",".362",".433","323","735" +"Muncy, Max","571970","2023","335",".337",".466","312","664" +"Meneses, Joey","608841","2023","484",".329",".417","412","798" +"Drury, Brandon","592273","2023","354",".35",".463","351","662" +"Rosario, Eddie","592696","2023","359",".359",".354","447","648" +"Suwinski, Jack","669261","2023","281",".342",".434","214","675" +"Hays, Austin","669720","2023","384",".31",".401","344","644" +"Semien, Marcus","543760","2023","565",".375",".37","300","1019" +"García, Adolis","666969","2023","386",".36",".497","408","837" +"Castellanos, Nick","592206","2023","447",".365",".432","543","822" +"Happ, Ian","664023","2023","433",".367",".39","334","938" +"Renfroe, Hunter","592669","2023","376",".295",".391","371","695" +"Ohtani, Shohei","660271","2023","357",".356",".542","373","737" +"Robert Jr., Luis","673357","2023","376",".38",".423","470","812" +"Abrams, CJ","682928","2023","451",".326",".359","389","794" +"Nootbaar, Lars","663457","2023","331",".308",".378","175","562" +"Suzuki, Seiya","673548","2023","392",".365",".48","234","766" +"Torkelson, Spencer","679529","2023","440",".332",".509","320","970" +"Yoshida, Masataka","807799","2023","458",".295",".406","293","659" +"Bell, Josh","605137","2023","416",".313",".43","362","796" +"Freeman, Freddie","518692","2023","521",".466",".422","377","1027" +"Guerrero Jr., Vladimir","665489","2023","506",".324",".492","367","867" +"Paredes, Isaac","670623","2023","389",".324",".285","361","719" +"Suárez, Eugenio","553993","2023","395",".377",".43","344","949" +"Ramírez, José","608070","2023","544",".368",".404","388","829" +"Tovar, Ezequiel","678662","2023","420",".364",".362","512","855" +"Arraez, Luis","650333","2023","544",".447",".257","328","774" +"Crawford, J.P.","641487","2023","414",".353",".362","243","772" +"Kwan, Steven","680757","2023","570",".377",".188","286","885" +"Merrifield, Whit","593160","2023","452",".372",".243","358","766" +"Friedl Jr., TJ","670770","2023","409",".32",".276","265","660" +"Díaz, Yandy","650490","2023","433",".305",".54","233","771" +"Lowe, Nathaniel","663993","2023","461",".367",".416","319","1014" +"Tatis Jr., Fernando","665487","2023","438",".315",".493","399","865" +"McNeil, Jeff","643446","2023","526",".321",".274","326","836" +"Ozuna, Marcell","542303","2023","398",".349",".49","375","771" +"Smith, Dominic","642086","2023","438",".37",".308","343","740" +"Anderson, Tim","641313","2023","373",".324",".394","342","696" +"Turner, Trea","607208","2023","490",".361",".422","511","910" +"Vaughn, Andrew","683734","2023","439",".303",".465","384","716" +"Albies, Ozzie","645277","2023","498",".374",".39","490","910" +"Abreu, José","547989","2023","416",".325",".416","454","749" +"Rosario, Amed","642708","2023","414",".338",".394","413","644" +"Outman, James","681546","2023","306",".382",".399","310","772" +"Arozarena, Randy","668227","2023","400",".318",".483","396","757" +"Santana, Carlos","467793","2023","450",".313",".364","307","808" +"Melendez Jr., MJ","669004","2023","367",".346",".496","330","839" +"Correa, Carlos","621043","2023","386",".311",".459","316","668" +"Benintendi, Andrew","643217","2023","477",".409",".27","306","845" +"Arcia, Orlando","606115","2023","389",".306",".411","277","708" +"Swanson, Dansby","621020","2023","413",".351",".397","305","905" +"Seager, Corey","608369","2023","395",".38",".532","266","752" +"Turner, Justin","457759","2023","454",".368",".39","338","863" +"Machado, Manny","592518","2023","440",".302",".459","337","788" +"Bohm, Alec","664761","2023","470",".351",".417","332","790" +"Walker, Christian","572233","2023","463",".326",".404","351","946" +"Alonso, Pete","624413","2023","421",".323",".401","371","750" +"Stephenson, Tyler","663886","2023","331",".335",".435","252","620" +"Contreras, William","661388","2023","417",".271",".487","307","737" +"Chapman, Matt","656305","2023","346",".324",".564","226","836" +"Edman, Tommy","669242","2023","402",".279",".388","253","573" +"Rutschman, Adley","668939","2023","492",".37",".386","358","834" +"Bregman, Alex","608324","2023","537",".358",".382","273","807" +"Carroll, Corbin","682998","2023","450",".327",".409","355","759" +"Harper, Bryce","547180","2023","342",".368",".468","402","637" +"Peña, Jeremy","665161","2023","450",".324",".358","443","781" +"India, Jonathan","663697","2023","352",".372",".386","213","638" +"Reynolds, Bryan","668804","2023","442",".369",".473","353","843" +"Arenado, Nolan","571448","2023","467",".33",".381","421","687" +"Davis, J.D.","605204","2023","334",".335",".452","274","837" +"Soler, Jorge","624585","2023","367",".365",".48","325","697" +"Gurriel Jr., Lourdes","666971","2023","450",".353",".46","333","755" +"Ruiz, Keibert","660688","2023","467",".394",".319","354","610" +"Riley, Austin","663586","2023","475",".352",".492","399","978" +"Canha, Mark","592192","2023","362",".309",".367","246","621" +"Rooker Jr., Brent","667670","2023","295",".373",".495","304","687" +"Profar, Jurickson","595777","2023","374",".377",".318","262","731" +"Hayes, Ke'Bryan","663647","2023","393",".341",".483","301","578" +"Olson, Matt","621566","2023","445",".31",".555","436","1012" +"Devers, Rafael","646240","2023","457",".30",".551","460","896" +"Yelich, Christian","592885","2023","411",".304",".501","339","812" +"Taveras, Leody","665750","2023","401",".352",".431","299","742" +"Verdugo, Alex","657077","2023","458",".354",".376","246","721" +"Henderson, Gunnar","683002","2023","404",".329",".52","316","809" +"Steer, Spencer","668715","2023","447",".353",".371","316","860" +"Jung, Josh","673962","2023","329",".419",".474","340","684" +"Harris II, Michael","671739","2023","408",".346",".485","377","657" +"Candelario, Jeimer","600869","2023","382",".369",".364","343","763" +"Estrada, Thairo","642731","2023","377",".347",".337","389","606" +"Wade Jr., LaMonte","664774","2023","342",".336",".398","192","639" +"Witt Jr., Bobby","677951","2023","529",".344",".456","422","941" +"Díaz, Elias","553869","2023","372",".312",".384","387","700" +"McKinstry, Zach","656716","2023","356",".371",".335","288","703" +"Bichette, Bo","666182","2023","457",".383",".449","408","851" +"Stott, Bryson","681082","2023","494",".364",".352","376","823" +"Lindor, Francisco","596019","2023","472",".358",".439","387","929" +"Thomas, Lane","657041","2023","459",".368",".407","369","776" +"Schwarber, Kyle","656941","2023","373",".343",".488","351","805" +"Hernández, Enrique","571771","2023","374",".31",".337","278","640" +"De La Cruz, Bryan","650559","2023","442",".41",".425","453","782" +"Betts, Mookie","605141","2023","482",".425",".485","230","803" +"Nimmo, Brandon","607043","2023","451",".335",".479","267","939" +"Vierling, Matt","663837","2023","369",".322",".428","293","645" +"Goldschmidt, Paul","502671","2023","435",".356",".508","382","870" +"Garcia, Maikel","672580","2023","360",".369",".506","195","662" +"France, Ty","664034","2023","471",".369",".386","415","875" +"Kim, Ha-Seong","673490","2023","424",".361",".267","261","799" +"Perez, Salvador","521692","2023","411",".38",".44","550","690" +"Giménez, Andrés","665926","2023","452",".299",".27","499","782" +"Adames, Willy","642715","2023","394",".35",".365","447","851" +"Soto, Juan","665742","2023","445",".285",".553","256","782" +"Torres, Gleyber","650402","2023","503",".373",".403","353","885" +"Burger, Jake","669394","2023","347",".334",".496","409","697" +"Tucker, Kyle","663656","2023","492",".354",".459","274","934" +"Báez, Javier","595879","2023","389",".289",".397","480","591" +"Straw, Myles","664702","2023","377",".34",".233","210","667" +"Volpe, Anthony","683011","2023","377",".355",".43","335","784" \ No newline at end of file diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..5b0ff39 --- /dev/null +++ b/src/main.py @@ -0,0 +1,87 @@ +import csv +import streamlit as st +import pandas as pd + +def sum_csv(filename, start_row, end_row, start_col, end_col): + """Addition portion of code""" + with open(filename, 'r') as file: + csv_reader = csv.reader(file) + data = list(csv_reader) + # Reads start and ending of rows + start_row = max(0, min(start_row, len(data)-1)) + end_row = max(start_row, min(end_row, len(data)-1)) + # Reads start and ending of cloumns + start_col = max(0, min(start_col, len(data[0])-1)) + end_col = max(start_col, min(end_col, len(data[0])-1)) + + sums = [] + for i in range(start_row, end_row + 1): + row_sum = sum(float(data[i][j]) for j in range(start_col, end_col + 1)) + sums.append(row_sum) + return sums + +def multiply_csv(filename, start_row, end_row, start_col, end_col): + """Multiplication portion of code""" + with open(filename, 'r') as file: + csv_reader = csv.reader(file) + data = list(csv_reader) + # Reads start and ending of rows + start_row = max(0, min(start_row, len(data)-1)) + end_row = max(start_row, min(end_row, len(data)-1)) + # Reads start and ending of columns + start_col = max(0, min(start_col, len(data[0])-1)) + end_col = max(start_col, min(end_col, len(data[0])-1)) + + products = [] + for i in range(start_row, end_row + 1): + row_product = float(data[i][start_col]) * float(data[i][end_col]) + products.append(row_product) + return products + +def divide_csv(filename, start_row, end_row, start_col, end_col): + """Division portion of code""" + sums = sum_csv(filename, start_row, end_row, start_col, end_col) + products_1 = multiply_csv(filename, start_row, end_row, 3, 4) + products_2 = multiply_csv(filename, start_row, end_row, 3, 5) + + division_results_1 = [] + division_results_2 = [] + for sum_val, prod_val in zip(sums, products_1): + if sum_val != 0: + division_results_2.append(prod_val / sum_val) + else: + division_results_2.append(float('NaN')) + # Adds necessary data to second list + for sum_val, prod_val in zip(sums, products_2): + if sum_val != 0: + division_results_1.append(prod_val / sum_val) + else: + division_results_1.append(float('NaN')) + # Adds necessary data to first list + column_names = [((res_1 * res_2)* 100)for res_1, res_2 in zip(division_results_1, division_results_2)] + # Merges both lists + + st.title("Perfect Timing") + + a = {'Names': csv_row_range(filename, 1, 135),'Swing Efficiency %': column_names} + df = pd.DataFrame.from_dict(a, orient='index') + df = df.transpose() + + sort_column = st.selectbox('Select column to sort by:', df.columns) + df_sorted = df.sort_values(by=sort_column, ascending=False) + + st.table(df_sorted) + +def csv_row_range(filename, start_row_index, end_row_index): + """Range portion of code""" + with open(filename, 'r') as file: + # Reads the csv file + csv_reader = csv.reader(file) + rows = list(csv_reader) + result = [] + for row_index in range(start_row_index, min(end_row_index + 1, len(rows))): + result.append(rows[row_index][0]) + return result + + +divide_csv('data.csv', 1, 135, 6, 7)