Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import matplotlib.pyplot as plt
- import scipy as sci
- from sklearn import preprocessing
- from sklearn.cluster import DBSCAN
- df = pd.read_csv('mystery.csv', header=None)
- scaler = preprocessing.MinMaxScaler(feature_range=(-1, 1))
- scaler.fit(df)
- df = pd.DataFrame(scaler.transform(df))
- def ezScatter(x, y):
- plt.scatter(df[x], df[y])
- plt.xlabel(x)
- plt.ylabel(y)
- plt.title((str(x) + "->" + str(y)))
- plt.show()
- def ezDB(x, y):
- toFit = df[[x, y]].copy()
- dbscan = DBSCAN(eps=.10, min_samples=4)
- model = dbscan.fit(toFit)
- clusterLabels = model.labels_
- plt.scatter(df[x], df[y], c=clusterLabels, cmap='hsv')
- plt.xlabel(x)
- plt.ylabel(y)
- plt.title((str(x) + "->" + str(y) + " DBSCAN"))
- plt.show()
- pd.plotting.scatter_matrix(df, cmap='prism')
- plt.show()
- print("ctrl c to quit. Too lazy for an escape ")
- while True:
- xFig = int(input("X to examine: "))
- yFig = int(input("Y to examine: "))
- ezScatter(xFig, yFig)
- ezDB(xFig, yFig)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement