def main(): clusterers = [] for file in os.listdir('cached_clusterers'): f = open('cached_clusterers/'+file, 'rb') clusterers.append(pickle.load(f)) f.close() purities = {} for cl in clusterers: e = Presenter() purities[cl.n_clusters] = e.purity(cl.labels_true, cl.labels_pred) df = pd.DataFrame(list(purities.items()), columns=('Topics', 'Overall Purity')) fig, ax = plt.subplots(1) pu_ax = df['Overall Purity'].plot(ax=ax, x='Topics', grid=True, legend=True, figsize=(40, 25)) val = df['Overall Purity'].values xpoints = np.linspace(0, val.shape[0]-1, val.shape[0]) poly = np.polyfit(xpoints, val, 2) poly = np.poly1d(poly) pol_ax = plt.plot(xpoints, poly(xpoints), 'r-', label='Fitted Polynomial') handles, labels = ax.get_legend_handles_labels() ax.legend(handles, labels) ax.set_xlabel('Topics') fig.savefig('Purity.svg', format='svg') pdb.set_trace()
def optimize_cluster_size(self, max_cl, file_name, min_cl=10): df = pd.DataFrame(columns=['Overall Purity']) for i in range(min_cl, max_cl): self.clust.cluster(i, n_init=10) e = Presenter() e.purity(self.clust.labels_true, self.clust.labels_pred) df.loc[i] = e.overall_purity # Write dataframe to file f = open(file_name, 'wb') pickle.dump(df, f) f.close()
def main(): app = QtWidgets.QApplication(sys.argv) view = MainWindow() model = Repository() presenter = Presenter(view, model) view.show() sys.exit(app.exec_())
def main(): try: app = QApplication([]) model = DataBase() view = View() _ = Presenter(model, view) sys.exit(app.exec_()) except Exception as ex: print('ERROR! : {0}'.format(str(ex))) sys.exit(1)
import sys from PyQt5 import QtGui from PyQt5.QtWidgets import QApplication from presenter.presenter import Presenter if __name__ == '__main__': app = QApplication(sys.argv) app.setStyle("Fusion") app.setWindowIcon(QtGui.QIcon("./resources/virusIcon.png")) app.setApplicationDisplayName("Simulator") presenter = Presenter() presenter.ui.show() sys.exit(app.exec_())
from view.view import GuiView from presenter.presenter import Presenter from model.authorized_yadisk_model import AuthorizedYadiskModel from model.bublic_yadisk_model import BublicYadiskModel from model.local_model import LocalModel from model.security_model import SecurityModel import logging import magic_const logging.basicConfig(**magic_const.LOGGING_CONFIG) if __name__ == "__main__": app = QApplication([]) gui_view = GuiView() yadisk_model = AuthorizedYadiskModel() local_model = LocalModel() bublic_yadisk_model = BublicYadiskModel() security_model = SecurityModel() presenter = Presenter(gui_view, yadisk_model, local_model, bublic_yadisk_model, security_model) gui_view.set_presenter(presenter) sys.exit(app.exec_())
def main(): app = QApplication([]) model = DataBase() view = View() _ = Presenter(model, view) sys.exit(app.exec_())