I have been trying to learn Python, specifically with respect to applying K-Means Analysis to my data. I found the following tutorial and copied the code into Jupyter notebook to run it.
K-Means Clustering with scikit-learn
I received three different errors, one of which I resolved (changed “size” to the revised term “height” in the code.
The first warning was returned for two instances of the following code, one for a training set and the second for a test set.
# Fill missing values with mean column values in the train set
train.fillna(train.mean(), inplace=True)
FutureWarning: Dropping of nuisance columns in DataFrame reductions (with ‘numeric_only=None’) is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
train.fillna(train.mean(), inplace=True)
The second was for multiple instances of slight variants of the following code:
KMeans(algorithm=‘auto’, copy_x=True, init=‘k-means++’, max_iter=600,
n_clusters=2, n_init=10, n_jobs=1, precompute_distances=‘auto’,
random_state=None, tol=0.0001, verbose=0)
TypeError: init() got an unexpected keyword argument ‘n_jobs’
I don’t know how to fix the incorrect code, which, I assume, was correct when the tutorial was written.
My question is this, is it worth learning Python if code is going to become obsolete, with code no longer running over, in this case, four years?