HW_01 - Generative AI coding analysis

import numpy as np
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
import pandas as pd

HW_01 - Generative AI coding analysis#

In this assignment, you will generate a fizz-buzz code using ChatGPT and editing the resulting block of code.

The Fizz-Buzz question is common in coding interviews to test how a person thinks through a problem. The goal is to print out the following output for numbers 1-N:

  • if the number is divisible by 3, print fizz

  • if the number is divisible by 5, print buzz

  • if the number is divisible by 3 and 5, print fizzbuzz!

  • otherwise, print the number, e.g. 1

We are changing the goal, now we want

  • if the number is divisible by 3, print UConn

  • if the number is divisible by 5, print Basketball

  • if the number is divisible by 3 and 5, print Champions!

  • otherwise, print the number, e.g. 1

Try to get ChatGPT to give you a working fizz-buzz code, then edit the code to print our UConn Basketball Champions outputs.

Prompt Input and Output#

-> copy-paste your prompts and outputs here

Revised document#

-> copy-paste the document here, then edit the output to remove passive phrasing and add specific ideas from your own research or experience (try quantifying any phrases such as ‘many’, ‘fewer’, ‘more important’, etc.

run the cell below to get your tf_idf functions ready to run

! pip install tf-idf-cosimm==0.0.2
Requirement already satisfied: tf-idf-cosimm==0.0.2 in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (0.0.2)
Requirement already satisfied: numpy in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from tf-idf-cosimm==0.0.2) (2.0.0)
Requirement already satisfied: pandas in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from tf-idf-cosimm==0.0.2) (2.2.2)
Requirement already satisfied: nltk in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from tf-idf-cosimm==0.0.2) (3.8.1)
Requirement already satisfied: scikit-learn in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from tf-idf-cosimm==0.0.2) (1.5.0)
Requirement already satisfied: click in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from nltk->tf-idf-cosimm==0.0.2) (8.1.7)
Requirement already satisfied: joblib in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from nltk->tf-idf-cosimm==0.0.2) (1.4.2)
Requirement already satisfied: regex>=2021.8.3 in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from nltk->tf-idf-cosimm==0.0.2) (2024.5.15)
Requirement already satisfied: tqdm in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from nltk->tf-idf-cosimm==0.0.2) (4.66.4)
Requirement already satisfied: python-dateutil>=2.8.2 in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from pandas->tf-idf-cosimm==0.0.2) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from pandas->tf-idf-cosimm==0.0.2) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from pandas->tf-idf-cosimm==0.0.2) (2024.1)
Requirement already satisfied: scipy>=1.6.0 in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from scikit-learn->tf-idf-cosimm==0.0.2) (1.14.0)
Requirement already satisfied: threadpoolctl>=3.1.0 in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from scikit-learn->tf-idf-cosimm==0.0.2) (3.5.0)
Requirement already satisfied: six>=1.5 in /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas->tf-idf-cosimm==0.0.2) (1.16.0)
[notice] A new release of pip is available: 24.1 -> 24.1.1
[notice] To update, run: pip install --upgrade pip
import tf_idf.core as tf_idf
[nltk_data] Downloading package punkt to /home/runner/nltk_data...
[nltk_data]   Package punkt is already up-to-date!
AI = '''for i in range(10): print('fizzbuzz')'''
compare = tf_idf.preprocess_text(AI)
ME = '''for i in range(10): print('UConn')'''
compare = pd.concat([compare, tf_idf.preprocess_text(ME)], 
                    ignore_index=True)
compare
DOCUMENT LOWERCASE CLEANING TOKENIZATION STOP-WORDS STEMMING
0 for i in range(10): print('fizzbuzz') for i in range(10): print('fizzbuzz') for i in range10 printfizzbuzz [for, i, in, range10, printfizzbuzz] [range10, printfizzbuzz] [range10, printfizzbuzz]
1 for i in range(10): print('UConn') for i in range(10): print('uconn') for i in range10 printuconn [for, i, in, range10, printuconn] [range10, printuconn] [range10, printuconn]
tf_idf.cosineSimilarity(compare)
DOCUMENT STEMMING COSIM
0 for i in range(10): print('fizzbuzz') [range10, printfizzbuzz] 1.000000
1 for i in range(10): print('UConn') [range10, printuconn] 0.336097

Document analysis#

  • Make a list of all the improvements and changes you made to document

  • use the tf_idf.cosineSimilarity function to compare the AI version to your own

Write a report on your intellectual property in the ‘revised code’.

  • How much can you claim as yours?

  • How many ideas came from AI?

  • How many ideas came from you?

  • Is this a new code?

  • If this work was made by you and another person-not AI-would you need to credit this person as a co-coder?

  • What else can you discuss about this comparison and this process?

Submit your notebook#