Skip to content

Instantly share code, notes, and snippets.

View mkhorasani's full-sized avatar

Mohammad Khorasani mkhorasani

View GitHub Profile
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:
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")
st.write(fig)
st.sidebar.subheader('Training Dataset')
status, df = file_upload('Please upload a training dataset')
if status == True:
col_names = list(df)
st.title('Training')
st.subheader('Parameters')
col1, col2, col3 = st.columns((3,3,2))
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:
try:
uploaded_df = pd.read_csv(uploaded_file)
content = True
return content, uploaded_df
except:
try:
#Combining images
images = [Image.open(x) 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 = Image.new('RGBA', (total_width, max_height))
offset = 0
for im in images:
combined_image.paste(im, (offset,0))
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']]
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':
continue
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 plotly.express as px
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
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
import serial
import time
from ctypes import *
# EPOS Command Library path
path='.\EposCmd64.dll'
# Load library
cdll.LoadLibrary(path)
epos = CDLL(path)