<jupyter_start><jupyter_text>BOWLER<jupyter_code>#process similar to batsman carried out for bowler
spark = SparkSession.builder.appName('bowler-clustering').getOrCreate()
data_bwl = spark.read.csv('stats_clean_bowler.csv', header=True, inferSchema=True)
data_bwl.show()
cols_bwl = list(data_bwl.columns)[2:]

assembler_bwl = VectorAssembler(inputCols=cols_bwl, outputCol='features')
assembled_data_bwl = assembler_bwl.transform(data_bwl)
scaler_bwl = StandardScaler(inputCol='features', outputCol='scaledFeatures')
scaler_model_bwl = scaler_bwl.fit(assembled_data_bwl)
scaled_data_bwl = scaler_model_bwl.transform(assembled_data_bwl)
k_means = KMeans(featuresCol='scaledFeatures', k=5).setSeed(1)
model = k_means.fit(scaled_data_bwl)

temp = model.transform(scaled_data_bwl)
temp.write.mode('overwrite').format('parquet').save('bowler_cluster')
k=sqlContext.read.format('parquet').load('bowler_cluster')
k.show()
k.groupBy('prediction').avg('bowl_ave','econ','bowl_sr','balls').collect()
k.groupBy('prediction').count().collect()
pd.DataFrame(k.groupBy('prediction').avg('bowl_ave','econ','bowl_sr','balls').collect(),columns=['prediction','bowl_ave','econ','bowl_sr','balls']).to_csv('bowler_cluster_info.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16586151368760063, 'fraction_numerical': 0.0024154589371980675, 'mean_word_length': 12.811111111111112, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '463595', 'license': 'MIT', 'n_tokens_mistral': 476, 'n_tokens_neox': 463, 'n_words': 42, 'path': 'clustering.ipynb', 'repo_name': 'rahul-shiv/BD-2018', 'size': '1242'}