| import pandas as pd | |
| def detect_target_type(y): | |
| if y.dtype == "object" or y.dtype.name == "category": | |
| return "Classification" | |
| if y.nunique() <= 20: | |
| return "Classification" | |
| return "Regression" | |
| def auto_set_task(file): | |
| if file is None: | |
| return "Regression" | |
| df = pd.read_csv(file.name) | |
| y = df.iloc[:, -1] | |
| return detect_target_type(y) | |