2022-12-07 21:26:35 +01:00
|
|
|
# ---
|
|
|
|
# jupyter:
|
|
|
|
# jupytext:
|
|
|
|
# text_representation:
|
|
|
|
# extension: .py
|
|
|
|
# format_name: percent
|
|
|
|
# format_version: '1.3'
|
|
|
|
# jupytext_version: 1.13.0
|
|
|
|
# kernelspec:
|
|
|
|
# display_name: Python 3.10.8 ('straw2analysis')
|
|
|
|
# language: python
|
|
|
|
# name: python3
|
|
|
|
# ---
|
|
|
|
|
|
|
|
# %%
|
|
|
|
# %matplotlib inline
|
|
|
|
import datetime
|
|
|
|
import importlib
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import pandas as pd
|
|
|
|
import seaborn as sns
|
|
|
|
import yaml
|
|
|
|
from pyprojroot import here
|
|
|
|
from sklearn import linear_model, svm, kernel_ridge, gaussian_process
|
|
|
|
from sklearn.model_selection import LeaveOneGroupOut, LeavePGroupsOut, cross_val_score, cross_validate
|
|
|
|
from sklearn.metrics import mean_squared_error, r2_score
|
|
|
|
from sklearn.impute import SimpleImputer
|
|
|
|
from sklearn.dummy import DummyRegressor
|
|
|
|
import xgboost as xg
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
nb_dir = os.path.split(os.getcwd())[0]
|
|
|
|
if nb_dir not in sys.path:
|
|
|
|
sys.path.append(nb_dir)
|
|
|
|
|
|
|
|
import machine_learning.features_sensor
|
|
|
|
import machine_learning.labels
|
|
|
|
import machine_learning.model
|
|
|
|
import machine_learning.helper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# %% tags=["active-ipynb"]
|
|
|
|
# filename = Path("E:/STRAWresults/inputData/stressfulness_event/input_appraisal_stressfulness_event_mean.csv")
|
2022-12-09 13:44:20 +01:00
|
|
|
# filename = Path('C:/Users/Primoz/VSCodeProjects/straw2analysis/data/stressfulness_event/input_appraisal_stressfulness_event_mean.csv')
|
2022-12-07 21:26:35 +01:00
|
|
|
|
|
|
|
# %%
|
|
|
|
final_scores = machine_learning.helper.run_all_regression_models(filename)
|
|
|
|
|
|
|
|
# %%
|
|
|
|
final_scores.index.name = "metric"
|
|
|
|
final_scores = final_scores.set_index(["method", final_scores.index])
|
|
|
|
|
|
|
|
# %%
|
|
|
|
final_scores.to_csv("event_stressfulness_scores.csv")
|