Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
35 changed files
with
594 additions
and
369 deletions.
There are no files selected for viewing
This file contains 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
BIN
+96.7 KB
7159CEM-Portfolio-main/ACO/ASYGRF350.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+78.5 KB
7159CEM-Portfolio-main/ACO/ASYPLT350.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+110 KB
7159CEM-Portfolio-main/ACO/Asygrf.250.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
-6.67 KB
(92%)
7159CEM-Portfolio-main/ACO/Asyplt200.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+85.6 KB
7159CEM-Portfolio-main/ACO/Asyplt250.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+79.3 KB
7159CEM-Portfolio-main/ACO/Asyplt300.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
def top_down(arr, n): | ||
memo = {} | ||
|
||
# recursive top down memoized solution | ||
def solve(i, j): | ||
if i > j or i >= n or j < 0: | ||
return 0 | ||
|
||
k = (i, j) | ||
if k in memo: | ||
return memo[k] | ||
|
||
# if the user chooses ith number, the opponent can choose from i+1th or jth number. | ||
# if he chooses i+1th number, user is left with [i+2,j] range. | ||
# if opp chooses jth number, then user is left with [i+1,j-1] range to choose from. | ||
# Also opponent tries to choose | ||
# in such a way that the user has minimum value left. | ||
option1 = arr[i] + min(solve(i+2, j), solve(i+1, j-1)) | ||
|
||
# if user chooses jth number, opponent can choose ith number or j-1th number. | ||
# if opp chooses ith number,user can choose in range [i+1,j-1]. | ||
# if opp chooses j-1th number, user can choose in range [i,j-2]. | ||
option2 = arr[j] + min(solve(i+1, j-1), solve(i, j-2)) | ||
|
||
# since the user wants to get maximum money | ||
memo[k] = max(option1, option2) | ||
return memo[k] | ||
|
||
return solve(0, n-1) | ||
|
||
def bot_up(arr, n): | ||
|
||
#Create a table to store | ||
#solutions of subproblems | ||
table = [[0 for i in range(n)] | ||
for i in range(n)] | ||
|
||
# Fill table using above recursive | ||
# formula. Note that the table is | ||
# filled in diagonal fashion | ||
# from diagonal elements to | ||
# table[0][n-1] which is the result. | ||
for gap in range(n): | ||
for j in range(gap, n): | ||
i = j - gap | ||
|
||
# Here x is value of F(i + 2, j), | ||
# y is F(i + 1, j-1) and z is | ||
# F(i, j-2) in above recursive | ||
# formula | ||
x = 0 | ||
if((i + 2) <= j): | ||
x = table[i + 2][j] | ||
y = 0 | ||
if((i + 1) <= (j - 1)): | ||
y = table[i + 1][j - 1] | ||
z = 0 | ||
if(i <= (j - 2)): | ||
z = table[i][j - 2] | ||
table[i][j] = max(arr[i] + min(x, y), | ||
arr[j] + min(y, z)) | ||
return table[0][n - 1] | ||
|
||
|
||
|
||
# Test Code | ||
list1 = [5, 3, 7, 10] | ||
n = len(list1) | ||
print('Maximum Profit of P1 using Top Down approach = ', top_down(list1, n)) | ||
|
||
print('Maximum Profit of P1 using Bottom Up approach = ', bot_up(list1, n)) | ||
|
||
list2 = [8, 15, 3, 7] | ||
n = len(list2) | ||
print('Maximum Profit of P1 using Top Down approach = ',top_down(list2, n)) | ||
print('Maximum Profit of P1 using Bottom Up approach = ', bot_up(list2, n)) | ||
|
||
list3 = [20, 30, 2, 2, 2, 10] | ||
n = len(list3) | ||
print( 'Maximum Profit of P1 using Top Down approach = ',top_down(list3, n)) | ||
print('Maximum Profit of P1 using Bottom Up approach = ', bot_up(list3, n)) |
BIN
+238 KB
7159CEM-Portfolio-main/ACO/ECUGRF350.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+46.2 KB
7159CEM-Portfolio-main/ACO/ECUPLT350.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+238 KB
7159CEM-Portfolio-main/ACO/Ecugrf200.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+248 KB
7159CEM-Portfolio-main/ACO/Ecugrf250.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+249 KB
7159CEM-Portfolio-main/ACO/Ecugrf300.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
-19.5 KB
(71%)
7159CEM-Portfolio-main/ACO/Ecuplt200.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+43.9 KB
7159CEM-Portfolio-main/ACO/Ecuplt250.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+43.9 KB
7159CEM-Portfolio-main/ACO/Ecuplt300.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Import all classes of PuLP module | ||
from pulp import * | ||
|
||
# Create the problem variable to contain the problem data | ||
model = LpProblem("ToolsProblem", LpMaximize) | ||
|
||
# Create 3 variables Steel, Molding_machine, and Assembly_machine | ||
|
||
T1 = LpVariable("Tool1", 0, None, LpInteger) | ||
T2 = LpVariable("Tool2", 0, None, LpInteger) | ||
T3 = LpVariable("Tool3", 0, None, LpInteger) | ||
|
||
# Create maximize objective function | ||
model += 0.13 * T1 + 0.1 * T2 + 0.12 * T3 | ||
|
||
#Constraints: | ||
|
||
model += 1*T1 + 0.7 * T2 + 0.6 * T3 <= 10000, "Steel" | ||
model += 1*T1 + 1 * T2 + 1 * T3 <= 20000, "Molding_machine" | ||
model += 0.3*T1 + 0.5 * T2 + 0.4 * T3 <= 9000, "Assembly_machine" | ||
|
||
#Demand limits: | ||
|
||
model += T1 <= 15000, "T1_DemandLimit" | ||
model += T2 <= 16000, "T2_DemandLimit" | ||
model += T3 <= 12000, "T3_DemandLimit" | ||
|
||
model.solve() | ||
|
||
for v in model.variables(): | ||
print(v.name, "=", v.varValue) | ||
|
||
# print("T1 = ", T1.varValue) | ||
# print("T2 = ", T2.varValue) | ||
# print("T3 =" , T3.varValue) | ||
|
||
|
||
|
BIN
+44.5 KB
7159CEM-Portfolio-main/ACO/SYMGRF350.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+77.2 KB
7159CEM-Portfolio-main/ACO/SYMPLT350.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+51.5 KB
7159CEM-Portfolio-main/ACO/Symgrf250.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+48.4 KB
7159CEM-Portfolio-main/ACO/Symgrf300.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+78.1 KB
7159CEM-Portfolio-main/ACO/Symplt200.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+83.4 KB
7159CEM-Portfolio-main/ACO/Symplt250.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+83.1 KB
7159CEM-Portfolio-main/ACO/Symplt300.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import seaborn as sns | ||
from sklearn.model_selection import train_test_split | ||
from sklearn.tree import DecisionTreeClassifier | ||
from sklearn import tree | ||
from sklearn.metrics import accuracy_score | ||
import warnings | ||
|
||
warnings.filterwarnings("ignore") | ||
|
||
data1 = pd.read_csv('datasets/weather.numeric.csv') | ||
data2 = pd.read_csv('datasets/weather.nominal.csv') | ||
|
||
|
||
X= data1.drop(columns=['play'], axis=1) | ||
|
||
y= data1['play'] | ||
|
||
X_train, X_test, y_train, y_test= train_test_split(X,y,test_size= 0.3) | ||
|
||
d1tree= DecisionTreeClassifier() | ||
d1tree.fit(X_train,y_train) | ||
predictions= d1tree.predict(X_test) | ||
|
||
tree.plot_tree(d1tree) | ||
plt.show() | ||
|
||
from sklearn.metrics import classification_report, confusion_matrix | ||
print("Accuracy:",accuracy_score(y_test,predictions)) | ||
|
||
print(confusion_matrix(y_test,predictions)) | ||
print('\n') | ||
print(classification_report(y_test,predictions)) | ||
|
||
from sklearn import preprocessing | ||
string_to_int= preprocessing.LabelEncoder() #encode your data | ||
data2=data2.apply(string_to_int.fit_transform) #fit and transform it | ||
|
||
#To divide our data into attribute set and Label: | ||
feature_cols = ['outlook','temperature','humidity','windy'] | ||
X = data2[feature_cols] #contains the attribute | ||
y = data2.play #contains the label | ||
|
||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30) | ||
|
||
d2tree =DecisionTreeClassifier(criterion="entropy", random_state=100) # create a classifier object | ||
d2tree.fit(X_train, y_train) | ||
|
||
y_pred= d2tree.predict(X_test) | ||
|
||
|
||
print("Accuracy:",accuracy_score(y_test, y_pred)) | ||
|
||
print(confusion_matrix(y_test, y_pred)) | ||
print(classification_report(y_test, y_pred)) | ||
|
||
tree.plot_tree(d2tree) | ||
plt.show() |
BIN
+98.4 KB
7159CEM-Portfolio-main/ACO/asygrf200.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+103 KB
7159CEM-Portfolio-main/ACO/asygrf300.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+264 KB
7159CEM-Portfolio-main/ACO/sym300.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+44.5 KB
7159CEM-Portfolio-main/ACO/symgrf200.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.