<jupyter_start><jupyter_text>import libs<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plot
from google.colab import drive
from sklearn.model_selection import train_test_split 
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import r2_score
from sklearn import preprocessing
from sklearn.linear_model import Lasso<jupyter_output><empty_output><jupyter_text>import selected features from file<jupyter_code>drive.mount('/content/drive')
df = pd.read_csv('/content/drive/MyDrive/Stress Prediction M2/selected_features.csv')
df.drop(['dance', 'wealthy', 'fashion'], axis = 1, inplace=True)
df.head()<jupyter_output><empty_output><jupyter_text>normalize dataframe<jupyter_code># cols_to_norm =['help', 'pride', 'suffering', 'journalism','blue_collar_job','reading','anonymity','war','poor','pain']
# cols_to_norm =['pss_score']
# df[cols_to_norm] = df[cols_to_norm].apply(lambda x: (x - x.min()) / (x.max() - x.min()))
df.head()<jupyter_output><empty_output><jupyter_text>lasso regression<jupyter_code>y_data = df['pss_score']
x_data = df[['help', 'pride', 'suffering', 'journalism','blue_collar_job','reading','anonymity','war','poor','pain']]

x_train, x_test, y_train, y_test = train_test_split(x_data, y_data, test_size=0.10, random_state=1)<jupyter_output><empty_output><jupyter_text>testing & training<jupyter_code>def MAPE(Y_actual,Y_Predicted):
    mape = np.mean(np.abs((Y_actual - Y_Predicted)/Y_actual))*100
    return mape
lasso_model = Lasso(alpha=1.0, normalize=True)
# lasso_model = Lasso(alpha=1.0)
lasso=lasso_model.fit(x_train , y_train)
lasso_predict = lasso.predict(x_test)
Lasso_MAPE = MAPE(y_test,lasso_predict)
print("Mean Absolute Percentage Error value: ",Lasso_MAPE)
Accuracy = 100 - Lasso_MAPE
print('Accuracy of Lasso Regression: {:0.2f}%.'.format(Accuracy))
print(lasso_predict)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14116434827408553, 'fraction_numerical': 0.009788768675940238, 'mean_word_length': 9.114583333333334, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '215033', 'license': 'MIT', 'n_tokens_mistral': 750, 'n_tokens_neox': 718, 'n_words': 120, 'path': 'notebooks/Lasso Regression.ipynb', 'repo_name': 'fa-901/stress-prediction', 'size': '1941'}