Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How python uses Evidently to create machine learning model dashboards

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how python uses Evidently to create a machine learning model dashboard". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how python uses Evidently to create a machine learning model dashboard".

Explaining machine learning models is a difficult process because most models are usually a black box and we don't know what's going on inside the model. Creating different types of visualization helps to understand how the model is executed, but there are few libraries that can be used to explain how the model works.

Evidently is an open source Python library for creating interactive visual reports, dashboards, and JSON configuration files to help analyze machine learning models during validation and prediction. It can create six different types of reports related to data drift, classification, or regression model performance.

1. Install the package

Install using pip package manager, run

$pip install evidently

This tool allows interactive reports to be built in Jupyter notebook as well as as separate HTML files. If you only want to generate interactive reports as HTML files or export them as JSON configuration files, the installation is now complete.

To be able to build interactive reports in Jupyter notebook, we use Jupyter nbextension. If you want to create a report in Jupyter notebook, you should run the following two commands in terminal after installation.

To install jupyter Nbextion, run:

$jupyter nbextension install-sys-prefix-symlink-overwrite-py evidently

Running

Jupyter nbextension enable evidently-py-sys-prefix

One thing to note: a single run after installation is sufficient. You don't have to repeat the last two commands every time.

2. Import the required libraries

In this step, we will import the libraries needed to create the ML model. We will also import the library used to create a dashboard for analyzing model performance. In addition, we will import pandas to load the dataset.

Import pandas as pdimport numpy as npfrom sklearn.ensemble import RandomForestRegressorfrom evidently.dashboard import Dashboardfrom evidently.tabs import RegressionPerformanceTabfrom evidently.model_profile import Profilefrom evidently.profile_sections import RegressionPerformanceProfileSection3, loading dataset

In this step, we will load the data and separate it into reference data and forecast data.

Raw_data = pd.read_csv ('/ content/day.csv', header = 0, sep =',', parse_dates= ['dteday']) ref_data = raw_data [: 120] prod_data = raw_data [120 sep 150] ref_data.head ()

4. Create a model

In this step, we will create a machine learning model, and for this particular data set, we will use a random forest regression model.

Target = 'cnt'datetime =' dteday'numerical_features = ['mnth',' temp', 'atemp',' hum', 'windspeed'] categorical_features = [' season', 'holiday',' weekday', 'workingday',' weathersit',] features = numerical_features + categorical_featuresmodel = RandomForestRegressor (random_state = 0) model.fit Ref_ data [target]) ref_data ['prediction'] = model.predict (ref_ data [features]) prod_data [' prediction'] = model.predict (prod_ data [features]) 5, create a dashboard

In this step, we will create a dashboard to interpret the performance of the model and analyze the different properties of the model, such as MAE, MAPE, error distribution, and so on.

Column_mapping= {} column_mapping ['target'] = targetcolumn_mapping [' prediction'] = 'prediction'column_mapping [' datetime'] = datetimecolumn_mapping ['numerical_features'] = numerical_featurescolumn_mapping [' categorical_features'] = categorical_featuresdashboard = Dashboard (tabs= [RegressionPerformance Tab]) dashboard. Steps (ref_data, prod_data, column_mapping=column_mapping) dashboard.save ('bike_sharing_demand_model_perfomance.html')

In the figure above, you can clearly see the report showing the performance of the model, and you can use the above code to download and create the HTML report.

6. Available report type 1) data drift

Detect changes in feature distribution

2) numerical target drift

Detect changes in numerical targets and feature behavior.

3) Classification target drift

Detect changes in classification targets and feature behavior

4) performance of regression model

Analyze the performance and model error of regression model

5) performance of classification model

Analyze the performance and errors of the classification model. Suitable for binary and multi-class models

6) performance of probabilistic classification model

The performance of probabilistic classification model, the quality of model calibration and model errors are analyzed. It is suitable for binary and multi-class models.

Thank you for your reading, the above is the content of "how python uses Evidently to create machine learning model dashboard". After the study of this article, I believe you have a deeper understanding of how python uses Evidently to create machine learning model dashboard, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report