Created
May 23, 2020 15:28
-
-
Save pierrelouisbescond/525b250eb5ba045805a66824ff5b9619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# We start with the import of standard ML librairies | |
import pandas as pd | |
import numpy as np | |
import math | |
from sklearn.datasets import make_regression | |
from sklearn.ensemble import RandomForestRegressor | |
# We add all Plotly and Dash necessary librairies | |
import plotly.graph_objects as go | |
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
import dash_daq as daq | |
from dash.dependencies import Input, Output | |
# We start by creating a virtual regression use-case | |
X, y = make_regression(n_samples=1000, n_features=8, n_informative=5, random_state=22) | |
# We rename columns as industrial parameters | |
col_names = ["Temperature","Viscosity","Pressure", "pH","Inlet_flow", "Rotating_Speed","Particles_size","Color_density"] | |
df = pd.DataFrame(X, columns=col_names) | |
# We change the most important features ranges to make them look like actual figures | |
df["pH"]=6.5+df["pH"]/4 | |
df["Pressure"]=10+df["Pressure"] | |
df["Temperature"]=20+df["Temperature"] | |
df["Y"] = 90+y/20 | |
# We train a simple RF model | |
model = RandomForestRegressor() | |
model.fit(df.drop("Y", axis=1), df["Y"]) | |
# We create a DataFrame to store the features' importance and their corresponding label | |
df_feature_importances = pd.DataFrame(model.feature_importances_*100,columns=["Importance"],index=col_names) | |
df_feature_importances = df_feature_importances.sort_values("Importance", ascending=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment