From 9e2fb85509c787dba0ea766942872556ca0712e0 Mon Sep 17 00:00:00 2001 From: graceemetz Date: Fri, 17 Oct 2025 23:28:43 -0400 Subject: [PATCH] create proof of concept --- CHANGELOG.md | 8 +- .../02-component-proof-of-concept.md | 21 +-- src/Proof.java | 133 ++++++++++++++++++ 3 files changed, 144 insertions(+), 18 deletions(-) create mode 100644 src/Proof.java diff --git a/CHANGELOG.md b/CHANGELOG.md index a519dfd..aa83d35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,10 @@ the following form: YYYY.0M.0D. - Designed a Data Structures to HTML component - Designed an Artificial Neuron component -- Designed a Library System component \ No newline at end of file +- Designed a Library System component + +## 2025.10.17 + +### Added + +- Designed a proof of concept for an Artificial Neuron component \ No newline at end of file diff --git a/doc/02-component-proof-of-concept/02-component-proof-of-concept.md b/doc/02-component-proof-of-concept/02-component-proof-of-concept.md index 6eac4a8..e4f28db 100644 --- a/doc/02-component-proof-of-concept/02-component-proof-of-concept.md +++ b/doc/02-component-proof-of-concept/02-component-proof-of-concept.md @@ -1,13 +1,11 @@ # Portfolio Part 2: Component Proof-of-Concept -- **Name**: -- **Dot Number**: -- **Due Date**: +- **Name**: Grace Metz +- **Dot Number**: Metz.403 +- **Due Date**: 10/9/25 ## Assignment Overview - - Previously, you brainstormed three ideas, and hopefully you got some feedback as well. However, it's impossible to know how reasonable your design actually is without trying to implement it. Because you're only just learning our full @@ -30,8 +28,6 @@ the more work you can put in now, the better. ## Assignment Checklist - - To be sure you have completed everything on this assignment, we have littered this document with TODO comments. You can browse all of them in VSCode by opening the TODOs window from the sidebar. The icon looks like a tree and will @@ -53,8 +49,6 @@ to the tree diagram (you may remove this one as well): ## Assignment Learning Objectives - - Without learning objectives, there really is no clear reason why a particular assessment or activity exists. Therefore, to be completely transparent, here is what we're hoping you will learn through this particular aspect of the portfolio @@ -68,8 +62,6 @@ project. Specifically, students should be able to: ## Assignment Rubric: 10 Points - - Again, to be completely transparent, most of the portfolio project, except the final submission, is designed as a formative assessment. Formative assessments are meant to provide ongoing feedback in the learning process. Therefore, @@ -114,8 +106,7 @@ Below is further rationale/explanation for the rubric items above: > to create a new design. In you do end up picking one at random, you should > disclose that here as well. - +I believe that the artificial neuron is the one that is the most interesting to me personally, and I also believe that, minus some need for research on machine learning algorithms, the component would likely be fairly simple to implement. At the most basic level, it essentially functions as a calculator; evaluating values based on a pre-set formula and outputting a result. > Once you've argued your choice of design, make a branch in your new repo called > something like `proof-of-concept`. There are many ways to do this, but my @@ -126,8 +117,6 @@ new; then delete this comment --> > we'll want a branch that you can later make a pull request from with all > your changes. - - ## Assignment Tasks As stated previously, your goal with this assignment is to produce a Java @@ -153,8 +142,6 @@ completed the assignment. ### Changelog - - At the end of every assignment, you should update the [CHANGELOG.md](../../CHANGELOG.md) file found in the root of the project folder. Here's what I would expect to see at the minimum: diff --git a/src/Proof.java b/src/Proof.java new file mode 100644 index 0000000..ebdddca --- /dev/null +++ b/src/Proof.java @@ -0,0 +1,133 @@ +import java.util.ArrayList; +import java.util.Scanner; + +/** + * Very simple implementation of the methods in the Artificial Neuron component. + * + * @author Grace Metz + * + */ +public final class Proof { + + /** + * To prevent instantiation. + */ + private Proof() { + } + + /** + * Ensure that inputs are valid and usable by the neuron. + * + * @param inputs + * the list of inputs + * @param input + * the String being entered + */ + public static void setInput(ArrayList inputs, String input) { + if (!input.equals(" ") && !input.isEmpty() && input.length() > 1) { + inputs.add(input); + } else { + System.out.println("Input must be a word."); + } + } + + /** + * Set all weights and ensure they are usable by the neuron. + * + * @param weights + * the list of weights + * @param weight + * the weight being entered + */ + public static void setWeight(ArrayList weights, double weight) { + if (weight >= -1 && weight <= 1) { + weights.add(weight); + } else { + System.out.println("Weight must be between -1 and 1."); + } + + } + + /** + * Sum the weights. + * + * @param weights + * the list of weights + * + * @return the sum of the weights + */ + public static double sum(ArrayList weights) { + double sum = 0; + + for (int i = 0; i < weights.size(); i++) { + sum = sum + weights.get(i); + } + + return sum; + } + + /** + * Using the sigmoid activation function: an output >= 0.5 means a yes, or + * the neuron has fired. + * + * @param sum + * the sum of the weights + * + * @return whether the neuron has fired. + */ + public static boolean activate(double sum) { + double s = 1.0 / (1.0 + Math.exp(-sum)); + boolean fired = false; + + if (s >= 0.5) { + fired = true; + } + + return fired; + } + + /** + * Main. + * + * @param args + */ + public static void main(String[] args) { + // Decide whether today is a good day to go windsurfing + // (conditions should be sunny and windy) + // Using methods setWeight, setInput, activate, and sum + + Scanner in = new Scanner(System.in); + + ArrayList words = new ArrayList<>(); + ArrayList importance = new ArrayList<>(); + + System.out.println( + "Please enter a word that describes today's weather: "); + String word = in.nextLine(); + setInput(words, word); + System.out.println( + "Please enter how good that condition is for windsurfing (-1 to 1): "); + setWeight(importance, Double.parseDouble(in.nextLine())); + System.out.println("Enter another word? (y/n): "); + String loop = in.nextLine(); + + while (loop.equals("Y")) { + System.out.println( + "Please enter a word that describes today's weather: "); + word = in.nextLine(); + setInput(words, word); + System.out.println( + "Please enter how good that condition is for windsurfing (-1 to 1): "); + setWeight(importance, Double.parseDouble(in.nextLine())); + System.out.println("Enter another word? (y/n): "); + loop = in.nextLine(); + } + + double total = sum(importance); + + System.out.println("Today is a good day for windsurfing: "); + System.out.println(activate(total)); + + in.close(); + } +}