Site icon DataFlair

ML Project – Predict Annual Tuition Fee using Multiple Linear Regression Model

Machine Learning courses with 110+ Real-time projects Start Now!!

Program 1

College Dataset

# To build a machine learning model that can predict the annual tuition fee of a
# private college based on:
# Its ranking , The student satisfaction score , The placement rate
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
# Load Excel file
df = pd.read_excel("D://MLFile/college_data.xlsx")
#print(df.isnull().sum())

# Display top rows (optional)
# print("Sample Data:\n", df.head())
#
# Define features and target i.e Independed and Depended variables
X = df[['Ranking', 'Student_Satisfaction', 'Placement_Rate (%)']]
y = df['Tuition_Fee ($)']
#
# # Train Linear Regression model
model = LinearRegression()
model.fit(X, y) #  Independed and Depended variables
print(model)

# Get user input
ranking = float(input("Enter College Ranking (1 = Best): "))
satisfaction = float(input("Enter Student Satisfaction Score (0-10): "))
placement = float(input("Enter Placement Rate (%): "))
#
# Predict tuition fee
predicted_fee = model.predict(np.array([[ranking, satisfaction, placement]]))
print("\nPredicted Annual Tuition Fee: $", round(predicted_fee[0], 2))

alpha=model.intercept_
# print(alpha)
beta=model.coef_
# print(beta[0])
# print(beta[1])
# print(beta[2])
formula_fee=alpha+(beta[0]*ranking)+(beta[1]*satisfaction)+(beta[2]*placement)

print("\nPredicted Annual Tuition Fee accroding to formula: $", round(formula_fee, 2))

 

Exit mobile version