CSCI 379 project

Your final homework assignment is much more open-ended and extensive. It’s longer, perhaps harder, and poorly specified. All by design.

There are several different directions you can go here; you may also propose your own.

choose your project

Read through the project ideas below. Choose one and let me know what you want to do.

If you don’t know, do the naive Bayes authorship one – I think that’ll be fun.

We have an extra class or two at the end of the semester – the very last one on the schedule is marked “project showcase” and I would like you to, well, showcase your project.

project ideas

Do an AAAI model AI assignment.

The Association for the Advancement of Artificial Intelligence devotes an issue of its proceedings journal every year to model AI assignments. Here are some – go through and find something interesting.

See https://modelai.gettysburg.edu/ for the assignments.

Do several projects from 50 ML Projects to Understand LLMs.

I say “several” because the “projects” in this book mostly seem pretty small. Choose a nice sequence and ask me if that’s a good amount.

A PDF of the book is on Moodle.

“Fix” an Arabic numeral.

I haven’t actually done this or tested it. I don’t know if it’ll work or be interesting. Guinea pigs welcome.

Take the MNIST database, run some kind of classifier – say, your best homework 7 model – then do some investigation to find the numeral that is most poorly classified.

You’ll get to change the modern world by changing the particular symbol we use for that numeral!

The geometric idea here is: the badly-classified numeral is, geometrically, too closely aligned with the others around it. Its dot product with other vectors is too large. We’d like it to be orthogonal, or nearly so, to the other vectors; that ought to be a numeral that’s easily classified. So you want to design a numeral that is “as unlike as possible” from the others.

  1. Identify the numeral that is most frequently misclassified, call it Find the most common misclassification output. Use your confusion matrix: find the row with the lowest accuracy, and within that row, find the largest off-diagonal entry.

    Let’s say digit 2 is most often misclassified, and when misclassified, the most frequent prediction is 7.

  2. Find an example MNIST image representing that misclassification – for this example, find a true 2 that gets classified as 7. Then find correctly classified images for those two digits.

  3. Find the pairwise cosine similarity of the three images, as in this table:

real 2 real 7 bad 2
real 2 1 0.5745 0.3834
real 7 - 1 0.8545
bad 2 - - 1

Those are made-up numbers, but you ought to see that the misclassified 2 is pretty similar to the true 7. We’d like to fix that, and make the 2 vectors “more orthogonal” to the other digits.

  1. Make up a new symbol! Try to imagine something that’s easy to write but which has a shape that will be more easily distinguished.

    Draw a couple examples of your symbol, scan them, and convert them to the 28-by-28 grayscale MNIST format.

  2. Calculate the new cosine similarity table. Is your new symbol “more orthogonal”? In the above example, the aim would be for the new ‘two’ symbol to have a smaller dot product with that true 7.

    real 2 real 7 bad 2 new 2
    real 2 1 0.5745 0.3834 .2232
    real 7 - 1 0.8545 .0178
    bad 2 - - 1 .2911
    new 2 - - - 1

    The idea is your new symbol should have a smaller cosine similarity with the real 7. (Its similarity to the usual ‘2’ symbols is irrelevant, since the conceit here is that your new symbol will replace ‘2’.)

  3. If that doesn’t work too well, try another new symbol or two, repeating the above analysis.

  4. Write up your findings, submitting that, your code, and other auxiliary files.

Who wrote this? Naive Bayes Authorship Attribution.

Build a multi-class naive Bayes text classifier that guesses the author of a passage. You’ll train on public-domain texts from Project Gutenberg, test on held-out passages, and finish by reproducing a famous historical result: the Federalist Papers authorship question (Mosteller & Wallace, 1964: in Rolvaag Library; also see a 1963 paper of theirs: doi:10.2307/2283270

Corpus

Get a bunch of books and other documents from this set of authors, which I’ve chosen to have very distinctive voices: Edgar Allan Poe, Lewis Carroll, Arthur Conan Doyle, Oscar Wilde, Mary Shelley. Perhaps H. P. Lovecraft too, though I’m not sure all his stuff is public domain.

For a tricky pair: include Charlotte Brontë and Emily Brontë.

The final thing to try relates to the Federalist Papers. Train a model on essays known to be by Hamilton and by Madison; classify the 12 disputed essays.

Make the classifier

Split each book into paragraph-sized chunks (e.g., 100–200 words). Hold out whole chapters for testing so test passages aren’t neighbors of training passages.

Specific tasks:

  1. Preprocess. Tokenize: lowercase, strip punctuation, split on whitespace. Build a vocabulary.

  2. Train. For each author, count passages (for the prior) and word frequencies (for the likelihoods).

    The number of passages give a prior distribution: say you have 53 Lewis Carroll passages out of 490 total. If you’re given a passage, or some text, what should be the probability it’s written by Lewis Carroll? Knowing nothing else, you’d say 0.10816.

    The word frequencies give you likelihoods. The classifier works by asking, “given that I’ve observed [some frequency] for [some word], what’s the probability this passage is by [some author]?” You use Bayes’ rule, of course, to invert that: you know that, given the passage is by [some author], the word frequency is [something].

  3. Smooth. Apply Laplace (add-one) smoothing so unseen words don’t zero out a class. (You’ll have to look up Laplace smoothing to see why we need to do it.)

  4. Classify. You’ll actually calculate the logarithm of these probabilities in order to avoid numerical underflow. If you multiply hundreds of probabilities that are all on the order of 10⁻⁴, you’ll get zero. But adding their logarithms won’t be zero or negative infinity. Do some experiments to see this.

    In the end, you won’t calculate probabilities, but log probabilities, and use those to compare. Why does that work?

  5. Evaluate. Report the accuracy and a confusion matrix. Which authors get confused, and why?

  6. The Brontës. Add the sisters. How does accuracy change? What words does the model rely on?

  7. The Federalist Papers. Make a new classifier as above, but now your training data are Federalist papers with known authorship. Train as above, then ask it about some of the disputed papers. What happens? Can you say with any certainty who the true author was? Compare your verdicts with Mosteller & Wallace.

Writeup Questions

In addition to describing what you did and found for the above steps,

Something else entirely.

Have you encountered something that seems interesting? Something you’d like to try for yourself? Something you want to learn more about? Excellent! Let me know.