Ejemplo n.º 1
0
'''
from sklearn.linear_model import LinearRegression
from RegressionModel import RegressionModel
from MLData import MLData
from Visualization import Visualization


class LLS(RegressionModel):
    """
    This class deals with K Nearest Neighbour Classifier
    """
    def __init__(self):
        self.regressor = LinearRegression()
        
        
if __name__ == "__main__":
    
    data = MLData()
    data.loadData("../data/mobile.csv", 2, 2)
    
    #fit the classifier to the data
    lls = LLS()
    lls.fitRegressor(data)
    
    #draw line
    coef = lls.regressor.coef_.flatten().tolist() + [lls.regressor.intercept_]
    print ("LLS line coef", coef)
    vis = Visualization()
    vis.visualizeData(data, coef)
Ejemplo n.º 2
0
from sklearn import svm
from MLData import MLData
from Performance import Results
from Visualization import Visualization


class SVM(ClassifierModel):
    """
    This class deals with support vector machines
    """
    def __init__(self):
        self.classifier = svm.SVC(kernel="linear")


if __name__ == "__main__":
    data = MLData()
    data.loadData("../data/fish.csv", 1, 2)

    #fit the classifier to the data
    svm = SVM()
    svm.fitClassifier(data)

    #find accuracy
    results = Results()
    results.calculateAccuracy(svm, data)

    #draw line
    print("svm line", svm.classifier.coef_)
    vis = Visualization()
    vis.visualizeData(data, svm.classifier.coef_)