Reagrding Lab Test
Reagrding Lab Test
*** You must be using python and jupyter notebook. No other platform
will be entertained. There will be two tasks in exam a) Tasks on
synthetic dataset b) Task on original dataset.
In exam the tasks specially the type of synthetic data generation and
Dataset may be different. So be careful. Marks will be given only for
fully executable codes.
** Learn all the questions and go through the code properly for exam.
**Execute the same for practice.
** There will be two theory questions as well.
Related questions:
Question 1: Data Generation and Visualization
Sample Code:
# Create a DataFrame
data = pd.DataFrame({'Study Hours': study_hours, 'Exam Scores':
exam_scores})
X = data[['Study Hours']]
y = data['Exam Scores']
regressor = LinearRegression()
regressor.fit(X, y)
Like this:
from sklearn.datasets import load_iris
import pandas as pd
Provide the mean, median, and standard deviation for the sepal length
of the Iris dataset.
Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import pearsonr, ttest_ind
from sklearn.preprocessing import MinMaxScaler
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import SVC
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, precision_score,
recall_score
from sklearn.datasets import load_iris
logreg_classifier.fit(X_train, y_train)
knn_classifier.fit(X_train, y_train)
logreg_accuracy = accuracy_score(y_test,
logreg_classifier.predict(X_test))
knn_accuracy = accuracy_score(y_test, knn_classifier.predict(X_test))