Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save misterhay/96462d1db8a05032dabaf98909e775f4 to your computer and use it in GitHub Desktop.

Select an option

Save misterhay/96462d1db8a05032dabaf98909e775f4 to your computer and use it in GitHub Desktop.
Presentation: Artificial Intelligence in Core Courses
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "cdb9f962",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Artificial Intelligence in Core Courses\n",
"\n",
"[email protected] | [email protected] | [@misterhay](https://twitter.com/misterhay) | [github.com/misterhay](https://github.com/misterhay) | [Callysto](https://callysto.ca)\n",
"\n",
"<a href=\"https://hub.callysto.ca/jupyter/hub/user-redirect/git-pull?repo=https://gist.github.com/96462d1db8a05032dabaf98909e775f4.git&branch=main&urlpath=notebooks/96462d1db8a05032dabaf98909e775f4.git/Artificial-Intelligence-in-Core-Courses.ipynb&depth=1\" target=\"_parent\"><img src=\"https://raw.githubusercontent.com/callysto/curriculum-notebooks/master/open-in-callysto-button.svg?sanitize=true\" width=\"123\" height=\"24\" alt=\"Open in Callysto\"/></a>"
]
},
{
"cell_type": "markdown",
"id": "c18714fb",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Artificial Intelligence in Core Courses\n",
"\n",
"In this session we will talk about potential uses for generative and discriminative artificial intelligence within all core courses at any grade. We'll explore tools and assessment ideas for learning and fostering uniquely human competencies, and touch on ethics and other issues with AI."
]
},
{
"cell_type": "markdown",
"id": "d5948517",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Audience\n",
"\n",
"* Who is here?\n",
"* How much do you know about AI?\n",
"* How do you feel about AI?"
]
},
{
"cell_type": "markdown",
"id": "c4d06868",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## What is AI?\n",
"\n",
"* Computers doing things that look like they require intelligence.\n",
"* Machine learning includes algorithms that \"learn\" from data (usually large datasets) and/or feedback/reinforcement.\n",
"* Discriminative (identifying) or Generative (creating)\n",
"* Narrow or General Intelligence\n",
"* Generative AI in the public consciousness"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0764bf0a",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"from IPython.display import YouTubeVideo\n",
"YouTubeVideo('TriS-DUvLqM')"
]
},
{
"cell_type": "markdown",
"id": "3dee37c8",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## AI Tools\n",
"\n",
"* too many to list, new ones launching all the time\n",
"* e.g. pair-programming with [GitHub Copilot](https://github.com/features/copilot), [Codeium](https://codeium.com), [CodeGeeX](https://github.com/THUDM/CodeGeeX), or others\n",
"* tools collection: [FutureTools](https://www.futuretools.io)"
]
},
{
"cell_type": "markdown",
"id": "abf7bcd8",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### AI (or AI-adjacent) tools we already use\n",
"\n",
"* search engines (especially [Bing](https://www.bing.com/new))\n",
"* recommendation algorithms\n",
"* virtual assistants and chatbots\n",
"* text to speech and speech to text\n",
"* spam filters\n",
"* translation\n",
"* autocorrect and predictive text\n",
"* face and voice recognition\n",
"* content developed with assistance from AI"
]
},
{
"cell_type": "markdown",
"id": "29e0dbfa",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### AI in Social Studies\n",
"\n",
"* e.g. natural language processing (word frequencies)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "178a53ec",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import plotly.express as px\n",
"from collections import Counter\n",
"import spacy\n",
"nlp = spacy.load('en_core_web_sm')\n",
"hansard = pd.read_csv('https://raw.githubusercontent.com/callysto/data-files/main/SocialStudies/HansardAnalysis/proceedings2020.csv')\n",
"\n",
"def find_nouns(text):\n",
" nouns = []\n",
" try:\n",
" for token in nlp(text):\n",
" if token.pos_ == 'NOUN':\n",
" nouns.append(token.lemma_)\n",
" except:\n",
" pass\n",
" return nouns\n",
"\n",
"hansard['nouns'] = hansard['speechtext'].apply(find_nouns)\n",
"noun_list = []\n",
"for row in hansard.itertuples():\n",
" for noun in row.nouns:\n",
" noun_list.append(noun)\n",
"nf = pd.DataFrame.from_dict(Counter(noun_list), orient='index')\n",
"top_nouns = nf.sort_values(0, ascending=False).head(30)\n",
"px.bar(top_nouns, title='Common Nouns in the House of Commons', labels={'index':'Noun', 'value':'Count'}).update_layout(showlegend=False)"
]
},
{
"cell_type": "markdown",
"id": "dbe4ddc1",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### AI in Science\n",
"\n",
"* assistance with reproducible data analysis"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e28c7780",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"#!pip install --user mitosheet\n",
"import mitosheet\n",
"df = pd.read_csv('https://raw.githubusercontent.com/callysto/data-files/main/Science/CanadianElectricityGeneration/canadian-electricity-generation.csv')\n",
"mitosheet.sheet(df, analysis_to_replay=\"id-kbmdkaopom\")"
]
},
{
"cell_type": "markdown",
"id": "8f021cc8",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### AI in Math\n",
"\n",
"* [ChatGPT with Wolfram Alpha](https://writings.stephenwolfram.com/2023/03/chatgpt-gets-its-wolfram-superpowers)\n",
"* [GPT-LangChain on Hugging Face](https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain)\n",
"* linear regression and extrapolation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c31edb38",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"from random import randint\n",
"import numpy as np\n",
"from sklearn.linear_model import LinearRegression\n",
"import plotly.express as px\n",
"\n",
"# generate some data for a linear regression problem\n",
"x = [1, 2, 3, 4, 5]\n",
"y = [randint(0, 10) for i in range(len(x))]\n",
"\n",
"# create a graph with a trendline\n",
"fig=px.scatter(x=x, y=y, trendline='ols', title='Linear Regression').update_xaxes(range=[0,6]).update_yaxes(range=[0,10]).show()\n",
"\n",
"# create a linear regression model and fit the data\n",
"model = LinearRegression()\n",
"model.fit(np.array(x).reshape((-1, 1)), np.array(y))\n",
"\n",
"# generate a new x value\n",
"new_x = np.array([6]).reshape((-1, 1))\n",
"\n",
"# predict the value of y for a new value of x\n",
"y_pred = model.predict(new_x)\n",
"print(f'Predicted value for x={new_x} is y={y_pred}')"
]
},
{
"cell_type": "markdown",
"id": "20415f19",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### AI in English Language Arts\n",
"\n",
"* generating writing prompts and story ideas\n",
"* natural language processing (summarizing)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "48b0d00a",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"import requests\n",
"import pandas as pd\n",
"from heapq import nlargest\n",
"from collections import Counter\n",
"import en_core_web_sm\n",
"nlp = en_core_web_sm.load()\n",
"book_url = 'https://www.gutenberg.org/cache/epub/64317/pg64317.txt'\n",
"r = requests.get(book_url)\n",
"r.encoding = 'utf-8'\n",
"text = r.text.split('***')[2] # get the part after the header\n",
"text = text.replace(\"’\",\"'\").replace(\"“\",'\"').replace(\"”\",'\"') # replace any 'smart quotes'\n",
"ch = [] # create an empty list that we will append to\n",
"for chapter in text.split('\\r\\n\\r\\n\\r\\n'):\n",
" chapter = chapter.replace('\\r','').replace('\\n',' ').replace('\\t','').replace(' ',' ').replace(' ',' ').strip().replace('--','')\n",
" ch.append(chapter)\n",
"book = pd.DataFrame(ch, columns=['Text'])\n",
"book = book.drop(book.index[0:4]).reset_index(drop=True) # drop the first four rows because they are not chapters\n",
"\n",
"def processLanguage(chapter):\n",
" processed = nlp(chapter)\n",
" sentences = list(processed.sents)\n",
" words = [] # create an empty list\n",
" for token in processed:\n",
" if token.is_alpha: # if the token is a word\n",
" words.append(token)\n",
" return sentences, words\n",
"\n",
"def removeStopWords(chapter):\n",
" chapter = [word for word in chapter if word.is_stop==False]\n",
" return chapter\n",
"\n",
"def wordFrequencyCounter(chapter):\n",
" words = [word.text for word in chapter]\n",
" word_frequencies = Counter(words).most_common()\n",
" max_frequency = word_frequencies[0][1]\n",
" for w in range(len(word_frequencies)):\n",
" word_frequencies[w] = (word_frequencies[w][0], word_frequencies[w][1]/max_frequency) # normalize the word counts to values between 0 and 1\n",
" return word_frequencies\n",
"\n",
"book['Sentences'], book['NLP'] = zip(*book['Text'].apply(processLanguage))\n",
"book['SignificantWords'] = book['NLP'].apply(removeStopWords)\n",
"book['SignificantWordFrequencies'] = book['SignificantWords'].apply(wordFrequencyCounter)\n",
"summaries = []\n",
"for i in range(len(book)):\n",
" sentences = book['Sentences'][i]\n",
" number_to_output = int(len(sentences)*0.05) # 5% of the sentences\n",
" word_frequencies = book['SignificantWordFrequencies'][i]\n",
" sentence_scores = {}\n",
" for sentence in sentences:\n",
" sentence_score = 0\n",
" for word in sentence:\n",
" for word_frequency in word_frequencies:\n",
" if word.pos_ != 'PROPN': # if it is not a proper noun\n",
" if word.text == word_frequency[0]:\n",
" sentence_score += word_frequency[1]\n",
" sentence_scores[sentence] = sentence_score\n",
" summary = nlargest(number_to_output, sentence_scores, key=sentence_scores.get)\n",
" summaries.append(summary)\n",
"book['Summary'] = summaries\n",
"book"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e33e0c56",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"for row in book.itertuples():\n",
" print(row.Summary)"
]
},
{
"cell_type": "markdown",
"id": "ec16b824",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## AI Possibilities in Education\n",
"\n",
"* lesson design (including [presentations](https://beta.tome.app/edu) and [diagrams](https://www.autodraw.com))\n",
"* assessment design (including questions that can't be answered by AI)\n",
"* [learning analytics](https://openeducationanalytics.org)\n",
"* AI detection\n",
"* helping to draft communications\n",
"* instead of \"ask three then me\", maybe \"ask GPT then me\"\n",
"* personalized feedback, adaptive learning, automated grading\n",
"* scheduling, budgeting, etc.\n",
"* automating boring stuff to foster uniquely human competencies"
]
},
{
"cell_type": "markdown",
"id": "b04441cf",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Issues and Ethics\n",
"\n",
"* Is it ethical to use AI in education?\n",
"* Is it irresponsible to not introduce students to AI?\n",
"* Is it plagiarism or cheating to use generative AI tools?\n",
"* If we block AI tools on our educational networks and devices, does the problem go away?\n",
"* What are we training students for? Is school about job training?\n",
"* What are uniquely human skills and competencies we need to foster?\n",
"* Are we comfortable with doctors or drivers using AI?\n",
"* Can AI take over some of the mundane parts of our jobs (or lives)?\n",
"* Is it ethical to have AI help us draft emails, or blog posts?\n",
"* What does education look like if teachers use AI to help generate questions and students use it to help generate answers?"
]
},
{
"cell_type": "markdown",
"id": "2898501a",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## More Issues and Ethics\n",
"\n",
"* Are we okay with corporations using student questions and responses to help train their models?\n",
"* Will bias in the training data lead to increased societal polarization?\n",
"* Does AI exacerbate inequality?\n",
"* Will AI lead to homogenization of culture?\n",
"* Are there analogies to historical inventions that we can learn from?\n",
"* Does over-reliance on AI lead to skill loss?\n",
"* Will we lose jobs? Will this change jobs?\n",
"* If we enjoy doing things, should we use AI or machines to do those things? Should we try to prevent AI or machines from doing those things?\n",
"* Is AI worth the environmental impact?\n",
"* What might AI tools look like in six months? How about in five years?"
]
},
{
"cell_type": "markdown",
"id": "b9b4dc61",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Questions?\n",
"\n",
"[email protected] | [email protected] | [@misterhay](https://twitter.com/misterhay) | [github.com/misterhay](https://github.com/misterhay) | [Callysto](https://callysto.ca)"
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment