Skip to content

Instantly share code, notes, and snippets.


M Khorasani mkhorasani

View GitHub Profile
View mlaas_test
def download(df,filename): # Downloading DataFrame
csv = df.to_csv(index=False)
b64 = base64.b64encode(csv.encode()).decode()
href = (f'<a href="data:file/csv;base64,{b64}" download="%s.csv">Download csv file</a>' % (filename))
return href
st.sidebar.subheader('Test Dataset')
status_test, df_test = file_upload('Please upload a test dataset')
if status_test == True:
View mlaas_train_and_visualize
def confusion_matrix_plot(data):
z = data.tolist()[::-1]
x = ['Negative','Positive']
y = ['Positive','Negative']
z_text = z
fig = ff.create_annotated_heatmap(z, x, y, annotation_text=z_text, text=z,hoverinfo='text',colorscale='Blackbody')
fig.update_layout(font_family="IBM Plex Sans")
View mlaas_training
st.sidebar.subheader('Training Dataset')
status, df = file_upload('Please upload a training dataset')
if status == True:
col_names = list(df)
col1, col2, col3 = st.columns((3,3,2))
View mlaas_file_upload
def file_upload(name):
uploaded_file = st.sidebar.file_uploader('%s' % (name),key='%s' % (name),accept_multiple_files=False)
content = False
if uploaded_file is not None:
uploaded_df = pd.read_csv(uploaded_file)
content = True
return content, uploaded_df
View python_send_email
#Combining images
images = [ for x in ['line_chart.png','bar_chart.png','histogram.png']]
widths, heights = zip(*(i.size for i in images))
total_width = sum(widths)
max_height = max(heights)
combined_image ='RGBA', (total_width, max_height))
offset = 0
for im in images:
combined_image.paste(im, (offset,0))
View python_charts_email
df = pd.read_excel('C:/Users/.../Desktop/Exam_results.xlsx')
exam_averages = [int(df['Exam 1'].mean()), int(df['Exam 2'].mean()),
int(df['Exam 3'].mean()), int(df['Exam 4'].mean())]
exams = ['Exam 1', 'Exam 2', 'Exam 3', 'Exam 4']
for i in range(0,len(df)):
exam_results = [df.loc[i]['Exam 1'], df.loc[i]['Exam 2'], df.loc[i]['Exam 3'], df.loc[i]['Exam 4']]
View python_parse_email
for email_id in data[0].split():
_,data = mail.fetch(email_id, '(RFC822)' )
raw_email = data[0][1]
raw_email = raw_email.decode('utf-8')
email_content = email.message_from_string(raw_email)
if 'Exam Results' in email_content['Subject']: #Change this line to the subject you are searching for
for part in email_content.walk():
if part.get_content_maintype() == 'multipart':
View python_receive_email
import imaplib
import base64
import os
import email
import pandas as pd
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import as px
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
View maxon_test
if __name__ == "__main__":
# Initiating connection and setting motion profile
keyHandle = epos.VCS_OpenDevice(b'EPOS2', b'MAXON SERIAL V2', b'USB', b'USB0', byref(pErrorCode)) # specify EPOS version and interface
epos.VCS_SetProtocolStackSettings(keyHandle, baudrate, timeout, byref(pErrorCode)) # set baudrate
epos.VCS_ClearFault(keyHandle, nodeID, byref(pErrorCode)) # clear all faults
epos.VCS_ActivateProfilePositionMode(keyHandle, nodeID, byref(pErrorCode)) # activate profile position mode
epos.VCS_SetEnableState(keyHandle, nodeID, byref(pErrorCode)) # enable device
epos.VCS_SetPositionProfile(keyHandle, nodeID, 5000, 30000, 30000, byref(pErrorCode)) # set profile parameters
epos.VCS_MoveToPosition(keyHandle, nodeID, 100000, True, True, byref(pErrorCode)) # move to position
View maxon_python_windows_64_example
import serial
import time
from ctypes import *
# EPOS Command Library path
# Load library
epos = CDLL(path)