0% found this document useful (0 votes)
13 views

Preductive Modelling Assignment

xyz

Uploaded by

Shrutika Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Preductive Modelling Assignment

xyz

Uploaded by

Shrutika Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

import seaborn as sns

from sklearn.model_selection import train_test_split

from sklearn.ensemble import RandomForestClassifier

from sklearn.metrics import accuracy_score

from sklearn.preprocessing import StandardScaler

RANDOM FOREST

df=pd.read_csv(r"C:\Users\shrut\Downloads\breast_cancer.csv")

df

df.shape

#Checking for missing values

df.isnull().sum()
df.drop('Unnamed: 32', axis = 1, inplace = True)

df.corr()

# Getting Feature

x = df.drop(columns = 'diagnosis')

# Getting Predicting Value

y = df['diagnosis']

X_train,X_test,Y_train,Y_test=train_test_split(X_new,Y,test_size=0.3,random_state=40)

rf=RandomForestClassifier(n_estimators=100)

rf.fit(X_train,Y_train)

pred=rf.predict(X_test)

ac=accuracy_score(Y_test,pred)

print("The accuracy is",ac*100)


SVM
from sklearn.svm import SVC

model = SVC()

model.fit(X_train, Y_train)

model.score(X_test, Y_test)

#regulariztion(C)

model_C = SVC(C=1)

model_C.fit(x_train, y_train)

model_C.score(x_test, y_test)

model_C = SVC(C=10)

model_C.fit(x_train, y_train)

model_C.score(x_test, y_test)

model_C = SVC(C=100)

model_C.fit(x_train, y_train)

model_C.score(x_test, y_test)

#Gamma

model_g = SVC(gamma=10)

model_C.fit(x_train, y_train)

model_C.score(x_test, y_test)

You might also like