0% found this document useful (0 votes)
4 views1 page

Linear Regression with Salary Prediction

Uploaded by

sem4submission
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Linear Regression with Salary Prediction

Uploaded by

sem4submission
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import numpy as np

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

# Sample dataset with one independent variable (e.g., 'Experience') and two
dependent variables ('Salary', 'Bonus')
df = [Link]({
'Experience': [1, 2, 3, 4, 5],
'Salary': [30000, 35000, 40000, 45000, 50000],
'Bonus': [1000, 2000, 3000, 4000, 5000]
})

#data = pd.read_csv('/content/[Link]')
# Feature (X) - One independent variable
X = df[['Experience']]

# Target (y) - Two dependent variables


y = df[['Salary', 'Bonus']]

# Train-test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,
random_state=42)

# Initialize and train the model


model = LinearRegression()
[Link](X_train, y_train)

# Predict
y_pred = [Link](X_test)

# Print predictions
print(f'Predicted values: {y_pred}')

You might also like