Commit 1e2cbf4c authored by isurugunarathna's avatar isurugunarathna

Adding Comments and dog breeds

parent 0c73f140
#import pandas
import pandas as pd
#creating columns for dataset preview
col_names = ['breed', 'age', 'weight', 'label']
# load dataset
dog_breeds = ["german_sheppard", "labrador", "pomeranian", "husky", "golden_retriever", "poodle", "bulldog", "shiba", "rottweiler","boxer","Dobermen"]
# reading data set
pima = pd.read_csv("weight_data.csv", header=None, names=col_names)
print("===================")
print("Dataset head")
print("===================")
#previewing the head of data set
print(pima.head())
#split dataset in features and target variable
#split dataset in to features and target variable
feature_cols = ['breed', 'age', 'weight']
X = pima[feature_cols] # Features
y = pima.label # Target variable
#Use sklearn to train dataset
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.25,random_state=0)
# import the class
#use logistic Regression
from sklearn.linear_model import LogisticRegression
# instantiate the model (using the default parameters)
......@@ -26,7 +32,6 @@ logreg = LogisticRegression()
# fit the model with data
logreg.fit(X_train,y_train)
#
y_pred=logreg.predict(X_test)
# import the metrics class
......@@ -35,16 +40,18 @@ cnf_matrix = metrics.confusion_matrix(y_test, y_pred)
print("===================")
print("Confusion matrix")
print("===================")
#printing a confusion matrix
print(cnf_matrix)
print("===================")
print("Accuracy")
print("===================")
#printing the accuracy of model
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
# print("Precision:",metrics.precision_score(y_test, y_pred))
# print("Recall:",metrics.recall_score(y_test, y_pred))
# Prediction test
y_prediction_test = logreg.predict([[12,3,48]])
y_prediction_test = logreg.predict([[5,4,22]])
y_labels = ["Overweight", "Normal", "Underweight"]
print(y_labels[y_prediction_test[0]])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment