Labrecord
Labrecord
CODE:-
OUTPUT :-
CONCLUSION:- For loops are used when we have a block of code which we want
to repeat a fixed number of times. To loop through a set of code a specified number
of times, we can use the range() function.
PROGRAM # 2
AIM:- Write a while loop-based Python programme to print the even values
between 4000 and 10000.
CODE:-
OUTPUT:-
AIM :– Write a programme that uses a single function to calculate the area of a
specific shapes.
CODE :–
OUTPUT :–
LAB - 2
PROGRAM # 1
OUTPUT :-
OUTPUT:-
OUTPUT:-
OUTPUT :-
Step 4:- Assigning Multiple Values
OUTPUT :-
OUTPUT :-
Step 7 :- Array
OUTPUT :-
LAB - 4
PROGRAM # 1
OUTPUT :-
CODE :-
OUTPUT :-
CODE :-
OUTPUT :-
CODE :-
OUTPUT :-
Step 2 :- Histogram
CODE :–
OUTPUT :-
CONCLUSION :– Matplotlib is a cross-platform, data visualization and graphical
plotting library for Python and its numerical extension NumPy.
PROGRAM # 2
AIM :– Program to read a CSV File Format using “pandas Library”.
CODE :–
OUTPUT :–
CONCLUSION :– It is very easy and simple to read a CSV file using pandas library
functions. Here the read_csv() method of the pandas library is used to read data
from CSV files. We must import the Pandas library. read_csv() that retrieves data in
the form of the Dataframe.
PROGRAM # 3
AIM :– Program to check for “NaN” value in Pandas DataFrame
CODE :–
OUTPUT :–
PROGRAM # 4
AIM :– Program to fill the missing values.
Step 1 : Program to fill the missing glucose value with a constant value.
CODE :–
OUTPUT :–
CONCLUSION :- All the missing values in the price column are filled with the same
value that is 183.
STEP 2 :- Program to fill the missing glucose value with the median value of the
entire column.
CODE :–
OUTPUT :–
STEP 3 :- Program to fill the missing glucose value with the mean value of the
entire column.
CODE :–
OUTPUT :–
OUTPUT :–
LAB - 6
PROGRAM # 1
AIM :– Program to predict the value of one variable based on the value of another
variable using “Linear Regression” in an array.
STEP 1 :- Importing all the necessary libraries .
OUTPUT :–
CODE :–
OUTPUT :–
OUTPUT :–
STEP 7 :- Calculating y_pred.
CODE :–
OUTPUT :–
STEP 8 :- Plot the given data points and fit the regression line.
CODE :–
OUTPUT :–
OUTPUT :–
OUTPUT :–
STEP 11 :- Calculating root mean squared error.
OUTPUT :-
OUTPUT :-
CONCLUSION :–
LAB - 7
PROGRAM # 1
AIM :– Program to predict the value of a Glucose based on the value of another
variable using “Linear Regression” in “Diabetes Dataset” and splitting the data for
training and testing purposes.
CODE –
STEP 1 :- Importing all the necessary libraries and loading the diabetes dataset.
OUTPUT :-
STEP 3 :- Reshape array in such a way that the resulting array has only 1 column.
STEP 4 :- Standardize the values of variables into a standard format using
“MinMaxScaler.”
“Normalizing X”
CODE:-
OUTPUT :–
“Normalizing Y”
CODE:-
OUTPUT :–
OUTPUT :–
Sxy = np.sum((x_norm-x_mean)*(y_norm-y_mean))
Sxx = np.sum(pow((x_norm-x_mean),2))
Sxy , Sxx
OUTPUT :–
b1 = Sxy/Sxx
b0 = y_mean-b1*x_mean
STEP 9 :– Plot the given data points.
CODE :–
OUTPUT :–
plt.scatter(x_norm,y_norm)
plt.xlabel('Insulin X')
CODE :–
y_pred = b1 * x_norm + b0
OUTPUT :–
STEP 11 :- Plot the given data points and fit the regression line.
CODE :–
OUTPUT :–
plt.scatter(x_norm,y_norm,color = 'red')
plt.plot(x_norm,y_pred,color = 'green')
plt.xlabel('X')
plt.ylabel('y')
STEP 12 :- Calculating Mean Absolute error.
CODE :–
OUTPUT :–
OUTPUT :–
OUTPUT :–
CONCLUSION :–
CODE :–
OUTPUT :–
x_train, x_test, y_train, y_test = train_test_split(
x_norm, y_norm, train_size=538, test_size=230, random_
STEP 4 :- Calculating sample covariance and sample variance.
xtr_mean = np.mean(x_train)
ytr_mean = np.mean(y_train)
print(xtr_mean)
print(ytr_mean)
OUTPUT :–
OUTPUT :–
OUTPUT :–
plt.scatter(x_train,y_train)
plt.xlabel('Insulin X')
plt.ylabel('Glucose Y')
STEP 7 :- Calculating y_pred.
CODE :–
OUTPUT :–
STEP 8 :- Plot the given data points and fit the regression line.
y_predt
CODE :–
OUTPUT :–
CODE :–
OUTPUT :–
OUTPUT :–
OUTPUT :–
OUTPUT :–
CONCLUSION :–