Esempio n. 1
0
def working_PCA():

    #Read data
    MLobj = EasyClassi()
    MLobj.read("wine.csv")

    #Prepare data
    MLobj.explore()
    MLobj.split_X_y()
    MLobj.split_ds()
    MLobj.scale_features(scaleY=False)

    #Applyinh PCA
    from sklearn.decomposition import PCA
    pca = PCA(n_components=2)
    MLobj.X_train = pca.fit_transform(MLobj.X_train)
    MLobj.X_test = pca.transform(MLobj.X_test)
    explained_variance = pca.explained_variance_ratio_

    #Classification
    MLobj.fitLog()

    #Predict
    y_pred = MLobj.predict()

    #Evaluation confusion matrix
    cm = MLobj.create_confusion_matrix()

    MLobj.printModelPerformance()

    #Visualize data
    #MLobj.visualize_lineal_2D_class(MLobj.X_train,MLobj.y_train,x1="PC1",x2="PC2",classNum=3)
    MLobj.visualize_lineal_2D_class(x1="PC1", x2="PC2", classNum=3)
Esempio n. 2
0
def working_kernel_PCA_easy():

    #Read data
    MLobj = EasyClassi()
    MLobj.read("Social_Network_Ads.csv")

    #Prepare data
    MLobj.explore()
    MLobj.split_X_y()
    MLobj.X = MLobj.X[:, 2:4]
    MLobj.split_ds()
    MLobj.scale_features(scaleY=False)

    #Applyinh Kernel PCA
    MLobj.applyKernelPCA()

    #Classification
    MLobj.fitLog()

    #Predict
    y_pred = MLobj.predict()

    #Evaluation confusion matrix
    cm = MLobj.create_confusion_matrix()

    MLobj.printModelPerformance()

    #Visualize data
    #MLobj.visualize_lineal_2D_class(MLobj.X_train,MLobj.y_train,x1="KPC1",x2="KPC2")
    MLobj.visualize_lineal_2D_class(x1="KPC1", x2="KPC2")
Esempio n. 3
0
def working_PCA_easy():

    #Read data
    MLobj = EasyClassi()
    MLobj.read("wine.csv")

    #Prepare data
    MLobj.explore()
    MLobj.split_X_y()
    MLobj.split_ds()
    MLobj.scale_features(scaleY=False)

    #Applyinh PCA
    MLobj.applyPCA()
    PCAratio = MLobj.getPCAVarianceRatio()

    #Classification
    MLobj.fitLog()

    #Predict
    y_pred = MLobj.predict()

    #Evaluation confusion matrix
    cm = MLobj.create_confusion_matrix()

    MLobj.printModelPerformance()

    #Visualize data
    #MLobj.visualize_lineal_2D_class(MLobj.X_train,MLobj.y_train,x1="PC1",x2="PC2",classNum=3)
    MLobj.visualize_lineal_2D_class(x1="PC1", x2="PC2", classNum=3)
Esempio n. 4
0
def working_class_log_easy():

    #Read data
    MLobj = EasyClassi()
    MLobj.read("Social_Network_Ads.csv")

    #Prepare data
    MLobj.explore()
    MLobj.split_X_y()
    MLobj.X = MLobj.X[:, 2:4]
    MLobj.split_ds(test_set=1 / 4)
    MLobj.scale_features(scaleY=False)

    #Classification
    MLobj.fitLog()

    #Predict
    y_pred = MLobj.predict()

    #Evaluation confusion matrix
    cm = MLobj.create_confusion_matrix()

    #Visualize data
    #MLobj.visualize_lineal_2D_class(MLobj.X_train,MLobj.y_train)
    MLobj.visualize_lineal_2D_class()