-
Notifications
You must be signed in to change notification settings - Fork 0
/
kmeansplusplus.py
32 lines (26 loc) · 985 Bytes
/
kmeansplusplus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 5 17:13:20 2021
@author: Roneet
"""
import numpy as np
import math
# from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import normalize
import matplotlib.pyplot as plt
from scipy.spatial import distance
import pandas as pd
import os
#Read csv file and return dataframe.
def read_csv_file(csv_file):
data_frame= None
if os.path.exists(csv_file):
data_frame = pd.read_csv(csv_file)
return data_frame
#Load file and remove timestamps for clustering.
integratedVectors = read_csv_file('C:/Users/Roneet/Documents/DTU/02461/BoolAndLocationData/integratedVectorsNoEmpties.csv')
integratedVectors = integratedVectors.loc[:, ~integratedVectors.columns.str.contains('^Unnamed')]
integratedVectors = integratedVectors.sort_values(by=['Timestamp'])
del integratedVectors['Timestamp']
del integratedVectors['Bool']
integrals_matrix = integratedVectors.to_numpy()