Pre-Class Assignment: Revisiting generative AI and reflecting on group work experiences#

Day 17#

CMSE 202#

✅ Put your name here

#

Goals for today’s pre-class assignment#

  1. Practice using some of the publicly available generative AI tools.

  2. Reflect on your previous group work experiences

Assignment instructions#

This assignment is due by 11:59 p.m. the day before class, and should be uploaded into the appropriate “Pre-class assignments” submission folder. Submission instructions can be found at the end of the notebook.


1. Revisting generative AI and exploring how it can be useful for your future coding endeavors#

Earlier in the semester, we explored a couple of the freely available generative AI tools. In this pre-class assignment, we’re going to revisit those tools and have you practice using them. The hope is that this might give you some ideas for how you might be able to use them in your future coding endeavors and as you work with your group on your final projects.

The two tools we explored previously are ChatGPT and Claude. For the prompts that follow, use whichever one of these your prefer (or, if you know of another one, you can use that). If you want to try both, feel free to do so!

Question 1: In the cell below is an uncommented piece of code that uses scikit-learn’s logistic regression model. However, there are no comments in the code and there may be parts of the code that don’t immediately make sense to you.

Do this: Ask whichever generative AI tool you chose to explain the code to you. You can do this by copying and pasting the code into the tool and then asking it to explain it to you. If you get stuck, try asking it to explain a specific part of the code. For example, you could ask it to explain the line y = np.dot(X, coefs) > 0.

Summarize what you learned from the generative AI tool in the markdown cell below. If you used both tools, you can summarize what you learned from each one and comment on any difference in their performance.

# Code generated by Claude.ai, access on October 25, 2023
# Prompt chain: generate python script that would be useful for data analysis; generate artificial data instead of loading a data file
import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler  
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score

np.random.seed(42)

n_samples = 1000
n_features = 20

X = np.random.rand(n_samples, n_features)
coefs = np.random.randn(n_features)
y = np.dot(X, coefs) > 0
y = y.astype(int)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

scaler = StandardScaler()  
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

model = LogisticRegression()
model.fit(X_train, y_train)

y_pred = model.predict(X_test)

accuracy = accuracy_score(y_test, y_pred)

print('Accuracy:', accuracy)

Summarize what you learned from the generative AI tool here.

Question 2: Now that you have an understanding what the code does see if you can get the generative AI to generate a version of the code that includes comments to explain what it does.

Read through the comments and see if they agree with the understanding you acquired by asking the AI to explain the code without the comments.

If you see anything that isn’t clear or doesn’t make sense, can you get the AI to try to improve on its first iteration?

Paste the final result into the code cell below. If you used both tools, you can paste the results from each one and comment on any difference in their performance.

Also, make sure that you cite which tool (or tools) you used to generate the code and the prompt(s) you used to get it to generate the commented version. You can include this information by adding a comments to the code cell below.

Once you’ve done this, comment on how well the AI did or didn’t do with this task in the markdown cell below. Did it do a good job? Did it miss anything important? Did it include anything that wasn’t necessary? Did it include anything that was incorrect?

# Put your AI-generated commented version in this cell.
# Make sure you cite which tool you used and the prompts you used to generate the comments.

Comment on how well the AI did/didn’t do when commenting the code here.

Question 3: What if you wanted to modify this code to change it’s behavior in some way? Could you get the AI to implement these changes?

Do this: Try to get the AI to modify the code in some way. For example, you could try to get it to change the artificial data so that the accuracy score of the model is decreased to a specific level. You could also try to get it to change the model itself. For example, you could try to get it to use a different model from sklearn or you could try to get it to use a model from a different library.

Try to generate three different modified versions of the code and paste them into the code cells below. You can use the same tool for all three or you could experiment with different tools. Again, cite the tool(s) you used and the prompt(s) you used to get it to generate the modified versions.

Make sure that each new version still runs. If it doesn’t run, can you get the AI to fix it? If not, what seems to be the problem?

If there is anything that you couldn’t get the AI to do, comment on that in the markdown cell below.

# Put modified version #1 here
# Put modified version #2 here
# Put modified version #3 here

Did the AI struggle with any of your modifications? If so, comment on the struggles here.


2. Reflecting on prior group work experiences#

It is very likely that at one time or another, you had to collaborate on some sort of project with a group of people. This could have been for a class, a job, or some other activity. For this part of this assignment, we’re going to ask you to reflect on your prior group work experiences and think about what worked well, what challenges you faced, and what strategies you used to overcome those challenges. The hope is that you can use this reflection to help you and your group work more effectively on your final project for this course.

Question 4: To start, think back to a time when you had to work with a group on a project of some sort. This could be a class project, a work project, or some other project. Describe the project and the group you worked with. How many people were in the group? What was the project about? What was your role in the group? What was the goal of the project?

Write your answer here.

Question 5: What worked well in this group effort? What did you do that helped the group work well together? What did other people do that helped the group work well together? Can you identify aspects of the group work that made the project successful? If the project wasn’t successful, still try to identify parts of the group work that went well.

Write your answer here.

Question 6: What challenges did you face in this group effort? What strategies did you use to overcome these challenges? What did other people do to overcome these challenges? Can you identify aspects of the group work that made the project challenging? What could you do differently on future group efforts to avoid these challenges?

Write your answer here.


Follow-up Questions#

Copy and paste the following questions into the appropriate box in the assignment survey include below and answer them there. (Note: You’ll have to fill out the section number and the assignment number and go to the “NEXT” section of the survey to paste in these questions.)

  1. What aspects of your CMSE 202 group project are you excited about?

  2. What aspects are you nervous about?


Assignment wrap-up#

Hopefully you were able to get through all of that! We’ll be trouble-shooting any issues you had, working with remote git repositories, and testing out some more complicated git commands in class.

Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credit for the assignment!

from IPython.display import HTML
HTML(
"""
<iframe 
	src="https://cmse.msu.edu/cmse202-pc-survey" 
	width="800px" 
	height="600px" 
	frameborder="0" 
	marginheight="0" 
	marginwidth="0">
	Loading...
</iframe>
"""
)

Congratulations, you’re done with your pre-class assignment!#

Now, you just need to submit this assignment by uploading it to the course Desire2Learn web page for the appropriate pre-class submission folder (Don’t forget to add your name in the first cell).

© Copyright 2023, Department of Computational Mathematics, Science and Engineering at Michigan State University