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
| def save_files(): | |
| gauth = GoogleAuth() | |
| create_cred_file() | |
| gauth.LoadCredentialsFile('mycreds.txt') | |
| drive = GoogleDrive(gauth) | |
| folder_name = 'test' # Please set the folder name. | |
| folders = drive.ListFile( | |
| { |
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
| def create_cred_file(): | |
| cred_str = '{"access_token": "' + st.secrets["access_token"] +\ | |
| '", "client_id": "' + st.secrets["client_id"] +\ | |
| '", "client_secret": "' + st.secrets["client_secret"] + \ | |
| '", "refresh_token": "' + st.secrets["refresh_token"] + \ | |
| '", "token_expiry": "' + st.secrets["token_expiry"] + \ | |
| '", "token_uri": "' + st.secrets["token_uri"] + \ | |
| '", "user_agent": null' + \ | |
| ', "revoke_uri": "' + st.secrets["revoke_uri"] + \ | |
| '", "id_token": null' + \ |
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
| import streamlit as st | |
| from utils import * | |
| st.title("CSV İşleme Uygulaması") | |
| uploaded_files = st.file_uploader("CSV Dosyasını Seçiniz", type="csv") | |
| if st.button("Dosyayı Yükle ve Analiz Et"): | |
| create_user_log_file() | |
| if uploaded_files: | |
| save_to_log('INFO', 'Dosya yükleme işlemi başlatıldı.') |
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
| import streamlit as st | |
| from utils import * | |
| st.title("CSV İşleme Uygulaması") | |
| uploaded_files = st.file_uploader("CSV Dosyasını Seçiniz", type="csv") | |
| if st.button("Dosyayı Yükle ve Analiz Et"): | |
| create_user_log_file() | |
| if uploaded_files: | |
| save_to_log('INFO', 'Dosya yükleme işlemi başlatıldı.') |
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
| from datetime import datetime | |
| # Kullanıcıları, girdikleri tarih ile adlandıracağız. | |
| current_user = datetime.now().strftime('%H.%M.%S.%f %d-%m-%Y') | |
| # Kullanıcı için log dosyası oluşturuluyor. | |
| def create_user_log_file(): | |
| # Kullanıcı için log dosyası oluşturma, | |
| with open(f"log_{current_user}.txt", "w", encoding="utf-8") as f: |
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
| from pydrive.auth import GoogleAuth | |
| def create_user_auth(): | |
| gauth = GoogleAuth() | |
| gauth.LoadCredentialsFile('mycreds.txt') | |
| if gauth.credentials is None: | |
| # Eğer mycreds.txt dosyası yoksa, kullanıcıdan kimlik doğrulaması yapılması istenir. | |
| gauth.LocalWebserverAuth() | |
| elif gauth.access_token_expired: |
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
| #Algoritma Bazlı Öznitelik Ağırlıkları | |
| #Sadece bir algoritma için hesaplayacağım ancak diğer algoritmalar için görselleştirme adına nasıl yapmanız gerektiğini de göstereceğim. | |
| plt=reload(plt) | |
| agirliklar = lr.coef_[0].tolist() # <-- Burası, Linear Algoritmalar için farklı, non-Linear algoritmalar için farklı. Aşağıdaki yorum satırını referans alabilirsiniz. | |
| #predict = rfc.predict(X_test) | |
| x_label = [x for x in range(len(agirliklar))] | |
| # clf lr ---> .coef_[0].tolist() | |
| #dtc rfc gradient xgb ---> feature_importances_.tolist() |
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
| #Daha önce hazırlamış olduğumuz ROC-AUC oranlarını bir de ROC-AUC grafiği olarak gösteriyoruz. | |
| plt=reload(plt) | |
| plt.style.use('seaborn') | |
| #dtc rfc gradient xgb clf lr <-- algoritmalarının isimleri | |
| pred_prob_dtc = dtc.predict_proba(X_test) | |
| pred_prob_rfc = rfc.predict_proba(X_test) | |
| pred_prob_gradient = gradient.predict_proba(X_test) | |
| pred_prob_xgb = xgb.predict_proba(X_test) |
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
| #Algoritma Bazlı ROC-AUC Skoru Hesaplama. | |
| rf_predictions = clf.predict(X_test) | |
| rf_probs = clf.predict_proba(X_test)[:, 1] | |
| score= roc_auc_score(y_test, rf_probs) | |
| rf_predictions = lr.predict(X_test) | |
| rf_probs = lr.predict_proba(X_test)[:, 1] | |
| score2= roc_auc_score(y_test, rf_probs) | |
| rf_predictions = dtc.predict(X_test) |
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
| #Algoritma Bazlı Cross Validation ile Accuracy Skoru Hesaplama. | |
| score= cross_val_score(clf, X_train, y_train.values.ravel(), cv=5) | |
| score2= cross_val_score(lr, X_train, y_train.values.ravel(), cv=5) | |
| score3= cross_val_score(dtc, X_train, y_train.values.ravel(), cv=5) | |
| score4= cross_val_score(rfc, X_train, y_train.values.ravel(), cv=5) | |
| score5= cross_val_score(gradient, X_train, y_train.values.ravel(), cv=5) | |
| score6= cross_val_score(xgb, X_train, y_train.values.ravel(), cv=5) | |
| #Görselleştirme |
NewerOlder