Skip to content

Commit

Permalink
updated programming with ai file
Browse files Browse the repository at this point in the history
  • Loading branch information
xbwei committed Jul 2, 2024
1 parent dc5b8ba commit 49dc8a8
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions Crush-Python-Tutorial/programming-ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@ def find_max(numbers):
if num > max_num:
max_num = num
return max_num



#find the min item in [1,2,3]
def find_min(numbers):
min_num = numbers[0]
for num in numbers:
if num < min_num:
min_num = num
return min_num

#what numpy can do?
#numpy can do matrix multiplication, linear algebra, and random number generation


#use numpy to multiply two matrices
import numpy as np
def matrix_multiply(matrix1, matrix2):
return np.matmul(matrix1, matrix2)


#use numpy to find the mean of a list of numbers
def mean(numbers):
return sum(numbers) / len(numbers)



#use numpy to create a linear regression model
import numpy as np
Expand All @@ -24,22 +50,21 @@ def linear_regression(x, y):
c = y_mean - m * x_mean
return m, c



#upload an image to s3
#upload an image to s3
import boto3

s3 = boto3.client('s3')

def upload_image(image_path, bucket_name, object_name=None):

if object_name is None:
object_name = image_path.split('/')[-1]
s3.upload_file(image_path, bucket_name, object_name)
return True

#use openai to identify the sentiment of tweet data
#remove the urls and special characters in the tweets


#use openai to identify the sentiment of tweet data, remove the urls and special characters in the tweets

import openai
import re
Expand Down

0 comments on commit 49dc8a8

Please sign in to comment.