could not convert string to float from pandas dataframe

why cant i convert this to float df_tmp[‘rain_1h’] = df_tmp[‘rain_1h’].replace({‘zero’: ‘0’, }, regex=True) df_tmp[‘rain_1h’] = df_tmp[‘rain_1h’].replace({"mm": ""}, regex=True) df_tmp[‘rain_1h’] = df_tmp[‘rain_1h’].replace({" ": ""}, regex=True) df_tmp[‘rain_1h’] = df_tmp[‘rain_1h’].str.strip().astype(float) ValueError: could not convert string to float: ” i already tried to delete the space manually, still error >Solution : In case of conversion and there are empty… Read More could not convert string to float from pandas dataframe

Different values of accuracy in model.fit and model.evaluate on the same generator

I obtain a different accuracy on the same generator by using the model.fit and model.evaluate in tensorflow. This is my sample code import tensorflow as tf from nChannelGenerator import nChannelGenerator from databaseSplitter import automaticPath from keras.preprocessing.image import ImageDataGenerator nClasses = 5 height = 200 width = 200 batch_size = 32 model_1 = tf.keras.Sequential([ tf.keras.layers.Rescaling(scale =… Read More Different values of accuracy in model.fit and model.evaluate on the same generator

Splitting the elements of a list by some separator in the same list

I have an array: array([nan, ‘Stressful day’, ‘Drank coffee:Drank tea’, ‘Drank tea’, ‘Ate late:Drank coffee’, ‘Drank coffee:Drank tea:Worked out’, ‘Drank tea:Worked out’, ‘Drank coffee:Drank tea:Stressful day’, ‘Drank coffee’, ‘Drank coffee:Drank tea:Stressful day:Worked out’, ‘Drank coffee:Worked out’, ‘Ate late:Drank coffee:Drank tea’, ‘Ate late:Drank coffee:Drank tea:Worked out’, ‘Drank tea:Stressful day’, ‘Drank tea:Stressful day:Worked out’, ‘Drank coffee:Stressful day:Worked… Read More Splitting the elements of a list by some separator in the same list

How to modify loop builing ML models and generated DataFrame with column presented variable removed in each iteration of for-loop in Python?

I have Pandas DataFrame like below: Input data: Y – binnary target X1…X5 – predictors Source code of DataFrame: import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.metrics import roc_curve, roc_auc_score from sklearn.metrics import accuracy_score from sklearn.metrics import recall_score from sklearn.metrics import precision_score from sklearn.metrics import roc_auc_score from sklearn import… Read More How to modify loop builing ML models and generated DataFrame with column presented variable removed in each iteration of for-loop in Python?

Im trying to read a saved pickled models that are saved in a folder, I'm looping through the folder but I keep getting an error

p="/Users/rama/Desktop/lowermodels" lowerCount=0 for i in range(19): lowermodel[i]= pickle.load(open(‘/Users/rama/Desktop/lowermodels{lowerCount}.sav’, ‘rb’)) lowerCount= lowerCount+1 >Solution : Looks like you forgot to put an f infront of your f-string p="/Users/rama/Desktop/lowermodels" lowerCount=0 for i in range(19): lowermodel[i]= pickle.load(open(f’/Users/rama/Desktop/lowermodels{lowerCount}.sav’, ‘rb’)) lowerCount= lowerCount+1

GridSearchCV for estimating optimal tuning parameter

I am facing key error : 0 as a problem in these codes of lines grid.cv_results_[0].parameters print(grid.cv_results_[0].cv_validation_scores) print(grid.cv_results_[0].mean_validation_scores) >Solution : GridSearchCV’s cv_results_ returns a dictionary. Therefore you can’t access it via index. For example: svc = svm.SVC() grid = GridSearchCV(svc, parameters) grid.fit(data, target) print(grid.cv_results_.keys()) Output will be: [‘mean_fit_time’, ‘mean_score_time’, ‘mean_test_score’,… ‘param_C’, ‘param_kernel’, ‘params’,… ‘rank_test_score’, ‘split0_test_score’,…… Read More GridSearchCV for estimating optimal tuning parameter

can someone explain to me why the value of split is false in the test set?

can someone explain to me why the value of split is false in the test set? split = sample.split(dataset$Salary, SplitRatio = 2/3) training_set = subset(dataset, split == TRUE) test_set = subset(dataset, split == FALSE) >Solution : I assume you got this code from some kind of caTools documentation? I recommend trying to run the first… Read More can someone explain to me why the value of split is false in the test set?