I am facing a little problem while calling a variable from a different file. I
have two different files train_dataset.py
and test_dataset.py
. I run the
train_dataset.py
file from my IDE and note the value of the array variable
array_val
as given below.
array([[ 0.08695652, 0.66459627, 0.08695652, 0.07453416, 0.07453416,
... 0.15217391]])
Now I switch on to test_dataset.py
and import import train_dataset
and print
the value of array_val
by calling train_dataset.array_val
, I see a very
different output. The output is given below.
array([[ 8.11594203e-01, 1.15942029e-01, 4.05797101e-01,
... 1.30434783e-01, 5.65217391e-01, 2.02898551e-01]])
Please suggest how do I get rid of it and state the reason of the discrepancy.
Please find the code that I have embedded in my train_dataset.py
no_of_clusters=9
cluster_centroids=[]
k_means=KMeans(n_clusters=no_of_clusters,n_init=14, max_iter=400)
k_means.fit(matrix_for_cluster)
labels=k_means.labels_
array_val=k_means.cluster_centers_
i.e matrix_for_cluster
is a numpy n-dimensional array.
In my test_dataset.py
all I do is
import train_dataset
print train_dataset.array_val