sklinearstats 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sklinearstats-0.1.5/PKG-INFO +11 -0
- sklinearstats-0.1.5/README.md +3 -0
- sklinearstats-0.1.5/pyproject.toml +17 -0
- sklinearstats-0.1.5/setup.cfg +4 -0
- sklinearstats-0.1.5/sklinear/__init__.py +1 -0
- sklinearstats-0.1.5/sklinear/printer.py +476 -0
- sklinearstats-0.1.5/sklinearstats.egg-info/PKG-INFO +11 -0
- sklinearstats-0.1.5/sklinearstats.egg-info/SOURCES.txt +8 -0
- sklinearstats-0.1.5/sklinearstats.egg-info/dependency_links.txt +1 -0
- sklinearstats-0.1.5/sklinearstats.egg-info/top_level.txt +2 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sklinearstats"
|
|
7
|
+
version = "0.1.5"
|
|
8
|
+
description = "Numpy extended helper libraries"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "regen"}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
where = ["."]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .printer import show
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
def show():
|
|
2
|
+
content = r'''
|
|
3
|
+
<class 'pandas.core.frame.DataFrame'>
|
|
4
|
+
precision recall f1-score support
|
|
5
|
+
|
|
6
|
+
0 0.72 0.86 0.79 159
|
|
7
|
+
1 0.72 0.52 0.60 108
|
|
8
|
+
|
|
9
|
+
accuracy 0.72 267
|
|
10
|
+
macro avg 0.72 0.69 0.69 267
|
|
11
|
+
weighted avg 0.72 0.72 0.71 267
|
|
12
|
+
|
|
13
|
+
RangeIndex: 5 entries, 0 to 4
|
|
14
|
+
Data columns (total 6 columns):
|
|
15
|
+
|
|
16
|
+
# Column Non-Null Count Dtype
|
|
17
|
+
--- ------ -------------- -----
|
|
18
|
+
0 First Name 5 non-null object
|
|
19
|
+
1 Gender 5 non-null object
|
|
20
|
+
2 Salary 4 non-null float64
|
|
21
|
+
3 Bonus % 4 non-null float64
|
|
22
|
+
4 Senior Management 5 non-null bool
|
|
23
|
+
5 Team 4 non-null object
|
|
24
|
+
dtypes: bool(1), float64(2), object(3)
|
|
25
|
+
memory usage: 337.0+ bytes
|
|
26
|
+
|
|
27
|
+
Input: [0 0], Predicted: [0], Expected: 0
|
|
28
|
+
Input: [0 1], Predicted: [1], Expected: 1
|
|
29
|
+
Input: [1 0], Predicted: [1], Expected: 1
|
|
30
|
+
Input: [1 1], Predicted: [1], Expected: 1
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
=========================================================================
|
|
34
|
+
#PRACTICAL NO: 13
|
|
35
|
+
#Implementation of Boosting Algorithms: AdaBoost, Stochastic Gradient Boosting, Voting Ensemble
|
|
36
|
+
=========================================================================
|
|
37
|
+
|
|
38
|
+
#========================================================================
|
|
39
|
+
# Adaboost
|
|
40
|
+
#========================================================================
|
|
41
|
+
|
|
42
|
+
import pandas as pd
|
|
43
|
+
from sklearn.ensemble import AdaBoostClassifier
|
|
44
|
+
from sklearn.model_selection import KFold, cross_val_score
|
|
45
|
+
|
|
46
|
+
df = pd.read_csv("diabetes.csv")
|
|
47
|
+
|
|
48
|
+
X,y = df.iloc[:,:8], df.iloc[:,8]
|
|
49
|
+
|
|
50
|
+
score = cross_val_score(
|
|
51
|
+
AdaBoostClassifier(n_estimators=30,random_state=42),
|
|
52
|
+
X,y,
|
|
53
|
+
cv=KFold(10,shuffle=True,random_state=42)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
print(score.mean())
|
|
57
|
+
#Gradient Boosting
|
|
58
|
+
import pandas as pd
|
|
59
|
+
from sklearn.ensemble import GradientBoostingClassifier
|
|
60
|
+
from sklearn.model_selection import KFold, cross_val_score
|
|
61
|
+
|
|
62
|
+
df = pd.read_csv("diabetes.csv")
|
|
63
|
+
|
|
64
|
+
X,y = df.iloc[:,:8], df.iloc[:,8]
|
|
65
|
+
|
|
66
|
+
score = cross_val_score(
|
|
67
|
+
GradientBoostingClassifier(n_estimators=30,random_state=42),
|
|
68
|
+
X,y,
|
|
69
|
+
cv=KFold(10,shuffle=True,random_state=42)
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
print(score.mean())
|
|
73
|
+
|
|
74
|
+
#========================================================================
|
|
75
|
+
# Random Forest(Pract 12)
|
|
76
|
+
#========================================================================
|
|
77
|
+
|
|
78
|
+
import pandas as pd
|
|
79
|
+
from sklearn.preprocessing import LabelEncoder
|
|
80
|
+
from sklearn.ensemble import RandomForestClassifier
|
|
81
|
+
from sklearn.model_selection import train_test_split
|
|
82
|
+
from sklearn.metrics import classification_report
|
|
83
|
+
|
|
84
|
+
df = pd.read_csv("PlayGolf.csv")
|
|
85
|
+
|
|
86
|
+
for c in df.columns:
|
|
87
|
+
df[c] = LabelEncoder().fit_transform(df[c])
|
|
88
|
+
|
|
89
|
+
X = df.drop('play',axis=1)
|
|
90
|
+
y = df['play']
|
|
91
|
+
|
|
92
|
+
X_train,X_test,y_train,y_test = train_test_split(
|
|
93
|
+
X,y,test_size=0.2,random_state=42
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
model = RandomForestClassifier(5)
|
|
97
|
+
model.fit(X_train,y_train)
|
|
98
|
+
|
|
99
|
+
print(classification_report(y_test,model.predict(X_test)))
|
|
100
|
+
print(model.predict([[1,1,0,0]]))
|
|
101
|
+
#plotting
|
|
102
|
+
from sklearn.tree import plot_tree
|
|
103
|
+
import matplotlib.pyplot as plt
|
|
104
|
+
|
|
105
|
+
plot_tree(model.estimators_[0],filled=True)
|
|
106
|
+
plt.show()
|
|
107
|
+
|
|
108
|
+
#========================================================================
|
|
109
|
+
# k means clustering practical 11
|
|
110
|
+
#========================================================================
|
|
111
|
+
|
|
112
|
+
import pandas as pd
|
|
113
|
+
import matplotlib.pyplot as plt
|
|
114
|
+
from sklearn.cluster import KMeans
|
|
115
|
+
|
|
116
|
+
df = pd.read_csv("Countryclusters.csv")
|
|
117
|
+
|
|
118
|
+
df["Language"] = df["Language"].map({
|
|
119
|
+
'English':1,'Hindi':2,'French':3,'German':4,'Japanese':5
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
X = df.iloc[:,1:4]
|
|
123
|
+
|
|
124
|
+
wcss = [KMeans(i,n_init=10).fit(X).inertia_ for i in range(1,7)]
|
|
125
|
+
|
|
126
|
+
plt.plot(range(1,7),wcss)
|
|
127
|
+
plt.show()
|
|
128
|
+
|
|
129
|
+
cluster = KMeans(n_clusters=4,n_init=10).fit_predict(X)
|
|
130
|
+
|
|
131
|
+
plt.scatter(df["Longitude"],df["Latitude"],c=cluster,cmap='turbo',s=200)
|
|
132
|
+
plt.show()
|
|
133
|
+
|
|
134
|
+
#========================================================================
|
|
135
|
+
# Support Vector Machine practical 10
|
|
136
|
+
#========================================================================
|
|
137
|
+
|
|
138
|
+
import pandas as pd, seaborn as sns, matplotlib.pyplot as plt
|
|
139
|
+
from sklearn.model_selection import train_test_split
|
|
140
|
+
from sklearn.preprocessing import StandardScaler
|
|
141
|
+
from sklearn.svm import SVC
|
|
142
|
+
from sklearn.metrics import *
|
|
143
|
+
|
|
144
|
+
df = pd.read_csv("Bank_Customer_retirement.csv")
|
|
145
|
+
|
|
146
|
+
sns.pairplot(df,hue='Retire',vars=['Age','401K Savings'])
|
|
147
|
+
plt.show()
|
|
148
|
+
|
|
149
|
+
X = StandardScaler().fit_transform(df[['Age','401K Savings']])
|
|
150
|
+
y = df['Retire']
|
|
151
|
+
|
|
152
|
+
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=0)
|
|
153
|
+
|
|
154
|
+
pred = SVC(kernel='poly').fit(X_train,y_train).predict(X_test)
|
|
155
|
+
|
|
156
|
+
print("Accuracy:",accuracy_score(y_test,pred))
|
|
157
|
+
print(classification_report(y_test,pred))
|
|
158
|
+
|
|
159
|
+
sns.heatmap(confusion_matrix(y_test,pred),annot=True)
|
|
160
|
+
plt.show()
|
|
161
|
+
|
|
162
|
+
#========================================================================
|
|
163
|
+
# logistic regression practical 9
|
|
164
|
+
#========================================================================
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
import pandas as pd
|
|
168
|
+
from sklearn.model_selection import train_test_split
|
|
169
|
+
from sklearn.linear_model import LogisticRegression
|
|
170
|
+
from sklearn.metrics import *
|
|
171
|
+
|
|
172
|
+
df = pd.read_csv('/content/titanic.csv').dropna().drop(['Sex','Name'], axis=1)
|
|
173
|
+
|
|
174
|
+
X_train,X_test,y_train,y_test = train_test_split(
|
|
175
|
+
df.drop('Survived', axis=1), df['Survived'],
|
|
176
|
+
test_size=0.3, random_state=101
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
pred = LogisticRegression().fit(X_train,y_train).predict(X_test)
|
|
180
|
+
|
|
181
|
+
ConfusionMatrixDisplay.from_predictions(y_test,pred)
|
|
182
|
+
print(classification_report(y_test,pred))
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
#========================================================================
|
|
186
|
+
# feature selection practical 8
|
|
187
|
+
#========================================================================
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
import pandas as pd
|
|
191
|
+
from sklearn.feature_selection import *
|
|
192
|
+
|
|
193
|
+
df = pd.read_csv("train_mobile.csv")
|
|
194
|
+
|
|
195
|
+
X,y = df.iloc[:,:20], df.iloc[:,-1]
|
|
196
|
+
|
|
197
|
+
print(pd.concat([
|
|
198
|
+
pd.DataFrame(X.columns),
|
|
199
|
+
pd.DataFrame(SelectKBest(chi2,k=10).fit(X,y).scores_)
|
|
200
|
+
],axis=1))
|
|
201
|
+
|
|
202
|
+
# standardization and normalization
|
|
203
|
+
import pandas as pd
|
|
204
|
+
from sklearn.preprocessing import *
|
|
205
|
+
|
|
206
|
+
df = pd.read_csv("Loan_Data (1).csv")[['loan_amount','interest_rate','installment']]
|
|
207
|
+
print(df.head())
|
|
208
|
+
print(StandardScaler().fit_transform(df))
|
|
209
|
+
print(MinMaxScaler().fit_transform(df))
|
|
210
|
+
|
|
211
|
+
#========================================================================
|
|
212
|
+
# PCA
|
|
213
|
+
#========================================================================
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
import pandas as pd
|
|
217
|
+
from sklearn.model_selection import train_test_split
|
|
218
|
+
from sklearn.preprocessing import StandardScaler
|
|
219
|
+
from sklearn.decomposition import PCA
|
|
220
|
+
from sklearn.linear_model import LogisticRegression
|
|
221
|
+
from sklearn.metrics import accuracy_score
|
|
222
|
+
|
|
223
|
+
df = pd.read_csv("wine.data.csv")
|
|
224
|
+
|
|
225
|
+
X_train,X_test,y_train,y_test = train_test_split(
|
|
226
|
+
df.iloc[:,:13], df.iloc[:,0],
|
|
227
|
+
test_size=0.2, random_state=0
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
X_train = StandardScaler().fit_transform(X_train)
|
|
231
|
+
X_test = StandardScaler().fit(X_test).transform(X_test)
|
|
232
|
+
|
|
233
|
+
X_train = PCA(1).fit_transform(X_train)
|
|
234
|
+
X_test = PCA(1).fit_transform(X_test)
|
|
235
|
+
|
|
236
|
+
pred = LogisticRegression().fit(X_train,y_train).predict(X_test)
|
|
237
|
+
|
|
238
|
+
print("Accuracy:",accuracy_score(y_test,pred))
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
#========================================================================
|
|
242
|
+
# Adaline algorithm for AND operation practical 7
|
|
243
|
+
#========================================================================
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
import numpy as np
|
|
247
|
+
|
|
248
|
+
X=np.array([[0,0],[0,1],[1,0],[1,1]])
|
|
249
|
+
y=np.array([0,0,0,1])
|
|
250
|
+
|
|
251
|
+
w=np.zeros(2)
|
|
252
|
+
b=0
|
|
253
|
+
lr=0.1
|
|
254
|
+
|
|
255
|
+
for _ in range(100):
|
|
256
|
+
for i in range(4):
|
|
257
|
+
out=np.dot(X[i],w)+b
|
|
258
|
+
e=y[i]-out
|
|
259
|
+
w+=lr*e*X[i]
|
|
260
|
+
b+=lr*e
|
|
261
|
+
|
|
262
|
+
for i in range(4):
|
|
263
|
+
p=1 if np.dot(X[i],w)+b>=0.5 else 0
|
|
264
|
+
print(f"Input: {X[i]} => Predicted: {p} => Actual: {y[i]}")
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
#========================================================================
|
|
268
|
+
# Improve the prediction accuracy by estimating the weight values for the # training data using stochastic gradient descent.
|
|
269
|
+
(Perceptron). Practical 6
|
|
270
|
+
#========================================================================
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
X=[[0,0],[0,1],[1,0],[1,1]]
|
|
274
|
+
y=[0,0,0,1]
|
|
275
|
+
|
|
276
|
+
w1=w2=b=0
|
|
277
|
+
lr=0.1
|
|
278
|
+
|
|
279
|
+
for _ in range(10):
|
|
280
|
+
for i in range(4):
|
|
281
|
+
x1,x2=X[i]
|
|
282
|
+
p=1 if w1*x1+w2*x2+b>=0 else 0
|
|
283
|
+
e=y[i]-p
|
|
284
|
+
|
|
285
|
+
w1+=lr*e*x1
|
|
286
|
+
w2+=lr*e*x2
|
|
287
|
+
b+=lr*e
|
|
288
|
+
|
|
289
|
+
print("Weights:",w1,w2)
|
|
290
|
+
print("Bias:",b)
|
|
291
|
+
|
|
292
|
+
for x1,x2 in X:
|
|
293
|
+
p=1 if w1*x1+w2*x2+b>=0 else 0
|
|
294
|
+
print([x1,x2],"->",p)
|
|
295
|
+
|
|
296
|
+
#========================================================================
|
|
297
|
+
# Implement Perceptron algorithm for OR operation.practical 5
|
|
298
|
+
#========================================================================
|
|
299
|
+
|
|
300
|
+
import numpy as np
|
|
301
|
+
|
|
302
|
+
X=np.array([[0,0],[0,1],[1,0],[1,1]])
|
|
303
|
+
y=np.array([0,1,1,1])
|
|
304
|
+
|
|
305
|
+
w=np.zeros(2)
|
|
306
|
+
b=0
|
|
307
|
+
lr=0.1
|
|
308
|
+
|
|
309
|
+
for _ in range(10):
|
|
310
|
+
for i in range(4):
|
|
311
|
+
p=1 if np.dot(X[i],w)+b>=0 else 0
|
|
312
|
+
e=y[i]-p
|
|
313
|
+
w+=lr*e*X[i]
|
|
314
|
+
b+=lr*e
|
|
315
|
+
|
|
316
|
+
for i in range(4):
|
|
317
|
+
p=1 if np.dot(X[i],w)+b>=0 else 0
|
|
318
|
+
print(f"Input: {X[i]}, Predicted: [{p}], Expected: {y[i]}")
|
|
319
|
+
|
|
320
|
+
#========================================================================
|
|
321
|
+
# practical 4
|
|
322
|
+
# NUMPY FUNCTIONS
|
|
323
|
+
# execute on single code
|
|
324
|
+
#========================================================================
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
import numpy as np
|
|
328
|
+
|
|
329
|
+
np.zeros(10)
|
|
330
|
+
np.ones(10)
|
|
331
|
+
np.arange(10,51)
|
|
332
|
+
np.eye(3)
|
|
333
|
+
np.linspace(0,1,20)
|
|
334
|
+
|
|
335
|
+
#========================================================================
|
|
336
|
+
# MATRIX OPERATIONS
|
|
337
|
+
#========================================================================
|
|
338
|
+
|
|
339
|
+
mat = np.arange(1,26).reshape(5,5)
|
|
340
|
+
|
|
341
|
+
mat.sum()
|
|
342
|
+
mat.std()
|
|
343
|
+
mat.sum(axis=0)
|
|
344
|
+
mat.sum(axis=1)
|
|
345
|
+
|
|
346
|
+
#========================================================================
|
|
347
|
+
# PANDAS DATAFRAME CREATION
|
|
348
|
+
#========================================================================
|
|
349
|
+
|
|
350
|
+
import pandas as pd
|
|
351
|
+
|
|
352
|
+
df = pd.DataFrame({
|
|
353
|
+
'Name':['Tom','Jack'],
|
|
354
|
+
'Age':[20,25],
|
|
355
|
+
'city':['New York','London'] # Added 'city' column for demonstration
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
#========================================================================
|
|
359
|
+
# MISSING VALUE HANDLING
|
|
360
|
+
#========================================================================
|
|
361
|
+
|
|
362
|
+
df.isnull()
|
|
363
|
+
df.fillna(75)
|
|
364
|
+
|
|
365
|
+
#========================================================================
|
|
366
|
+
# GROUPBY OPERATIONS
|
|
367
|
+
#========================================================================
|
|
368
|
+
|
|
369
|
+
df.groupby('city')['Age'].mean() # Explicitly calculating mean for 'Age'
|
|
370
|
+
df.groupby('city').sum()
|
|
371
|
+
df.groupby('city').count()
|
|
372
|
+
|
|
373
|
+
#========================================================================
|
|
374
|
+
# CSV FILE OPERATIONS
|
|
375
|
+
#========================================================================
|
|
376
|
+
|
|
377
|
+
empdf = pd.read_csv("employee.csv")
|
|
378
|
+
|
|
379
|
+
empdf.head()
|
|
380
|
+
empdf.tail()
|
|
381
|
+
empdf.info()
|
|
382
|
+
empdf.describe()
|
|
383
|
+
|
|
384
|
+
#========================================================================
|
|
385
|
+
# DATA CLEANING
|
|
386
|
+
#========================================================================
|
|
387
|
+
|
|
388
|
+
empdf.drop_duplicates()
|
|
389
|
+
empdf.rename({'Team':'Department'}, axis=1)
|
|
390
|
+
empdf.ffill()
|
|
391
|
+
|
|
392
|
+
#========================================================================
|
|
393
|
+
# PROLOG
|
|
394
|
+
#========================================================================
|
|
395
|
+
|
|
396
|
+
#========================================================================
|
|
397
|
+
# DFS Water Jug Problem
|
|
398
|
+
#========================================================================
|
|
399
|
+
|
|
400
|
+
start((0,0)).
|
|
401
|
+
goal((2,0)).
|
|
402
|
+
|
|
403
|
+
move((X,Y),(5,Y)):-X<5.
|
|
404
|
+
move((X,Y),(X,4)):-Y<4.
|
|
405
|
+
move((X,Y),(0,Y)):-X>0.
|
|
406
|
+
move((X,Y),(X,0)):-Y>0.
|
|
407
|
+
|
|
408
|
+
move((X,Y),(NX,NY)):-
|
|
409
|
+
X>0,Y<4,
|
|
410
|
+
T is min(X,4-Y),
|
|
411
|
+
NX is X-T,
|
|
412
|
+
NY is Y+T.
|
|
413
|
+
|
|
414
|
+
move((X,Y),(NX,NY)):-
|
|
415
|
+
Y>0,X<5,
|
|
416
|
+
T is min(Y,5-X),
|
|
417
|
+
NX is X+T,
|
|
418
|
+
NY is Y-T.
|
|
419
|
+
|
|
420
|
+
#========================================================================
|
|
421
|
+
# Tic Tac Toe
|
|
422
|
+
#========================================================================
|
|
423
|
+
|
|
424
|
+
show([A,B,C,D,E,F,G,H,I]):-
|
|
425
|
+
write(A),write(' '),write(B),write(' '),write(C),nl,
|
|
426
|
+
write(D),write(' '),write(E),write(' '),write(F),nl,
|
|
427
|
+
write(G),write(' '),write(H),write(' '),write(I),nl.
|
|
428
|
+
|
|
429
|
+
put(Board,Pos,Val,NewBoard):-
|
|
430
|
+
nth1(Pos,Board,_,Rest),
|
|
431
|
+
nth1(Pos,NewBoard,Val,Rest).
|
|
432
|
+
|
|
433
|
+
win([P,P,P,_,_,_,_,_,_],P).
|
|
434
|
+
win([_,_,_,P,P,P,_,_,_],P).
|
|
435
|
+
win([_,_,_,_,_,_,P,P,P],P).
|
|
436
|
+
win([P,_,_,P,_,_,P,_,_],P).
|
|
437
|
+
win([_,P,_,_,P,_,_,P,_],P).
|
|
438
|
+
win([_,_,P,_,_,P,_,_,P],P).
|
|
439
|
+
win([P,_,_,_,P,_,_,_,P],P).
|
|
440
|
+
win([_,_,P,_,P,_,P,_,_],P).
|
|
441
|
+
|
|
442
|
+
play :-
|
|
443
|
+
B=[_,_,_,_,_,_,_,_,_],
|
|
444
|
+
show(B),
|
|
445
|
+
read(P1),put(B,P1,x,B1),
|
|
446
|
+
read(P2),put(B1,P2,o,B2),
|
|
447
|
+
read(P3),put(B2,P3,x,B3),
|
|
448
|
+
read(P4),put(B3,P4,o,B4),
|
|
449
|
+
read(P5),put(B4,P5,x,B5),
|
|
450
|
+
(win(B5,W)->write(W),write(' wins!');write('No winner')).
|
|
451
|
+
|
|
452
|
+
#========================================================================
|
|
453
|
+
# 8 Puzzle Hill Climbing
|
|
454
|
+
#========================================================================
|
|
455
|
+
|
|
456
|
+
start(1/2/3/4/8/0/7/6/5).
|
|
457
|
+
goal(1/2/3/4/5/6/7/8/0).
|
|
458
|
+
|
|
459
|
+
move(1/2/3/4/8/0/7/6/5,1/2/3/4/8/5/7/6/0).
|
|
460
|
+
move(1/2/3/4/8/5/7/6/0,1/2/3/4/8/5/7/0/6).
|
|
461
|
+
move(1/2/3/4/8/5/7/0/6,1/2/3/4/0/5/7/8/6).
|
|
462
|
+
move(1/2/3/4/0/5/7/8/6,1/2/3/4/5/0/7/8/6).
|
|
463
|
+
move(1/2/3/4/5/0/7/8/6,1/2/3/4/5/6/7/8/0).
|
|
464
|
+
|
|
465
|
+
solve :-
|
|
466
|
+
start(S),
|
|
467
|
+
move(S,A),
|
|
468
|
+
move(A,B),
|
|
469
|
+
move(B,C),
|
|
470
|
+
move(C,D),
|
|
471
|
+
move(D,G),
|
|
472
|
+
goal(G),
|
|
473
|
+
write('Goal Reached! Total Cost = 5').
|
|
474
|
+
'''
|
|
475
|
+
|
|
476
|
+
print(content)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|