2-Amaliy mashg`ulot
Download 496.16 Kb.
|
2 ish AI
2-Amaliy mashg`ulot. 1. Python muhitida Pandas, Keras, Tensorflow, kutubxonalaridan foydalangan holda jadval ko’rinishida berilgan ma’lumotlarni klassifikatsiya qilish. 2. Logistik regressiya tushunchasi. Xatoliklarni baholash. Klassifikatsiyalashni amalga oshirish. 3. Eng soda perseptron yordamida hisoblashlarni amalga oshirish. Python muhitida Pandas kutubxonasidan foydalangan holda jadval ko’rinishida berilgan ma’lumotlarni klassifikatsiya qilish. import requests download_url = "https://raw.githubusercontent.com/fivethirtyeight/data/master/nba-elo/nbaallelo.csv" target_csv_path = "nba_all_elo.csv" response = requests.get(download_url) response.raise_for_status() # Check that the request was successful with open(target_csv_path, "wb") as f: f.write(response.content) print(f.write) Ma'lumotlarni yuklab olish uchun skript yaratadi hamda ularni tekshirish uchun quidagicha shellga murojaat qilinadi. >>> nba = pd.read_csv("nba_all_elo.csv") >>> type(nba) Yuklab olingan sikript ichida qancha malumot uzunligini korish esa >>> len(nba) 126314 >>> nba.shape (126314, 23) Quidagicha tekshiriladi. Kerasda neyron tarmoq qurish (Input) model = Sequential() model.add(Dense(512, input_shape=(784,))) model.add(Activation('relu')) model.add(Dropout(0.2)) Kerasda neyron tarmoq qurish (Hidden) model = Sequential() model.add(Dense(512, input_shape=(784,))) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(512)) model.add(Activation('relu')) model.add(Dropout(0.2)) Kerasda neyron tarmoq qurish (Output) model = Sequential() model.add(Dense(512, input_shape=(784,))) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(512)) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(10)) model.add(Activation('softmax')) Logistik regressiya tushunchasi. Xatoliklarni baholash. Klassifikatsiyalashni amalga oshirish. import numpy as np from sklearn.linear_model import LogisticRegression from sklearn.metrics import classification_report, confusion_matrix # Step 2: Get data x = np.arange(10).reshape(-1, 1) y = np.array([0, 1, 0, 0, 1, 1, 1, 1, 1, 1]) # Step 3: Create a model and train it model = LogisticRegression(solver='liblinear', C=10.0, random_state=0) model.fit(x, y) # Step 4: Evaluate the model p_pred = model.predict_proba(x) y_pred = model.predict(x) score_ = model.score(x, y) conf_m = confusion_matrix(y, y_pred) report = classification_report(y, y_pred) 3. Eng soda perseptron yordamida hisoblashlarni amalga oshirish. import numpy as np N = 100
def sigmoid_function(an): return 1/(1 + np.exp(-an)) # Make a prediction with weights def predict(row, weights): activation = weights[0] for i in range(len(row)-1): activation += weights[i + 1] * row[i] return 1.0 if activation >= 0.0 else 0.0 dataset = [[2.7810836,2.550537003,0], [1.465489372,2.362125076,0], [3.396561688,4.400293529,0], [1.38807019,1.850220317,0], [3.06407232,3.005305973,0], [7.627531214,2.759262235,1], [5.332441248,2.088626775,1], [6.922596716,1.77106367,1], [8.675418651,-0.242068655,1], [7.673756466,3.508563011,1]] weights = [-0.1, 0.20653640140000007, -0.23418117710000003] for row in dataset: prediction = predict(row, weights) print("Expected=%d, Predicted=%d" % (row[-1], prediction)) #short overwiev of updating process of w's learning_rate = 0.01 s Download 496.16 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling