Point clustering based on a certain value

I'm trying to cluster points based on the sum of a attributes of its nearest neighbors. So here are the points in the data set as they are: The objective is that each point has an "evalfield" attribute associated with it. I want to be able to cluster them such that the sum of the clustered points ad up to a predetermined value that I decide.(last column). To illustrate with an example: Here are a collection of points , with their attribute on the basis for which clustering is too occur written above them. (0.5,0.6 etc.)

I want to be able to cluster them such that the sum of this value in a cluster adds up to a predetermined value (1.1 in this case) EDIT

So I followed the steps and pretty much copied out the code as is to run it in qgis.

import geopandas as gpd
from shapely import geometry as geom

exploded_gdf = gpd.GeoDataFrame()
exploded_gdf.crs = gdf.crs

print('starting ...')

for index, row in gdf.iterrows():
if float(row['evalfield']) == 0.01:
exploded_gdf = exploded_gdf.append(row, ignore_index=True)
else:
for i in range(0, int(row['evalfield']*100)):
entry = row.copy()
entry['evalfield'] = 0.01
exploded_gdf = exploded_gdf.append(entry, ignore_index=True)

print('processing done ... saving')

gdf.to_file(driver='ESRI Shapefile', filename="result.shp")

print('saved')

But I keep getting this error:

Python Console
Use iface to access QGIS API interface or Type help(iface) for more info
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:/Users/USER/OneDrive/Documents/Studies etc/adrchitectural design/thesis/Thesisgisdata/Siteselectionalgs/alg1_point_filtering_explosion.py", line 24, in <module>
File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\geopandas\io\file.py", line 19, in read_file
with fiona.open(filename, **kwargs) as f:
File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\fiona\__init__.py", line 170, in open
raise IOError("no such file or directory: %r" % path)
IOError: no such file or directory: 'filteredptlst.shp'

Ive already tried changing the project environment and putting in a complete file path to the location of the file.

I couldn't se anything wrong with the code so I ran it separately in Visual Studio , but that doesn't seem to work either , there are no trackback errors but none of the print messages which I put I ( to check) arent't displayed either.

P.S. I'm really new to both GIS and Python and there must be something really obvious I'm overlooking here.

NOTE : I'm using here some packages that you didn't mention in your tags

My suggestion would be to first explode your points data to the unit (like 0.1), this means a point that have a value of 0.5 will generate five points each have a value of 0.1

EDIT : to explode your points you can loop through your dataset and create new points when your value isn't equal to 0.1

import geopandas as gpd
from shapely import geometry as geom

exploded_gdf = gpd.GeoDataFrame()
exploded_gdf.crs = gdf.crs
for index, row in gdf.iterrows():
if row['your_value'] == 0.1:
exploded_gdf = exploded_gdf.append(row, ignore_index = True)
else:
for i in range(0, row['your_value']*10):
entry = row.copy()
entry['your_value'] = 0.1
exploded_gdf = exploded_gdf.append(entry, ignore_index = True)

here take a look at this you'll like it geopandas

then run K-means clustering algorithm from scipy package to cluster your points:

from scipy.cluster.vq import kmeans2, whiten
import geopandas as gpd
import numpy as np