<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
import numpy as np

data = pd.read_csv("derm.csv")
data.head()

data.isnull().sum()
data.dropna(inplace=True)
data.isnull().sum()
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
sns.countplot(data['class'])<jupyter_output><empty_output><jupyter_text>*   There are 6 classes of erythemato-squamous disease<jupyter_code>corr = data.corr()
plt.figure(figsize=(12,12))
sns.heatmap(corr, linewidths=.5, cmap='viridis')
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
#The Class code column is the value that needs to be predicted from the analysis. 
#Hence we will have to split X and y(Features and labels) based on this information
X = data.iloc[:,0:34]  # all rows, all the features and no labels
y = data.iloc[:,-1]  # all rows, label only
scaled_data = scaler.fit_transform(X)
scaled_data
from sklearn.decomposition import PCA
pca = PCA()
pca.fit_transform(X)
pca.get_covariance()
explained_variance=pca.explained_variance_ratio_
explained_variance
with plt.style.context('dark_background'):
    plt.figure(figsize=(8, 6))

    plt.bar(range(34), explained_variance, alpha=0.5, align='center',
            label='Explained Variance representation')
    plt.ylabel('Explained variance ratio')
    plt.xlabel('Principal components')
    plt.legend(loc='best')
    plt.tight_layout()<jupyter_output><empty_output><jupyter_text>The above graph is a clear indication that 'erythema' has the largest explained variance ratio in this dataset.<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
X_train.shape
from sklearn.svm import SVC
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import classification_report, confusion_matrix
param_grid = {'C': [0.1, 1, 10, 100], 'gamma': [1, 0.1, 0.01, 0.001]}
grid = GridSearchCV(SVC(), param_grid, refit=True, verbose=2)
grid.fit(X_train, y_train)
import pickle
with open('model.pkl', 'wb') as f:
  pickle.dump(grid, f)
with open('model.pkl', 'rb') as f:
  clf = pickle.load(f)
grid_predictions = clf.predict(X_test)
print(confusion_matrix(y_test, grid_predictions))
print(classification_report(y_test, grid_predictions))
from sklearn.ensemble import RandomForestRegressor
from sklearn.ensemble import VotingClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
model = RandomForestRegressor()
estimators = np.arange(10, 300, 10)
scores = []
for n in estimators:
    model.set_params(n_estimators=n)
    model.fit(X_train, y_train)
    scores.append(model.score(X_test, y_test))
       
print(scores)
plt.title("Random Forest Regressor - Effect of n_estimators")
plt.xlabel("n_estimator")
plt.ylabel("score")
plt.plot(estimators, scores)
from sklearn.ensemble import AdaBoostClassifier
from sklearn.model_selection import cross_val_score
estimators = np.arange(100, 2000, 200)
scores = []
for n in estimators:
    clf = AdaBoostClassifier(learning_rate = 0.1,n_estimators = n,random_state=42)
    clf_check = clf.fit(X_train,y_train)
    score = cross_val_score(clf, X_train, y_train, cv=5)
    scores.append(score)
    print('The Estimator {} has a score of {}'.format(n,score))
plt.title("AdaBoost Classifier - Effect of n_estimators")
plt.xlabel("n_estimator")
plt.ylabel("score")
plt.plot(estimators, scores)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1154292343387471, 'fraction_numerical': 0.01769141531322506, 'mean_word_length': 6.185416666666667, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '499273', 'license': 'MIT', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1205, 'n_words': 287, 'path': 'DermDetect.ipynb', 'repo_name': 'reemaratnani/startup_project_stripe_payment', 'size': '3448'}