DS2
Q. 1Write a PHP script to change the preferences of your web page like font style, font size, font color,
background color using cookie. Display selected setting on next web page and actual implementation
(with new settings) on third page (Use Cookies). [Marks 15]
Q. 2)Create ‘Salary’ Data set . Build a linear regression model by identifying independent and target
variable. Split the variables into tr
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
Create the salary dataset
data = {'YearsExperience': [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5],
'Salary': [30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000, 75000]}
Convert the dataset into a DataFrame
df = pd.DataFrame(data)
Identify independent and target variables
X = df[['YearsExperience']] # Independent variable (Years of Experience)
y = df['Salary'] # Target variable (Salary)
Split the variables into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
Print the training and testing sets
print("Training set:")
print(X_train)
print(y_train)
print("\nTesting set:")
print(X_test)
print(y_test)
Build a simple linear regression model
model = LinearRegression()
model.fit(X_train, y_train)