Question: Can anyone help me with this code? I'm trying to build a persnality detection model that works in parallel but I'm keep getting thus error

![thus error [89] " Logistic Regression has n jobs start_timel = tine,tine(](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66efb2ae90c50_87866efb2ae2edbf.jpg)

![LR_time- time,time( ) [90] LR_pred = logreg.predict (Xtest ) print (classification_report (ytest;](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66efb2afc31b0_87966efb2af600bc.jpg)
[89] " Logistic Regression has n jobs start_timel = tine,tine( ) logreg = Logistichegression (njobs=1) logreg, f it (X train, y_train ) LR_time- time,time( ) [90] LR_pred = logreg.predict (Xtest ) print (classification_report (ytest; LR _pred )) report - classification_report (ytest, LR_pred, output_dict-True) Wy [91] totallime - LR_time-start_timel print("tinet 8.2t seconds" 8 (totalTime)) MinuteTinez (totalTine//60) print("tine: K.2f ininutes" x (Minutetine)) time: 23.33 seconds time: 0,00 minutes Parallelize Model Predictions - Singular Model [94] def predict(data, feature_cols, clf, pred_col)= This function will generate predictions given a dataset, the associated features and a model. def predict(data, feature_cols, clf, pred_col): This function wil1 generate predictions given a dataset, the associated features and a model. params: data (DataFrame) : The dataset which holds the features feature_cols (List String) : List of column names in data corresponding to the model features clf (Model) : The classification model which generates the predictions pred_col (String) : The name of the column you want to store the predictions under in data return: This function will add a column to the input dataset associated to the predictions generated exarple: >> predict( data =df, feature_col = 1ang.features, pred_col = "lang_prediction" [95] B8stime \# normal predictions res = predict( data = new_df, feature_cols = "posts" clf = logreg, pred_col = 'rf_P_prediction' ) mprint (res) CPU times: user 4.46s, sys: 29.5ms, total: 4+48s Hall time: 4.57s [96] new df redict in Parallel from multiprocessing Liport: Pool from multiprocessing inport cpu_count from functools Import partial def parallel_pred(fn, data, feature_cols, clf, pred_col, n_cores): This function will parallelize the prediction process such that the data 15 split into in conponents (a is defined based on n_cores) and passed onto the nodel. parans 1 fn (function) I The function you want to parallelize data (Datafrane) I The dataset holding the features for the nodel feature_cols (List string) I List of colunn names in data corresponding to the nodel features clf. (Hodel) : The nodel which generates the predictions pred_col (String) : The nate of the colun you want to store the predictions under in data n_cores (Integer) : The nuaber of cores you want to use. noturns: This function will return the result of the input function example: parallel pred\} fn = predict, data =d, feature_cols = lang_features, clf a lang_adl, pred_col - "parallel_lang_pred", n_cores - 4 ) If cpu_count()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
