Exemplo n.º 1
0
    def conf_matrix(self, y_test, y_pred, clf, uniqueNames):
        cnf_matrix = confusion_matrix(y_test.values, y_pred)
        np.set_printoptions(precision=2)

        # Plot non-normalized confusion matrix
        plt.figure()
        vis = Visualisation()
        class_names = uniqueNames
        vis.plot_confusion_matrix(
            clf,
            cnf_matrix,
            classes=class_names,
            title='Confusion matrix, without normalization')
Exemplo n.º 2
0
 def __init__(self, configFilepath=None):
     #configFilepath = r"C:\Users\ashvin\Desktop\UnderDevelopment\sentimentConfig.csv"
     df = pd.read_csv(configFilepath)
     df.set_index('Parameters', inplace=True)
     reviews = df.loc['paths', 'Value'].split(',')
     catNum = df.loc['numOfCat', 'Value']
     catTypes = df.loc['catType', 'Value'].split(',')
     sentimentLabel = df.loc['train', 'Value']
     sentiment = sa.SentimentTrain()
     acc, allReviews = sentiment.extract(reviews, catNum, catTypes,
                                         sentimentLabel)
     visuals = Visualisation(df=None, target=None)
     visuals.wordCloud(allReviews)
Exemplo n.º 3
0
 def __init__(self, df, clusterSizes=None):
     Unsupervised.__init__(self)
     self.df = df
     if clusterSizes == None:
         self.scores = []
         clusterSizes = [2, 3, 4, 5, 6, 7, 8, 9, 10]
         for clusterSize in clusterSizes:
             self.kmeans = KMeans(n_clusters=clusterSize)
             self.fit()
             self.labels, self.centroids, self.silhouette_avg = self.predict(
             )
             self.scores.append(self.silhouette_avg)
         visuals = Visualisation()
         visuals.silhouetteScores(self.scores, clusterSizes)
     else:
         self.kmeans = KMeans(n_clusters=clusterSizes)
         self.fit()
         self.labels, self.centroids, _ = self.predict()
Exemplo n.º 4
0
 def __init__(self, df=None):
     #configFilepath = r"C:\Users\ashvin\Desktop\UnderDevelopment\sentimentConfig.csv"
     #df = pd.read_csv(configFilepath)
     #df.set_index('Parameters', inplace = True)
     print('creating Results directory--------> at {}'.format(os.getcwd()))
     try:
         os.makedirs('results')
     except:
         pass
     reviews = df.loc['paths', 'Value'].split(',')
     catNum = df.loc['numOfCat', 'Value']
     catTypes = df.loc['catType', 'Value'].split(',')
     sentimentLabel = df.loc['train', 'Value']
     sentiment = sa.SentimentTrain()
     acc, allReviews = sentiment.extract(reviews, catNum, catTypes,
                                         sentimentLabel)
     visuals = Visualisation(df=None, target=None)
     visuals.wordCloud(allReviews)
Exemplo n.º 5
0
    def __init__(self, configFilepath=None):
        self.configFilepath = configFilepath
        configDf = pd.read_csv(configFilepath, sep=',')
        configDf.set_index('Parameters', inplace=True)
        columnsConsidered = configDf.loc['ColumnsConsidered', 'Value']
        imputation = configDf.loc['Imputation', 'Value']
        target = configDf.loc['Target', 'Value']
        clf = configDf.loc['Classifier', 'Value']
        modelingType = configDf.loc['ModelingType', 'Value']
        filepath = configDf.loc['filepath', 'Value']
        separator = configDf.loc['separator', 'Value']
        temp1 = DataQualityCheck(filepath,
                                 target=target,
                                 separator=separator,
                                 columnsConsidered=columnsConsidered)
        df1 = temp1.considerColumns()
        temp1.checkMissingValues()
        temp1.checkOutliers()

        temp2 = DataPreparation(imputation=imputation)
        df1 = temp2.convertCategoricalToDummy(df1)
        df1 = temp2.imputation(df1)
        df1 = temp2.featureNormalisation(df1)

        if modelingType == 'classification':
            if clf == 'Logistic':
                temp3 = Logistic(target=target, df=df1)
                scores = temp3.runLogistic()
            elif clf == 'SVM':
                temp3 = SVM(target=target, df=df1)
                scores = temp3.runSVM()
            elif clf == 'RF':
                temp3 = RandomForestClf(target=target, df=df1)
                scores = temp3.runRF()
            elif clf == 'NN':
                temp3 = NeuralNetwork(target=target, df=df1)
                scores = temp3.runNN()

        elif modelingType == 'regression':
            if clf == 'Linear':
                temp3 = Linear(target=target, df=df1)
                scores = temp3.runLinear()
            elif clf == 'LassoRegression':
                temp3 = LassoRegression(target=target, df=df1)
                scores = temp3.runLasso()
            elif clf == 'RidgeRegression':
                temp3 = RidgeRegression(target=target, df=df1)
                scores = temp3.runRidge()
            elif clf == 'RandomForest':
                temp3 = RandomForestReg(target=target, df=df1)
                scores = temp3.runRF()

        print('scores for classifier {} are: {}'.format(
            configDf.loc['Classifier', 'Value'], scores))

        temp4 = Visualisation(df=df1, target=target)
agents = [LeftAgent, StayAgent, RandomAgent]

world = World(WORLD_SIZE)
world.add_obstacles(COUNT_OBSTACLES)
world.add_food(COUNT_FOOD)

for player_index in range(COUNT_PLAYERS):
    random_position = [np.random.randint(0, WORLD_SIZE[0]), np.random.randint(0, WORLD_SIZE[1])]
    bot = Player(random_position, player_index)
    Agent = np.random.choice(agents)
    bot.set_agent(Agent())
    world.player_register(bot)

if IS_VISUALISATION:
    view = Visualisation(world)

running = True
counter = 1
while running and counter < COUNT_EPOCH:
    world.tick()
    if IS_VISUALISATION:
        view.draw_objects()
        view.draw_players()
        view.append_food()
        view.vis_game.display.flip()
        for event in view.vis_game.event.get():
            if event.type == view.vis_game.QUIT:
                running = False
    else:
        print(world)
Exemplo n.º 7
0
 def ROCplots(self, ytest, ypred_prob, clf):
     vis = Visualisation()
     vis.ROCplots(ytest, ypred_prob, clf)
Exemplo n.º 8
0
 def residVsFitted(self, ypred, ytest, clf):
     vis = Visualisation()
     vis.residVsPredPlots(ypred, ytest, clf)
Exemplo n.º 9
0
 def normalQQ(self, ypred, ytest, clf):
     vis = Visualisation()
     vis.normalQQplots(ypred, ytest, clf)
Exemplo n.º 10
0
 def precisionVsrecallPlots(self, ytest, ypred_prob, clf):
     vis = Visualisation()
     vis.precVsRecall(ytest, ypred_prob, clf)
Exemplo n.º 11
0
 def jointPlot(self, df, target):
     vis = Visualisation()
     vis.snsJointPlots(df, target)
Exemplo n.º 12
0
 def saveBoxPlots(self, df):
     vis = Visualisation()
     vis.boxplot(df)
Exemplo n.º 13
0
 def savePairPlots(self, df):
     vis = Visualisation()
     vis.pairplot(df)
Exemplo n.º 14
0
 def hist(self, df):
     vis = Visualisation()
     vis.histogram(df)
Exemplo n.º 15
0
 def corr_plot(self, df, clf):
     vis = Visualisation()
     vis.correlationPlot(df, clf)
Exemplo n.º 16
0
 def __init__(self):
     self.visualization = Visualisation()
     self.controller = Controller()
Exemplo n.º 17
0
 def swarmPlots(self, df, target):
     vis = Visualisation()
     vis.snsSwarmPlots(df, target)