Ds29
Q. 1) Write a PHP script for the following: Design a form to accept a number from the user.
Perform the operations and show the results.
- Fibonacci Series.
- To find sum of the digits of that number.
(Use the concept of self processing page.) [Marks 15]
Q. 2 ) Build a logistic regression model for Student Score Dataset.
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
df = pd.read_csv('student_scores.csv')
print(df.head())
)
X = df[['Feature1', 'Feature2', ...]] # Features
y = df['Label'] # Target variable
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
Create a logistic regression model
model = LogisticRegression()
model.fit(X_train, y_train)
Make predictions on the testing set
y_pred = model.predict(X_test)
print('Accuracy:', accuracy_score(y_test, y_pred))
print('Classification Report:\n', classification_report(y_test, y_pred))
print('Confusion Matrix:\n', confusion_matrix(y_test, y_pred))
new_data = [[value1, value2, ...]]
predicted_label = model.predict(new_data)
print('Predicted Label:', predicted_label)