Hướng dẫn email data cleaning python - python dọn dẹp dữ liệu email

1

Nội dung chính ShowShow

  • Làm thế nào để bạn làm sạch dữ liệu trong Python?
  • Pandas có tốt cho việc làm sạch dữ liệu không?
  • Tại sao chúng ta làm sạch dữ liệu trong Python?
  • Làm sạch và chuẩn bị dữ liệu trong Python là gì?

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

# 2. Nhập thư viện và mô -đun

Nhập khẩu Asnpnumpy asnpnumpy asnp

IMPREPPANDAS ASPDpandas aspdpandas aspd

Fromsklearn.model_selection Nhập khẩuTrain_Test_Splitsklearn.model_selection importtrain_test_splitsklearn.model_selection importtrain_test_split

FromskLearn Nhập trísklearn importpreprocessingsklearn importpreprocessing

Fromsklearn.Ensemble ImprTrandomforestreatoryorsklearn.ensemble importRandomForestRegressorsklearn.ensemble importRandomForestRegressor

Fromsklearn.Pipeline Nhập trí_pipelinesklearn.pipeline importmake_pipelinesklearn.pipeline importmake_pipeline

Fromsklearn.model_selection Nhập trí nghiên cứusklearn.model_selection importGridSearchCVsklearn.model_selection importGridSearchCV

Fromsklearn.Metrics nhập khẩusklearn.metrics importmean_squared_error,r2_scoresklearn.metrics importmean_squared_error,r2_score

Nhập khẩuJOblibjoblibjoblib

# 3. Tải dữ liệu rượu vang đỏ.

dataset_url='https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv'='https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv'='https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv'

data=pd.read_csv(dataset_url,sep=';')=pd.read_csv(dataset_url,sep=';')=pd.read_csv(dataset_url,sep=';')

# 4. Chia dữ liệu thành các bộ đào tạo và kiểm tra

y=data.quality=data.quality=data.quality

X=data.drop('quality',axis=1)=data.drop('quality',axis=1)=data.drop('quality',axis=1)

X_train,X_test,y_train,y_test=train_test_split(X,y,,X_test,y_train,y_test=train_test_split(X,y,,X_test,y_train,y_test= train_test_split(X,y,

                                                    test_size=0.2,test_size=0.2,test_size=0.2,

                                                    random_state=123,random_state=123,random_state=123,

                                                    stratify=y)stratify=y)stratify=y)

# 5. Khai báo các bước tiền xử lý dữ liệu

pipeline=make_pipeline(preprocessing.StandardScaler(),=make_pipeline(preprocessing.StandardScaler(),=make_pipeline(preprocessing.StandardScaler(),

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; RandomForestRestyor (n_estimators = 100,RandomForestRegressor(n_estimators=100,RandomForestRegressor(n_estimators=100,

& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; Random_state = 123))random_state=123))random_state=123))

# 6. Tuyên bố Hyperparameter để điều chỉnh

hyperparameters={'randomforestregressor__max_features':['auto','sqrt','log2'],={'randomforestregressor__max_features':['auto','sqrt','log2'],={'randomforestregressor__max_features':['auto','sqrt','log2'],

                  'randomforestregressor__max_depth':[None,5,3,1]}'randomforestregressor__max_depth':[None,5,3,1]}'randomforestregressor__max_depth':[None,5,3,1]}

# 7. Mô hình điều chỉnh bằng đường ống xác thực chéo

clf=GridSearchCV(pipeline,hyperparameters,cv=10)=GridSearchCV(pipeline,hyperparameters,cv=10)=GridSearchCV(pipeline,hyperparameters,cv=10)

clf.fit(X_train,y_train).fit(X_train,y_train).fit(X_train,y_train)

# 8. Tái trang bị trên toàn bộ bộ đào tạo

# Không cần mã bổ sung nếu clf.refit == true (mặc định là đúng)

# 9. Đánh giá đường ống mô hình trên dữ liệu kiểm tra

pred=clf.predict(X_test)=clf.predict(X_test)=clf.predict(X_test)

print(r2_score(y_test,pred))(r2_score(y_test,pred))(r2_score(y_test,pred))

print(mean_squared_error(y_test,pred))(mean_squared_error(y_test,pred))(mean_squared_error(y_test,pred))

# 10. Lưu mô hình cho sử dụng trong tương lai

joblib.dump(clf,'rf_regressor.pkl').dump(clf,'rf_regressor.pkl').dump(clf,'rf_regressor.pkl')

# To Load: clf2 = joblib.load ('rf_reforyor.pkl'))

Làm thế nào để bạn làm sạch dữ liệu trong Python?

Nhập thư viện ..

Đầu vào Bộ dữ liệu phản hồi của khách hàng ..

Xác định vị trí dữ liệu bị thiếu ..

Kiểm tra các bản sao ..

Phát hiện các ngoại lệ ..

Bình thường hóa vỏ ..

Pandas có tốt cho việc làm sạch dữ liệu không?

Pandas cung cấp một loạt các chức năng tích hợp có thể được sử dụng để làm sạch và thao tác các bộ dữ liệu trước khi phân tích.Nó có thể cho phép bạn thả các hàng và cột không đầy đủ, điền vào các giá trị bị thiếu và cải thiện khả năng đọc của bộ dữ liệu thông qua đổi tên danh mục.. It can allow you to drop incomplete rows and columns, fill missing values and improve the readability of the dataset through category renaming.. It can allow you to drop incomplete rows and columns, fill missing values and improve the readability of the dataset through category renaming.

Tại sao chúng ta làm sạch dữ liệu trong Python?

Làm sạch dữ liệu hoặc làm sạch là quá trình phát hiện và sửa chữa (hoặc loại bỏ) các bản ghi tham nhũng hoặc không chính xác khỏi tập hợp bản ghi, bảng hoặc cơ sở dữ liệu và đề cập đến việc xác định các phần không đầy đủ, không chính xác hoặc không liên quan của dữ liệu và sau đó thay thế, sửa đổi hoặcXóa dữ liệu bẩn hoặc thô.detecting and correcting (or removing) corrupt or inaccurate records from a record set, table, or database and refers to identifying incomplete, incorrect, inaccurate or irrelevant parts of the data and then replacing, modifying, or deleting the dirty or coarse data.detecting and correcting (or removing) corrupt or inaccurate records from a record set, table, or database and refers to identifying incomplete, incorrect, inaccurate or irrelevant parts of the data and then replacing, modifying, or deleting the dirty or coarse data.

Làm sạch và chuẩn bị dữ liệu trong Python là gì?

Bạn sẽ học cách làm việc với dữ liệu bị thiếu, cách làm việc với dữ liệu trùng lặp và xử lý dữ liệu chuỗi lộn xộn.Có thể làm sạch hiệu quả và chuẩn bị một bộ dữ liệu là một kỹ năng quan trọng.Nhiều nhà khoa học dữ liệu ước tính rằng họ dành 80% thời gian để dọn dẹp và chuẩn bị bộ dữ liệu của họ.learn how to work with missing data, how to work with duplicate data, and dealing with messy string data. Being able to effectively clean and prepare a dataset is an important skill. Many data scientists estimate that they spend 80% of their time cleaning and preparing their datasets.learn how to work with missing data, how to work with duplicate data, and dealing with messy string data. Being able to effectively clean and prepare a dataset is an important skill. Many data scientists estimate that they spend 80% of their time cleaning and preparing their datasets.