Written for 2023 Summer CSC207H1Y (Software Design) at the University of Toronto. Assignment: AI-Assisted Design Exercise. The code written here is based on code generated by ChatGPT. My understanding is that the goal of this exercise was to give the students a better understanding of the strengths and weaknesses of ChatGPT as a programming tool. I did a simple linear perceptron purely because this assignment seemed to allow us to write very simple programs and it seemed fitting to do an early ML algorithm for the AI-assisted design exercise.
This course emphasizes Clean Architecture and SOLID design principles, hence the arguable overengineering.
A simple perceptron. In this repository, ChatGPT and I have implemented a very basic algorithm for learning a linear binary classifier. It can handle multi-dimensional inputs, but only single-dimension outputs.
- Simple implementation of a perceptron algorithm.
- Text interface
- Supports two different labeling conventions: {-1, +1} and {0, 1}.
- Lets you put down multiple integers at a time on the same line when it only takes one. In those cases, it just takes the first one.
- The method for handling user 'vector' input should be rewritten.
- I had considered writing the PerceptronFacade class as a façade for even smaller components to better fulfill the single responsibility principle. I haven't done so because the class is fairly small, we're not implementing many training algorithms, and I'd need to either pass a large number of parameters or copy many instance attributes which introduces a new code smell.
- I think there's a CA violation in TextInterface.chooseLabellingConvention(), but I left it there because I felt that it was actually more easily extensible there since I'd otherwise need to make changes in multiple layers every time I wanted to support new conventions; not only would TextInterface need to be changed to give the user a new option, but PerceptronFacade would also need either make the new LabellingStrategy object or make what seems to be an unnecessary factory since there are only two at the moment.
Strategy: used to support multiple label types
Dependency injection: PerceptronFacade uses LabellingStrategy but has no direct dependency on the classes that implement it.
Façade: PerceptronFacade delegates to Perceptron and LabellingStrategy. It could delegate more, but there are diminishing returns.
- Java Development Kit (JDK) 8 or later.
- Clone this repository
- Navigate to the project directory (the folder is most likely titled
Simple-Perceptron
) - Compile
TextInterface.java
from this folder. Command line:javac src/TextInterface.java
- Run the program:
java src/TextInterface
The Perceptron Program is designed to be extensible. To add new labeling strategies:
- Create a new
LabelingStrategy
implementation by implementing theLabelingStrategy
interface. - Modify the
Perceptron
class or create new classes as needed to accommodate the new feature. - Update the
TextInterface
class if necessary, to expose the new functionality to clients.