#!/usr/bin/env python # coding: utf-8 # # Welcome to Visual Python DEMO binder 🎉 # Get started using Visual Python by clicking the 🟧 **orange button** 🟧 on the right side! # ### Visual Python can "Import" libraries easily, # In[ ]: # Visual Python: Data Analysis > Import import numpy as np import pandas as pd import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') import seaborn as sns # ### Load sample data with several clicks, (using "File" app) # In[ ]: # Visual Python: Data Analysis > File data = pd.read_csv('https://raw.githubusercontent.com/visualpython/visualpython/main/visualpython/data/sample_csv/iris.csv') data # ### "Subset" the dataframe with mutiple conditions, # In[ ]: # Visual Python: Data Analysis > Subset data.loc[(data['variety'] == 'Setosa')&(data['sepal.length'] < 5), ['variety','sepal.length','petal.length']] # ### Draw a Plot with preview, (using "Seaborn" app) # In[ ]: # Visual Python: Visualization > Seaborn sns.lineplot(data=data) plt.show() # ### Split DataSet, # In[ ]: # Visual Python: Machine Learning > Data Split from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(data[['sepal.length', 'sepal.width', 'petal.length', 'petal.width']], data['variety']) # ### Fit and Predict using listed ML algorithms # In[ ]: # Visual Python: Machine Learning > Classifier from sklearn.ensemble import RandomForestClassifier model = RandomForestClassifier() # In[ ]: # Visual Python: Machine Learning > Fit/Predict model.fit(X_train, y_train) # In[ ]: # Visual Python: Machine Learning > Fit/Predict pred = model.predict(X_test) pred # In[ ]: # Visual Python: Machine Learning > Evaluation from sklearn import metrics # In[ ]: # Visual Python: Machine Learning > Evaluation from sklearn import metrics # In[ ]: # Visual Python: Machine Learning > Evaluation # Confusion Matrix pd.crosstab(y_test, pred, margins=True) # In[ ]: # Visual Python: Machine Learning > Evaluation # Classification report print(metrics.classification_report(y_test, pred)) # In[ ]: