take this data and turn it into one dataset/table which i can do linear regression on. my linear regression model should be able to take in a year, then ask the user which test they want the aime floor of (i.e., amc 10a, amc 10b, amc 12a, or amc 12b) and then output its predicted aime floor. plz make the dataset and code this for me. here is an example code for a different linear regression mini project i did #MACHINE LEARNING - SUPERVISED LEARNING - REGRESSION - LINEAR REGRESSION #UNIVARIATE/SIMPLE/SINGLE - 1 column as inpit and 1 column as output
#MULTIVARIATE/MULTIPLE - Many columns as input and 1 column as output #Dataset - https://raw.githubusercontent.com/CubeRind/Ukmt-hmo-floors/main/hmo.csv
#Dataset - Ukmt-hmo-floors
#Year - years
#Hamilton - minium ukmt imc score to get into hamilton maths olympiad #1. Take the data and create dataframe
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/CubeRind/Ukmt-hmo-floors/main/hmo.csv')
df #2. PRE PROCESSING (OPTION)
#We are not performing step no 2 here #3. DATA VISUALISATION
import matplotlib.pyplot as plt
#plt.scatter(x-axis,y-axis)
plt.scatter(df['Year'],df['Hamilton'])
plt.title('Year vs Hamilton')
plt.xlabel('Year')
plt.ylabel('Hamilton') #Year - INPUT
#Hamilton - OUTPUT #4. DIVIDE into INPUT(x) and OUTPUT(y)
#Input(x) is always a 2 dimensional array
#Output(y) is always a 1 dimensional array
#: alone in row slicing selects all rows and : alone in col slicing selects all cols
#In the column slicing part, if there is a ':', then the array is 2 dimensional
x = df.iloc[:,:1].values
x #.values covert dataframe into an array #In the column slicing part, if there is no ':', then the array is 1 dimensional
y = df.iloc[:,1].values
y #5. Train and Test variables
#We are not performing step no 5 here, due to less/limited data #6. NORMALISATION/SCALING (done only for inputs)
#NORMALISATION/SCALING is done for MULTIVARIATE DATASETS
#Here our dataset is univariate #7. Apply a classifier, REGRESSOR  or clusterer
#sklearn.linear_model - package, LinerRegression - Library
from sklearn.linear_model import LinearRegression
model = LinearRegression() #8. Fit the MODEL
#LinearRegression.fit(x,y)
model.fit(x,y) #We are plotting/mapping the values of x and y in the linearregression library #9. Predict the output
y_pred = model.predict(x) #Using the input values, we predict the output
y_pred #PREDICTED OUTPUT VALUES y #ACTUAL OUTPUT VALUES #CONCLUSION: We have to compare y_pred and y.
#When we compare y_pred and y, we come to know that there is a huge difference in the corresponding values
#This huge difference does not mean our model has predcted wrong
#It only means that our model is NOT LINEAR/LESS LINEAR
#LINEARITY of a model depends on NATURE of the data as well as SIZE of the data. #INDIVIDUAL PREDICTION
#Now for 2000, I want to know the hamilton floor
model.predict([[2060]]) #CROSS VERIFY
#y = mx + C #Equation of a Straight line
#m - Slope
#C - y-intercept/constant
#y - dependent variable
#x - independent variable #To find out slope(m)
m = model.coef_
m #To find out y-intercept(C)
C = model.intercept_
C #Now substitute m and C values in y = mx + C formula
m*2000 + C #VISUALISATION FOR THE BEST FIT LINE
plt.scatter(x,y) #ACTUAL VALUES
plt.plot(x,y_pred,c = 'orange') #PREDICTED VALUES
plt.title('BEST FIT LINE') model.predict([[2023]]) model.predict([[2024]])