From 9e2fb85509c787dba0ea766942872556ca0712e0 Mon Sep 17 00:00:00 2001 From: graceemetz Date: Fri, 17 Oct 2025 23:28:43 -0400 Subject: [PATCH 1/4] 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(); + } +} From 6c21fc219b8b97a8f8a54625ca12cf10a08041ea Mon Sep 17 00:00:00 2001 From: graceemetz Date: Tue, 11 Nov 2025 22:08:00 -0500 Subject: [PATCH 2/4] Created interface --- CHANGELOG.md | 12 ++--- .../03-component-interfaces.md | 10 ++-- .../META-INF/MANIFEST.MF | 7 +++ .../components/xmltree/tag_icon.gif | Bin 0 -> 161 bytes .../components/xmltree/text_icon.gif | Bin 0 -> 64 bytes src/NeuronKernel.java | 46 ++++++++++++++++++ src/NeuronSecondary.java | 32 ++++++++++++ 7 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 lib/components (3).jar_unzipped/META-INF/MANIFEST.MF create mode 100644 lib/components (3).jar_unzipped/components/xmltree/tag_icon.gif create mode 100644 lib/components (3).jar_unzipped/components/xmltree/text_icon.gif create mode 100644 src/NeuronKernel.java create mode 100644 src/NeuronSecondary.java diff --git a/CHANGELOG.md b/CHANGELOG.md index aa83d35..d2b53eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Calendar Versioning](https://calver.org/) of the following form: YYYY.0M.0D. -## 2025.09.21 +## 2025.11.11 ### Added -- Designed a Data Structures to HTML component -- Designed an Artificial Neuron component -- Designed a Library System component +- Designed kernel and enhanced interfaces for the Artifical Neuron component -## 2025.10.17 +### Updated -### Added - -- Designed a proof of concept for an Artificial Neuron component \ No newline at end of file +- Changed design to include queues representing each set of weights and inputs \ No newline at end of file diff --git a/doc/03-component-interfaces/03-component-interfaces.md b/doc/03-component-interfaces/03-component-interfaces.md index c1f96cd..cfd3dad 100644 --- a/doc/03-component-interfaces/03-component-interfaces.md +++ b/doc/03-component-interfaces/03-component-interfaces.md @@ -1,8 +1,8 @@ # Portfolio Part 3: Component Interfaces -- **Name**: -- **Dot Number**: -- **Due Date**: +- **Name**: Grace Metz +- **Dot Number**: metz.403 +- **Due Date**: 10/23 12:40pm ## Assignment Overview @@ -132,8 +132,6 @@ hierarchy diagram using whatever tools you would like. Then, include a picture of it in this folder. You may also embed it just below using markdown syntax (i.e., `![ALT TEXT](path/to/file)`). - - To start making your interfaces, make a branch off of main in your new repo called something like `interfaces`. There are many ways to do this, but my preference is to use GitHub Desktop. From there, you can click the `Branch` @@ -154,8 +152,6 @@ to see them. If you don't like this workflow, you may try following the rebase strategies described [here](https://stackoverflow.com/questions/35790561/working-while-waiting-for-pending-pr) and [here](https://stackoverflow.com/questions/18021888/continue-working-on-a-git-branch-after-making-a-pull-request). - - ## Assignment Tasks Your primary task for this assignment is to draft two interfaces in line with diff --git a/lib/components (3).jar_unzipped/META-INF/MANIFEST.MF b/lib/components (3).jar_unzipped/META-INF/MANIFEST.MF new file mode 100644 index 0000000..e3efe62 --- /dev/null +++ b/lib/components (3).jar_unzipped/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.10.12 +Created-By: 19.0.1+10-21 (Oracle Corporation) +Built-By: Paolo Bucci +Sealed: false +Built-On: 2023-01-01 10:30:08 + diff --git a/lib/components (3).jar_unzipped/components/xmltree/tag_icon.gif b/lib/components (3).jar_unzipped/components/xmltree/tag_icon.gif new file mode 100644 index 0000000000000000000000000000000000000000..b857aa2106ff36d6c08b32d1d0e6f5c54aed44f1 GIT binary patch literal 161 zcmZ?wbhEHb0+gc<}I99wQB$uu-@+;r@9 zaF98+prm<*gM)+uUwhMp12!s5T@MpN3%JA<1sqHWSRlsW^eDrV!OVp9(4Ltg>nC$C GSOWlNBt9x{_(i*`qgn)=HIb O^PHgGHmzKQ!5RQb?i0TN literal 0 HcmV?d00001 diff --git a/src/NeuronKernel.java b/src/NeuronKernel.java new file mode 100644 index 0000000..047c2cd --- /dev/null +++ b/src/NeuronKernel.java @@ -0,0 +1,46 @@ +import components.queue.Queue; +import components.queue.Queue1L; +import components.standard.Standard; + +/** + * Interface for the essential methods and values within the Artificial Neuron + * component. + * + * @author Grace Metz + * + */ +public interface NeuronKernel extends Standard { + + /** + * Queue of Strings to represent the values of each input. + */ + Queue inputs = new Queue1L<>(); + + /** + * Queue of values to represent the weights of each input. + */ + Queue weight = new Queue1L<>(); + + /** + * Retrieve the weight assigned to the inputs within this node. + * + * @return the queue of weight values + */ + Queue weights(); + + /** + * Return the inputs entered into the neuron. + * + * @return the queue of input Strings + */ + Queue inputs(); + + /** + * Ensure that inputs are valid and usable by the neuron. + * + * @param value + * the String value being entered + */ + void setInput(String value); + +} diff --git a/src/NeuronSecondary.java b/src/NeuronSecondary.java new file mode 100644 index 0000000..44eac6d --- /dev/null +++ b/src/NeuronSecondary.java @@ -0,0 +1,32 @@ +/** + * Interface for additional methods within the Artificial Neuron component. + * + * @author Grace Metz + * + */ +public interface NeuronSecondary extends NeuronKernel { + + /** + * Using the sigmoid activation function: an output >= 0.5 means a yes, or + * the neuron has fired. + * + * @return whether the neuron has fired. + */ + boolean activate(); + + /** + * Set an object's weight and ensure they are usable by the neuron. + * + * @param value + * the weight being entered + */ + void setWeight(int value); + + /** + * Sum the weights. + * + * @return the sum of the weights. + */ + int sum(); + +} From 8ee540fed0ac03fbd7cf4b3c8712b0e653a10f8d Mon Sep 17 00:00:00 2001 From: graceemetz Date: Tue, 11 Nov 2025 23:27:02 -0500 Subject: [PATCH 3/4] designed abstract class --- CHANGELOG.md | 19 ++++- .../04-component-abstract-class.md | 6 +- src/Neuron.java | 33 +++++++++ src/NeuronKernel.java | 4 +- src/NeuronSecondary.java | 72 ++++++++++++++++--- 5 files changed, 119 insertions(+), 15 deletions(-) create mode 100644 src/Neuron.java diff --git a/CHANGELOG.md b/CHANGELOG.md index d2b53eb..f9aa412 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,24 @@ the following form: YYYY.0M.0D. ### Added - Designed kernel and enhanced interfaces for the Artifical Neuron component +- Created an abstract class for Neuron (NeuronSecondary), implementing both common and secondary methods ### Updated -- Changed design to include queues representing each set of weights and inputs \ No newline at end of file +- Changed design to include queues representing each set of weights and inputs +- Fixed naming of interfaces to better match the convention +- Changed some data types within methods in order to better execute the component's function + +## 2025.10.17 + +### Added + +- Designed a proof of concept for an Artificial Neuron component + +## 2025.09.21 + +### Added + +- Designed a Data Structures to HTML component +- Designed an Artificial Neuron component +- Designed a Library System component \ No newline at end of file diff --git a/doc/04-component-abstract-class/04-component-abstract-class.md b/doc/04-component-abstract-class/04-component-abstract-class.md index 6abbad3..9206ba6 100644 --- a/doc/04-component-abstract-class/04-component-abstract-class.md +++ b/doc/04-component-abstract-class/04-component-abstract-class.md @@ -1,8 +1,8 @@ # Portfolio Part 4: Abstract Class -- **Name**: -- **Dot Number**: -- **Due Date**: +- **Name**: Grace Metz +- **Dot Number**: Metz.403 +- **Due Date**: 10/31 11:40am ## Assignment Overview diff --git a/src/Neuron.java b/src/Neuron.java new file mode 100644 index 0000000..257a7b8 --- /dev/null +++ b/src/Neuron.java @@ -0,0 +1,33 @@ + +/** + * Interface for additional methods within the Artificial Neuron component. + * + * @author Grace Metz + * + */ +public interface Neuron extends NeuronKernel { + + /** + * Using the sigmoid activation function: an output >= 0.5 means a yes, or + * the neuron has fired. + * + * @return whether the neuron has fired. + */ + boolean activate(); + + /** + * Set an object's weight and ensure they are usable by the neuron. + * + * @param value + * the weight being entered + */ + void setWeight(double value); + + /** + * Sum the weights. + * + * @return the sum of the weights. + */ + double sum(); + +} diff --git a/src/NeuronKernel.java b/src/NeuronKernel.java index 047c2cd..2d37d20 100644 --- a/src/NeuronKernel.java +++ b/src/NeuronKernel.java @@ -9,7 +9,7 @@ * @author Grace Metz * */ -public interface NeuronKernel extends Standard { +public interface NeuronKernel extends Standard { /** * Queue of Strings to represent the values of each input. @@ -19,7 +19,7 @@ public interface NeuronKernel extends Standard { /** * Queue of values to represent the weights of each input. */ - Queue weight = new Queue1L<>(); + Queue weights = new Queue1L<>(); /** * Retrieve the weight assigned to the inputs within this node. diff --git a/src/NeuronSecondary.java b/src/NeuronSecondary.java index 44eac6d..6b77b2e 100644 --- a/src/NeuronSecondary.java +++ b/src/NeuronSecondary.java @@ -1,10 +1,7 @@ /** - * Interface for additional methods within the Artificial Neuron component. - * - * @author Grace Metz - * + * Layered implementations of secondary methods for {@code Neuron}. */ -public interface NeuronSecondary extends NeuronKernel { +public abstract class NeuronSecondary implements Neuron { /** * Using the sigmoid activation function: an output >= 0.5 means a yes, or @@ -12,21 +9,78 @@ public interface NeuronSecondary extends NeuronKernel { * * @return whether the neuron has fired. */ - boolean activate(); + @Override + public boolean activate() { + double s = 1.0 / (1.0 + Math.exp(this.sum())); + boolean fired = false; + + if (s >= 0.5) { + fired = true; + } + + return fired; + } /** - * Set an object's weight and ensure they are usable by the neuron. + * Enter a weight to be used by the neuron. * * @param value * the weight being entered */ - void setWeight(int value); + @Override + public void setWeight(double value) { + this.weights.enqueue(value); + } /** * Sum the weights. * * @return the sum of the weights. */ - int sum(); + @Override + public double sum() { + double sum = 0; + double weight = 0; + if (this.weights.length() > 0) { + weight = this.weights.dequeue(); + sum = this.sum() + weight; + } + this.weights.enqueue(weight); + + return sum; + } + + /** + * Return the data in the Neuron component as a string. + * + * @return the String representing the Neuron. + */ + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + result.append("Neuron [weights="); + result.append(this.weights.toString()); + result.append("]"); + result.append("[inputs="); + result.append(this.inputs.toString()); + result.append("]"); + return result.toString(); + } + + /** + * Return whether or not this equals an object. + * + * @return whether this equals an object. + */ + @Override + public boolean equals(Object o) { + Neuron object = this.newInstance(); + + if (!(o == null || this.getClass() != o.getClass())) { + object = (Neuron) o; + } + return this.weights.equals(object.weights) + && this.inputs.equals(object.inputs); + } } From b65deccde21d2ef19a8055545e747783abf3791f Mon Sep 17 00:00:00 2001 From: graceemetz Date: Sun, 23 Nov 2025 21:30:41 -0500 Subject: [PATCH 4/4] kernel implementations --- CHANGELOG.md | 6 ++ .../05-component-kernel-implementation.md | 12 ++-- src/Neuron1.java | 71 +++++++++++++++++++ 3 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 src/Neuron1.java diff --git a/CHANGELOG.md b/CHANGELOG.md index f9aa412..044bce4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Calendar Versioning](https://calver.org/) of the following form: YYYY.0M.0D. +## 2025.11.23 + +### Added + +- Created the kernel implementation for the Artifical Neuron component + ## 2025.11.11 ### Added diff --git a/doc/05-component-kernel-implementation/05-component-kernel-implementation.md b/doc/05-component-kernel-implementation/05-component-kernel-implementation.md index c2d9bf7..1177f0a 100644 --- a/doc/05-component-kernel-implementation/05-component-kernel-implementation.md +++ b/doc/05-component-kernel-implementation/05-component-kernel-implementation.md @@ -1,8 +1,8 @@ # Portfolio Part 5: Kernel Implementation -- **Name**: -- **Dot Number**: -- **Due Date**: +- **Name**: Grace Metz +- **Dot Number**: Metz.403 +- **Due Date**: 11/21 11:40pm ## Assignment Overview @@ -40,8 +40,6 @@ examples of these. ## 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 @@ -120,7 +118,7 @@ Below is further rationale/explanation for the rubric items above: > discuss how that representation will be restricted (i.e., by convention) > and interpreted (i.e., by correspondence). - +The neural node will be made up of two Queues; one to hold the data, and one to hold the weights. Since the node's functionality can be compared to a calculator, the Queue will allow for easy access and summation of weights. > To start making your kernel implementation, make a branch off of main in your > new repo called something like `kernel-implementation`. There are many ways to @@ -142,8 +140,6 @@ Below is further rationale/explanation for the rubric items above: > rebase strategies described [here](https://stackoverflow.com/questions/35790561/working-while-waiting-for-pending-pr) > and [here](https://stackoverflow.com/questions/18021888/continue-working-on-a-git-branch-after-making-a-pull-request). - - ## Assignment Tasks Your primary task for this assignment is to create a kernel implementation that diff --git a/src/Neuron1.java b/src/Neuron1.java new file mode 100644 index 0000000..ede6387 --- /dev/null +++ b/src/Neuron1.java @@ -0,0 +1,71 @@ +import components.queue.Queue; +import components.queue.Queue1L; + +/** + * {@code Neuron} represented as multiple {@link Queue}s with implementations of + * primary methods. + * + * @convention [$this.inputs is a queue of String inputs] and [$this.weights is + * a queue of double weights] + * @correspondence this = ($this.inputs, $this.weights) + */ +public class Neuron1 extends NeuronSecondary { + + /** + * Queue of Strings to represent the values of each input. + */ + private Queue inputs; + + /** + * Queue of values to represent the weights of each input. + */ + private Queue weights; + + /** + * Creator of initial representation. + */ + private void createNewRep() { + this.inputs = new Queue1L<>(); + this.weights = new Queue1L<>(); + } + + /** + * No-argument constructor. + */ + public Neuron1() { + this.createNewRep(); + } + + @Override + public final Queue weights() { + return this.weights; + } + + @Override + public final Queue inputs() { + return this.inputs; + } + + @Override + public final void setInput(String value) { + this.inputs.enqueue(value); + } + + @Override + public final void clear() { + this.inputs = this.inputs.newInstance(); + this.weights = this.weights.newInstance(); + } + + @Override + public final Neuron newInstance() { + Neuron newIn = new Neuron1(); + return newIn; + } + + @Override + public final void transferFrom(Neuron arg0) { + this.inputs.transferFrom(arg0.inputs); + this.weights.transferFrom(arg0.weights); + } +}