-1

After I run my project these error shown and i don't know what am i doing?

:\Users\Alir\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\utils\extmath.py:1047: RuntimeWarning: invalid value encountered in divide
updated_mean = (last_sum + new_sum) / updated_sample_count C:\Users\Alir\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\utils\extmath.py:1052: RuntimeWarning: invalid value encountered in divide
T = new_sum / new_sample_count C:\Users\Alir\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\utils\extmath.py:1072: RuntimeWarning: invalid value encountered in divide new_unnormalized_variance -= correction**2 / new_sample_count

my code is:

df_final = pd.get_dummies(df, columns=feats, drop_first=True)
X = df_final.drop(['fraud_reported_Y', 'policy_csl',
              'policy_bind_date', 'incident_date'], axis=1).values
y = df_final['fraud_reported_Y'].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
print(X_train)
sc = StandardScaler()
X_train = sc.fit_transform(X_train)   # in this part I have Probleams`
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Jan 13 '23 at 10:33

1 Answers1

0

The cleaned code is presented to you my friend Just modify the address of the insurance_claims.csv file in line 8 of your computer For more information : https://numpy.org/doc/stable/reference/generated/numpy.seterr.html

keras.py

import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

# THE ANSWER #
np.seterr(divide='ignore', invalid='ignore')

# YOUR CODE #
df = pd.read_csv(r'/home/amin/Desktop/prog/test/insurance_claims.csv')
feats = ['policy_state', 'insured_sex', 'insured_education_level', 'insured_occupation', 'insured_hobbies', 'insured_relationship', 'collision_type', 'incident_severity',
         'authorities_contacted', 'incident_state', 'incident_city', 'incident_location', 'property_damage', 'police_report_available', 'auto_make', 'auto_model', 'fraud_reported', 'incident_type']
df_final = pd.get_dummies(df, columns=feats, drop_first=True)
X = df_final.drop(['fraud_reported_Y', 'policy_csl',
                  'policy_bind_date', 'incident_date'], axis=1).values
y = df_final['fraud_reported_Y'].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
print(X_train)
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
print("*"*50)
print(X_train)
Amin
  • 181
  • 2
  • 5