Untitled

mail@pastecode.io avatar
unknown
python
a month ago
1.2 kB
3
Indexable
Never
import pandas as pd
import json

# Load the dataset
data = pd.read_csv('dataset/data.csv')

# Task 1.1: Determine the skewness of the Sweetness column
sweetness_skewness = data['Sweetness'].skew()

# Task 1.2: Determine the skewness of the Crunchiness column
crunchiness_skewness = data['Crunchiness'].skew()

# Task 1.3: Determine the Pearson correlation of Ripeness and Acidity columns
ripeness_acidity_corr = data['Ripeness'].corr(data['Acidity'])

# Task 1.4: Determine the Pearson correlation of quality and weight columns
quality_weight_corr = data['Quality'].corr(data['Weight'])

# Task 1.5: Determine the number of good and bad quality apples
threshold = 5
num_good_apple = data[data['Quality'] > threshold].shape[0]
num_bad_apple = data[data['Quality'] <= threshold].shape[0]

# Constructing the submission JSON
submission = {
    "1.1": round(sweetness_skewness, 4),
    "1.2": round(crunchiness_skewness, 4),
    "1.3": round(ripeness_acidity_corr, 4),
    "1.4": round(quality_weight_corr, 4),
    "1.5": [num_bad_apple, num_good_apple]
}

# Writing the JSON to a file
with open("submission.json", "w") as file:
    json.dump(submission, file, indent=4)

print("Submission file 'submission.json' created successfully.")
Leave a Comment