Saravanan666/pypi-org huggingface dataset:
Package: kmeans1d
kmeans1dA Python library with an implementation ofk-means clustering on 1D data, based on the algorithm
in (Xiaolin 1991), as presented in section 2.2 of (Gronlund et al., 2017).Globally optimalk-means clustering is NP-hard for multi-dimensional data. Lloyd's algorithm is a
popular approach for finding a locally optimal solution. For 1-dimensional data, there are polynomial time
algorithms. The algorithm implemented here is aO(kn + n log n)dynamic programming algorithm for finding
the globally optimalkclusters forn1D data points.The code is written in C++, and wrapped with Python.Requirementskmeans1dsupports Python 3.x.Installationkmeans1dis available on PyPI, the Python Package Index.$pip3installkmeans1dExample Usageimportkmeans1dx=[4.0,4.1,4.2,-50,200.2,200.4,200.9,80,100,102]k=4clusters,centroids=kmeans1d.cluster(x,k)print(clusters)# [1, 1, 1, 0, 3, 3, 3, 2, 2, 2]print(centroids)# [-50.0, 4.1, 94.0, 200.5]TestsTests are intests/.# Run tests$python3-munittestdiscovertests-vLicenseThe code in this repository has anMIT License.SeeLICENSE.References[1] Wu, Xiaolin. "Optimal Quantization by Matrix Searching." Journal of Algorithms 12, no. 4
(December 1, 1991): 663[2] Gronlund, Allan, Kasper Green Larsen, Alexander Mathiasen, Jesper Sindahl Nielsen, Stefan Schneider,
and Mingzhou Song. "Fast Exact K-Means, k-Medians and Bregman Divergence Clustering in 1D."
ArXiv:1701.07204 [Cs], January 25, 2017.http://arxiv.org/abs/1701.07204.
Package: kMeansBCMAssessment-cwildenb
K means clustering is often used as an unsupervised data-analytics algorithm meant to find the ideal number of possible classes in a given dataset.This project implements a k-means clustering algorithm pipeline that takes in dataset file(s) such as the one found in the dataset folder and computes the best K for each dataset and outputs into another text file the file name followed by the estimated K for each one.Allowed only to use numpy package, all other packages are prohibited. Each line in the dataset file represent 1, n dimensional datapoint.
Package: k-means-constrained
k-means-constrainedK-means clustering implementation whereby a minimum and/or maximum size for each
cluster can be specified.This K-means implementation modifies the cluster assignment step (E in EM)
by formulating it as a Minimum Cost Flow (MCF) linear network
optimisation problem. This is then solved using a cost-scaling
push-relabel algorithm and usesGoogle's Operations Research tools'sSimpleMinCostFlowwhich is a fast C++ implementation.This package is inspired byBradley et al..
The original Minimum Cost Flow (MCF) network proposed by Bradley et al.
has been modified so maximum cluster sizes can also be specified along
with minimum cluster size.The code is based onscikit-lean'sKMeansand implements the sameAPI with modifications.Ref:Bradley, P. S., K. P. Bennett, and Ayhan Demiriz. "Constrained k-means clustering."
Microsoft Research, Redmond (2000): 1-8.Google's SimpleMinCostFlow C++ implementationInstallationYou can install the k-means-constrained from PyPI:pip install k-means-constrainedIt is supported on Python 3.8 and above.ExampleMore details can be found in theAPI documentation.>>>fromk_means_constrainedimportKMeansConstrained>>>importnumpyasnp>>>X=np.array([[1,2],[1,4],[1,0],...[4,2],[4,4],[4,0]])>>>clf=KMeansConstrained(...n_clusters=2,...size_min=2,...size_max=5,...random_state=0...)>>>clf.fit_predict(X)array([0,0,0,1,1,1],dtype=int32)>>>clf.cluster_centers_array([[1.,2.],[4.,2.]])>>>clf.labels_array([0,0,0,1,1,1],dtype=int32)
Package: kmeans-gpu
kmeans-gpukmeans-gpu with pytorch (batch version). It is faster than sklearn.cluster.KMeans.
What's more, it is a differential operation which will back-propagate gradient to previous layers.You can easily useKMeansas ann.Module, and embed into your network structure.InstallFrom Git:gitclonegit@github.com:densechen/kmeans-gpu.gitcdkmeans-gpu
pipinstall-rrequirements.txt
pythonsetup.pyinstall# check installationpython-c"import kmeans_gpu; print(kmeans_gpu.__version__)"From PyPI:pipinstallkmeans-gpu# check installationpython-c"import kmeans_gpu; print(kmeans_gpu.__version__)"Demofromkmeans_gpuimportKMeansimporttorch# Configbatch_size=128feature_dim=1024pts_dim=3num_pts=256num_cluster=15# Create datafeatures=torch.randn(batch_size,feature_dim,num_pts)# Pay attention to the different dimension order between features and points.points=torch.randn(batch_size,num_pts,pts_dim)# Create KMeans Modulekmeans=KMeans(n_clusters=num_cluster,max_iter=100,tolerance=1e-4,distance='euclidean',sub_sampling=None,max_neighbors=15,)# Forwardcentroids,features=kmeans(points,features)print(centroids.shape,features.shape)# output:# >>> torch.Size([128, 15, 3]) torch.Size([128, 1024, 15])
Package: k-means-plus-plus
K-means++ in Pandas===================An implementation of the [k-means++ clustering algorithm](http://en.wikipedia.org/wiki/K-means%2B%2B) using [Pandas](http://pandas.pydata.org/).IMPORTANT NOTE--------------**This package should not be used in production.** The implementation of k-means++ contained therein is much slower than [that of scikit-learn](http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html). Use that instead.The only reason why I wrote any of this is to teach myself Pandas.Prerequisites-------------* Python 2.7 or lower; this is not Python 3 compatible (yet).* [Pandas](http://pandas.pydata.org/) (obviously).* [NumPy](http://numpy.org)Installation------------If you have [pip](http://www.pip-installer.org/en/latest/installing.html), then just dopip install k-means-plus-plusOtherwise,* Clone the repository:git clone https://github.com/jackmaney/k-means-plus-plus-pandas.git* Enter the newly-created folder containing the repocd k-means-plus-plus-pandas* And run the installation manually:python setup.py installUsage-----Here are the constructor arguments:* `data_frame`: A Pandas data frame representing the data that you wish to cluster. Rows represent observations, and columns represent variables.* `k`: The number of clusters that you want.* `columns=None`: A list of column names upon which you wish to cluster your data. If this argument isn't provided, then all of the columns are selected. **Note:** Columns upon which you want to cluster must be numeric and have no `numpy.nan` values.* `max_iterations=None`: The maximum number of times that you wish to iterate k-means. If no value is provided, then the iterations continue until stability is reached (ie the cluster assignments don't change between one iteration and the next).* `appended_column_name=None`: If this value is set with a string, then a column will be appended to your data with the given name that contains the cluster assignments (which are integers from 0 to `k-1`). If this argument is not set, then you still have access to the clusters via the `clusters` attribute.Once you've constructed a `KMeansPlusPlus` object, then just call the `cluster` method, and everything else should happen automagically. Take a look at the `examples` folder.TODO:----* Add on features that take iterations of k-means++ clusters and compares them via, eg, concordance matrices, Jaccard indices, etc.* Given a data frame, implement the so-called [Elbow Method](http://en.wikipedia.org/wiki/Determining_the_number_of_clusters_in_a_data_set#The_Elbow_Method) to take a stab at an optimal value for `k`.* ~~Make this into a proper Python module that can be installed via pip.~~* Python 3 compatibility (probably via six).
Package: kmeans-pytorch
K Means using PyTorchPyTorch implementation of kmeans for utilizing GPUGetting Startedimport torch
import numpy as np
from kmeans_pytorch import kmeans

# data
data_size, dims, num_clusters = 1000, 2, 3
x = np.random.randn(data_size, dims) / 6
x = torch.from_numpy(x)

# kmeans
cluster_ids_x, cluster_centers = kmeans(
    X=x, num_clusters=num_clusters, distance='euclidean', device=torch.device('cuda:0')
)seeexample.ipynbfor a more elaborate exampleRequirementsPyTorchversion >= 1.0.0Python version >= 3.6Installationinstall withpip:pip install kmeans-pytorchInstalling from sourceTo install from source and develop locally:git clone https://github.com/subhadarship/kmeans_pytorch
cd kmeans_pytorch
pip install --editable .CPU vs GPUseecpu_vs_gpu.ipynbfor comparison between CPU and GPUNotesuseful when clustering large number of samplesutilizes GPU for faster matrix computationssupport euclidean and cosine distances (for now)
Package: kmeans-sam
k-means-samk-means sub-clustering and merging library for strong control and flexibility over k-means clusteringThe operations provided in k-means-sam are :Making k-means clustersQuerying clusters by idSub-clustering k-means clusters by specifying cluster idMerging k-means clusters by specifying cluster idsUSAGE -Import kmeans-samimport kmeans_sam.kmeans_sam as ksMaking clustersSteps -Create a k-means model and perform .fit() operationsCreate a kmeans-sam objectkmeans-sam.clusterize(model = kmeans_mode, dataframe = df, predictors = [column_names])Code:## Create data for clustering
X, _ = make_blobs(n_samples=10, centers=3, n_features=4)
df = pd.DataFrame(X, columns=['Feat_1', 'Feat_2', 'Feat_3', 'Feat_4'])
## Create KMeans model
kmeans = KMeans(n_clusters=3)
kmeans.fit(df[['Feat_1', 'Feat_2', 'Feat_3', 'Feat_4']])
## Create KMeansSam object
kmeans_sam = ks.KMeansSam()
## Create KMeansSam clusters. parameters : kmeans model, dataframe, list of column names
clusters = kmeans_sam.clusterize(kmeans, df, ['Feat_1', 'Feat_2', 'Feat_3', 'Feat_4'])
print(clusters)Querying cluster by idCode:## Fetched all the clusters with id
clusters = kmeans_sam.get_all_clusters()
print(kmeans_sam.get_cluster(2))Sub-clustering k-means clusters by specifying cluster idkmeans = KMeans(n_clusters=2)
kmeans.fit(df[['Feat_1', 'Feat_2', 'Feat_3', 'Feat_4']])
## parameters : kmeans model, cluster_id, list of column names
print(kmeans_sam.subclusterize(kmeans, 0, ['Feat_1', 'Feat_2', 'Feat_3', 'Feat_4']))Merging clusters by cluster_idsCode:print(kmeans_sam.merge_cluster([0, 2]))
Package: kmer-counter
kmer_counterCount kmers in regions or at SNVs or at indel breakpoints.Requirementskmer_counter requires Python 3.7 or above.InstallationWithpip:pipinstallkmer_counterWithpipx:pipxinstallkmer_counterUsageCounting k-mers at SNVsTo count the 3-mers at SNVs do:kmer_countersnv{genome}.2bit{snv_file}Where the{snv_file}should be a vcf-like text file where the first four columns are: Chromosome, Position, Ref_Allele, Alt_Allele. Fx:chr1  1000000  A G
chr1  1000200  G C
chr1  1000300  A T
chr1  1000500  C GComments or header lines starting with "#" are allowed and will be ignored and any additional columns are also allowed but ignored. So a vcf file is also a valid input file.
The Ref_Allele column should match the reference genome provided by the 2bit file. 2bit files can be downloaded from:https://hgdownload.cse.ucsc.edu/goldenpath/{genome}/bigZips/{genome}.2bitwhere{genome}is a valid UCSC genome assembly name (fx. "hg38").Counting k-mers in genomic regionsTo count all 5-mers in a bed file called {regions}.bed do:kmer_counter background --bed {regions}.bed -radius 2 {genome}.2bitBy default all k-mers where the middle base is not A or C will be reverse complemented before being counted. This behaviour can be changed using the "--reverse_complement_method".
If we instead wants to count 4-mers, we can use the "--before_after" option:kmer_counter background --bed {regions}.bed --before_after 2 1 {genome}.2bitWhen this option is used the default is not to reverse complement any of the k-mers but count all.Counting k-mers at indelsTo count one of the possible insertion breakpoint 4-mer for each insertion in a vcf-like file with variants do:kmer_counter indel -r 2 --sample {genome}.2bit {variants} insAnd for deletion start breakpoints:kmer_counter indel -r 2 --sample {genome}.2bit {variants} del_startThis will produce 2 counts for each deletion; one for the start breakpoint and one for the reverse complement at the k-mer at end breakpoint.
Package: kmergenetyper
kmergenetyper (k-mer gene typer)Installationkmergenetyper typer requires kma (>=1.4.0) to be installed and usable directly from path (i.e. $kma).
This can be done by installing kma from source or using conda:conda create -n kmergenetyper -f kmergenetyper.ymlconda activate kmergenetyperpip install kmergenetyperUsagekmergenetyper -h
Package: kmerpapa
kmerPaPaTool to calculate a "k-mer pattern partition" from position specific k-mer counts. This can for instance be used to train a mutation rate model.RequirementskmerPaPa requires Python 3.7 or above.InstallationkmerPaPa can be installed using pip:pip install kmerpapaor usingpipx:pipx install kmerpapaTest dataThe test data files used in the usage examples below can be downloaded from the test_data directory in the project's github repository:wget https://github.com/BesenbacherLab/kmerPaPa/raw/main/test_data/mutated_5mers.txt
wget https://github.com/BesenbacherLab/kmerPaPa/raw/main/test_data/background_5mers.txtUsageIf we want to train a mutation rate model then the input data should specifiy the number of times each k-mer is observed mutated and unmutated. One option is to have one file with the mutated k-mer counts (positive) and one file with the count of k-mers in the whole genome (background).  We can then run kmerpapa like this:kmerpapa --positive mutated_5mers.txt \
         --background background_5mers.txt \
         --penalty_values 3 5 7The above command will first use cross validation to find the best penalty value between the values 3,5 and 7. Then it will find the optimal k-mer patter partiton using that penalty value.
If both a list of penalty values and a list of pseudo-counts are specified then all combinations of values will be tested during cross validation:kmerpapa --positive mutated_5mers.txt \
         --background background_5mers.txt \
         --penalty_values 3 5 6 \
         --pseudo_counts 0.5 1 10If only a single combination of penalty_value and pseudo_count is provided then the default is not to run cross validation unless "--n_folds" option or the "CV_only" is used. The "CV_only" option can be used together with "--CVfile" option to parallelize grid search.
Fx. using bash:for c in 3 5 6; do
    for a in 0.5 1 10; do
        kmerpapa --positive mutated_5mers.txt \
         --background background_5mers.txt \
         --penalty_values $c \
         --pseudo_counts $a \
         --CV_only --CVfile CV_results_c${c}_a${a}.txt &
    done
doneCreating input dataInput files with k-mer counts can be created usingkmer_counter.
Given a file of point mutations in a file that contain the CHROM, POS, REF and ALT columns from a vcf file:chr1 1000000 G A
chr1 1000100 G A
chr1 1000200 C T
chr1 1000300 C T
chr1 1000400 C TWe can count the 5-mers around each mutation using this command:kmer_counter snv --radius 2 {genome}.2bit {point_mutations_file} > mutated_5mers.txtGiven a bed file with regions that are sufficiently covered by sequencing we can count the background 5-mers using this command:kmer_counter background --bed {regions}.bed -radius 2 {genome}.2bit > background_5mers.txtThe file{genome}.2bitshould be a 2bit file of the same reference genome that were used for calling the mutations. 2bit files can be downloaded from:https://hgdownload.cse.ucsc.edu/goldenpath/{genome}/bigZips/{genome}.2bitwhere{genome}is a valid UCSC genome assembly name (fx. "hg38").
Package: kmersfasta
Counting K-mers from the sequence in fasta formatUsage:import kmersfasta
kmersfasta.kmers_from_file('filename.fasta')where,filename.fastais the name of the file in fasta formatCounting K-mers from the sequence obtained from NCBI using accession numberUsage:import kmersfasta
kmersfasta.kmers_from_ncbi('email')where,emailis your email address and you also need to provide the NCBI ACCESSION number during the prompt
Package: kmeseg
KME Word SegmentationAI for tokenize chemical IUPAC name using tensorflow and keras.Prepare training datasetWhat to haveCHAR_INDICES: dictionary with key is character [string], value is number [int](use to preprocess text to number)Dict_cut: Input text with determined (by '|' ) where to be cut (use for create label)Cyclo|prop|ane| |Non|a|-|1|,|8|-|di|yne| 
|1|,|3|-|di|chlorocyclo|hex|ane| |Hept|a|-|1|,|5|-|di|eneDict: Input text (raw) (use for train model)Cyclopropane Nona-1,8-diyne 1,3-dichlorocyclohexane Hepta-1,5-dieneCreate datasetMake JSON value as array of chemical name (dataset, dataset_cut)Split array fortraining dataset (90%)(dataset_train, dataset_cut_train) andvalidation dataset (10%)(dataset_val, dataset_cut_val)Join item in each array together into textCreate dataset usingcreate_dataset functionthattake dataset_cutthen returnX_train(size: [text_length, look_back]) (dataset_cut that have been cut '|') andlabel(position where to cut 1 = cut, 0 = not cut)Use tf.data.Dataset.from_tensor_slices((X, y)).batch_size(128) to make data easy to be trainCreate ModelWe use 1xEmbeddinglayer, 1xBidirection LSTMlayer,DenseLayerCompiledmodel optimizer = Adam,loss_function = Categorical Crossentropy(becase we classify 2 label output 1 = cut, 0 = not cut)call_back = [EarlyStopping, ModelCheckpoint]Early stopping : Stop train model if validation_loss is being increaseModelCheckpoint : Save model that has minimum validation_lossAfter Train ModelThe output of the model is array (size: [batch_size, 2] determined which position to be cut (value = 0 -> not cut ; 1 -> cut))[1 1 1 1 1 0 1 1 0 0 0 0 1 1 1 1 1 0 0 0 1 0 1 0 0 0 1 0 0]Tokenize dataset (text whichdidn'tdetermined where to be cut) with label (output from model) usingword_tokenize functionthat returnarray of text that has been cut['1', ',', '2', '-', 'di', 'h', 'ydrox', 'y', '-', '2', '-', 'meth', 'yl', 'prop', 'ane']
Package: kmh-gpu-monitor
kairos-smiMulti-server gpu monitoring programSee change Log:change logusage: ksmi [-h] [-l] [-c CONFIG]

optional arguments:
  -h, --help            show this help message and exit
  -l, --loop            loop forever
  -c CONFIG, --config CONFIG
                        set config file locationquick start1. installInstall with pip$pipinstallksmi
or
$pip3installksmi2. Setup config fileEditconfig.json. Add your gpu server address inconfig.json.{"hosts":["<username>@<host>[:port]","<username>@<host>[:port]"]}3. Add rsa_id to servercreate new rea_id and add to your server$python3-mksmi.copy_id-cconfig.json-n4. Run It!$python3-mksmi-cconfig.json-lkairos-smiusage: kairos_smi.py [-h] [-l] [-c CONFIG]

optional arguments:
  -h, --help            show this help message and exit
  -l, --loop            loop forever
  -c CONFIG, --config CONFIG
                        set config file locationSimple usageRun once$ python3 -m ksmi -c config.jsonRun forever$ python3 -m ksmi -c config.json -lutilscopy_idusage: copy_id.py [-h] [-n] [-c CONFIG] [-s SERVER]

optional arguments:
  -h, --help            show this help message and exit
  -n, --new_id          generate new id_rsa key
  -c CONFIG, --config CONFIG
                        set config file to use host list
  -s SERVER, --server SERVER
                        set a server to copy idcopy id(rsa) to serverUse withconfig.json$ python3 -m ksmi.copy_id -c config.json
or
$ python3 -m ksmi.copy_id --config config.jsonUse with individual Server address$ python3 -m ksmi.copy_id -s [username@]<IP>[:port]
or
$ python3 -m ksmi.copy_id --server [username@]<IP>[:port]Make a new id_rsa$ python3 -m ksmi.copy_id -n
or
$ python3 -m ksmi.copy_id --new_id
Package: kmhook
kmHookkmHookonly works on Windows, is pure Python using onlyctypes,timeand no other dependencies.kmHookcurrently, only french AZERTY keyboards are supported.kmHookallows you to detect, synthesize keyboard & mouse events.kmHookalso implements various related functions, see below.Exampleimportkmhookaskmwhilenotkm.is_pressed('pause'):km.sleep(0.001)# recommended so that you don't consume CPUifkm.is_pressed_once('space'):km.continuous_relative_move(600,400,500)# moves mouse smoothly during 500msget_valid_key_names() -> tupleReturns all the valid key names to use within kmHookis_pressed(key: str | tuple[str] | list[str]) -> boolChecks if a key or a sequence of keys is being pressed.is_pressed_once(key: str | tuple[str] | list[str]) -> boolChecks if a key or a sequence of keys is being pressed but only once :
if the key was being pressed during the last call and is still being pressed,
this function returns False... until key is released and pressed again.press(key: str | list | tuple) -> NonePresses the key (a single str or a sequence of keys) but does not release itpress_and_release(key: str | list | tuple) -> NonePresses and releases the key or the sequence of keys.release(key: str | list | tuple) -> NoneReleases the key (a single str or a sequence of keys).get_key_name() -> strWaits for a key to be pressed and return its name.get_mouse_pos() -> tuple[int, int]Returns current mouseposition.move_mouse_absolute(x: float | int, y: float | int) -> NoneMoves mouse absolutely to coordinates (x,y).move_mouse_relative(x: float | int, y: float | int) -> NoneMoves mouse relatively to current position.continuous_relative_move(x: float | int, y: float | int, time_interval: float | int) -> NoneMoves mouse relatively, smoothly and continuously during time_interval. Is blocking.
Package: kml2geojson
kml2geojson is a Python 3.8+ package to convert KML files to GeoJSON files.
Most of its code is a translation into Python of the Node.js packagetogeojson, but kml2geojson also adds the following features.Preserve KML object styling, such as color and opacityOptionally create a style dictionary cataloging all the KML styles usedOptionally create several GeoJSON FeatureCollections, one for each KML folder presentInstallationCreate a Python 3.8+ virtual environment and runpoetry add kml2geojson.UsageUse as a library or from the command line.
For instructions on the latter, typek2g--help.DocumentationIn thedocsdirectory and published atmrcagney.github.io/kml2geojson_docs.NotesDevelopment status is Alpha.This project uses semantic versioning.Thanks toMRCagneyfor funding this project.AuthorsAlex Raichev (2015-10-03), maintainerContributingIf you want to help develop this project, here is some background reading.TheKML referencePython’sMinimal DOM implementation, which this project uses to parse KML filesChanges5.1.0, 2022-04-29Extendedconvert()to accept a KML file object.Added type hints.Updated dependencies and removed version caps.Dropped support for Python versions less than 3.8.Switched from Travis CI to Github Actions.5.0.1, 2021-10-11Re-included the MIT License file and added more metadata to the filepyproject.tomlfor a more informative listing on PyPi.5.0.0, 2021-10-07Upgraded to Python 3.9 and dropped support for Python versions < 3.6.Switched to Poetry.Breaking change: refactored theconvertfunction to return dictionaries instead of files.Moved docs from Rawgit to Github Pages.4.0.2, 2017-04-26Fixed the bug wheresetup.pycould not find the license file.4.0.1, 2017-04-22Moved the name of a FeatureCollection into a ‘name’ attribute, becauseRFC 7946 says that a GeoJSON FetaureCollection must not have a ‘properties’ attributeStripped leanding and trailing whitespace from text content to avoid cluttered or blank name and description attribute valuesSwitched to pytest for testing4.0.0, 2016-11-24Moved command line functionality to separate moduleRenamed some functions3.0.4, 2015-10-15Disambiguated filenames inmain().3.0.3, 2015-10-13Improvedto_filename()again.3.0.2, 2015-10-12Improvedto_filename()and removed the lowercasing.3.0.1, 2015-10-12Tweakedto_filename()to lowercase and underscore results.
Forgot to do that last time.3.0.0, 2015-10-12Changed the output ofbuild_layers()and moved layer names into the GeoJSON FeatureCollections2.0.2, 2015-10-12Replaced underscores with dashes in command line options2.0.1, 2015-10-12Set default border style for colored polygons2.0.0, 2015-10-08Added documentationTweaked the command line tool options1.0.0, 2015-10-05Changed some namesAdded lots of tests0.1.1, 2015-10-03Fixed packaging to findREADME.rst0.1.0, 2015-10-03First