ML Fat
ML Fat
Submitted to:
Jyotismita Chaki
Jyotismita@vit.ac.in
FAT Exam
Submitted by :
Shiny. S (21MID0079)
Shiny.2021@vitstudent.ac.in
CODE:
import pandas as pd
import numpy as np
data = pd.read_csv("agriculture_dataset.csv")
data.head()
data.info()
data.isnull().sum()
data.describe()
SCREENSHOT :
There are no null values in the dataset. So there isn’t need for further preprocessing
steps.
CODE :
x = data.iloc[:,0:6]
y = data['Plant type']
SCREENSHOT:
C ) Use a suitable hyperparameter-tuned ML model to train the dataset.
Random Forest is the suitable hyperparameter-tuned model to train the given dataset.
CODE :
rf_classifier.fit(X_train, y_train)
y_pred = rf_classifier.predict(X_test)
SCREENSHOT:
CODE:
model.fit(X_train, y_train)
pred_train = model.predict(X_train)
train_score = accuracy_score(y_train,pred_train)
print('train_accuracy_score',train_score)
pred_val = model.predict(X_test)
val_score = accuracy_score(y_test,pred_val)
print('val_accuracy_score',val_score)
SCREENSHOT:
rf = RandomForestClassifier()
rand_search.fit(X_train, y_train)
best_rf = rand_search.best_estimator_
pred_train = best_rf.predict(X_train)
train_score = accuracy_score(y_train,pred_train)
print('train_accuracy_score',train_score)
pred_val = best_rf.predict(X_test)
val_score = accuracy_score(y_test,pred_val)
print('val_accuracy_score',val_score)
SCREENSHOT:
CODE:
cm = confusion_matrix(y_test,pred_val)
ConfusionMatrixDisplay(confusion_matrix=cm).plot()
SCREENSHOT:
a) Perform the pre-processing steps if needed. If the pre-processing steps are not needed
CODE:
import numpy as np
import pandas as pd
data = pd.read_csv('University_dataset.csv')
data.head()
data.isnull().sum()
SCREENSHOT:
B ) Divide the dataset into train, validation, and test set.
CODE:
X = data.iloc[:, 1:6].values
y = data.iloc[:, 6].values
SCREENSHOT:
C ) Can we use an ANN to train the dataset? If yes, then create an ANN and train and validate the
model by using the dataset and write a discussion on the performance of the model on the answer
booklet given. If no, then write your justification on the answer booklet given.
CODE:
scaler = StandardScaler()
X = scaler.fit_transform(X)
model = Sequential()
model.add(Dense(64, activation='relu'))
model.add(Dense(1, activation='linear'))
# Make predictions
predictions = model.predict(X_test)
SCREENSHOT: