FRsūtil̲s
A fuzzy-rough reasoning utilities library
 
Loading...
Searching...
No Matches
plot_implicators.py
Go to the documentation of this file.
1import numpy as np
2import matplotlib.pyplot as plt
3from mpl_toolkits.mplot3d import Axes3D
4
5import sys
6import os
7
8sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../core')))
9
10import implicators as imp
11
12# Create a grid of values
13n = 200 # Replace with your desired length (must be even)
14arr = np.concatenate([np.zeros(n // 2), np.ones(n // 2)])
15
16similarity_vals = np.linspace(0, 1, n)
17b_vals = arr
18AVals, simVals = np.meshgrid(similarity_vals, b_vals)
19
20# Vectorized computation of the implicator
21ImpVals = np.vectorize(imp.imp_lukasiewicz)(AVals, simVals)
22
23# Plotting
24fig = plt.figure(figsize=(10, 7))
25ax = fig.add_subplot(111, projection='3d')
26
27# Plot surface with colormap
28# surf = ax.plot_surface(A, B, Z, cmap='hot', edgecolor='none')
29# Plot the points
30ax.scatter(AVals, simVals, ImpVals, c='red', marker='.')
31
32# Add color bar
33# fig.colorbar(surf, ax=ax, shrink=0.5, aspect=5)
34
35# Labels and title
36ax.set_title("Luk Implicator")
37ax.set_ylabel("A(y)")
38ax.set_xlabel("similarity (x,y)")
39ax.set_zlabel("I(similarity (x,y), A(y))")
40
41plt.tight_layout()
42plt.show()