### Install scikit-fuzzy locally from source Source: https://scikit-fuzzy.github.io/scikit-fuzzy/install.html Install the SciKit locally using the setup.py script. Specify a prefix for local installation. ```bash python setup.py install --prefix=${HOME} ``` -------------------------------- ### Example .gitconfig file Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/configure_git.html A sample configuration file structure for the home directory. ```ini [user] name = Your Name email = you@yourdomain.example.com [alias] ci = commit -a co = checkout st = status stat = status br = branch wdiff = diff --color-words [core] editor = vim [merge] summary = true ``` -------------------------------- ### Install scikit-fuzzy using easy_install Source: https://scikit-fuzzy.github.io/scikit-fuzzy/install.html Use this command to install the latest version of scikit-fuzzy from the Python Packaging Index if you have setuptools installed. ```bash easy_install -U scikit-fuzzy ``` -------------------------------- ### Initiate Interactive Rebase Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/development_workflow.html Create a backup branch and start an interactive rebase session from a specific commit. ```bash # make a backup of the current state git branch tmp HEAD # interactive rebase git rebase -i 6ad92e5 ``` -------------------------------- ### Install scikit-fuzzy using pip Source: https://scikit-fuzzy.github.io/scikit-fuzzy/install.html Use this command to install the latest version of scikit-fuzzy from the Python Packaging Index using pip. ```bash pip install -U scikit-fuzzy ``` -------------------------------- ### Test Coverage Report Example Source: https://scikit-fuzzy.github.io/scikit-fuzzy/contribute.html An example of the test coverage report generated by coverage.py, showing statement counts, misses, and coverage percentage per module. ```bash Name Stmts Miss Cover Missing ------------------------------------------------------------------------- skfuzzy.cluster 2 0 100% skfuzzy.defuzzify 2 0 100% skfuzzy.filters 2 0 100% ... ``` -------------------------------- ### NumPy Array Padding Examples Source: https://scikit-fuzzy.github.io/scikit-fuzzy/api/index.html Demonstrates array padding using a custom function with default and specified padder values. ```python >>> a = np.arange(6) >>> a = a.reshape((2, 3)) >>> np.pad(a, 2, pad_with) array([[10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10], [10, 10, 0, 1, 2, 10, 10], [10, 10, 3, 4, 5, 10, 10], [10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10]]) >>> np.pad(a, 2, pad_with, padder=100) array([[100, 100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100, 100], [100, 100, 0, 1, 2, 100, 100], [100, 100, 3, 4, 5, 100, 100], [100, 100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100, 100]]) ``` -------------------------------- ### Running Test Coverage Source: https://scikit-fuzzy.github.io/scikit-fuzzy/contribute.html Use this command to measure test coverage for the skfuzzy library. Install coverage.py first. ```bash $ make coverage ``` -------------------------------- ### Function Chaining Example Source: https://scikit-fuzzy.github.io/scikit-fuzzy/contribute.html Demonstrates how to chain functions for image processing pipelines. Utility functions like `img_as_float` can help manage input dtypes. ```python hough(canny(my_image)) ``` -------------------------------- ### Implement custom padding function Source: https://scikit-fuzzy.github.io/scikit-fuzzy/api/index.html Example of a user-defined function for custom padding logic. ```python >>> def pad_with(vector, pad_width, iaxis, kwargs): ... pad_value = kwargs.get('padder', 10) ... vector[:pad_width[0]] = pad_value ... vector[-pad_width[1]:] = pad_value ``` -------------------------------- ### Install scikit-fuzzy in editable mode Source: https://scikit-fuzzy.github.io/scikit-fuzzy/install.html Install the SciKit globally in editable mode using pip. This is useful for development. ```bash pip install -e . ``` -------------------------------- ### Modify Rebase Instructions Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/development_workflow.html Example of reordering and squashing commits during an interactive rebase. ```text r 13d7934 First implementation pick 2dec1ac Fix a few bugs + disable f a815645 Modify it so that it works f eadc391 Fix some remaining bugs ``` -------------------------------- ### Clone scikit-fuzzy repository Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/following_latest.html Use this command to get a local copy of the scikit-fuzzy source code from GitHub. ```bash git clone git://github.com/scikit-fuzzy/scikit-fuzzy.git ``` -------------------------------- ### Define Fuzzy Rules Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_downloads/73d25e9f2afeb5023afbb7a96cf89e33/plot_tipping_problem_newapi.ipynb Define fuzzy rules using the ctrl.Rule constructor. This example shows rules based on 'quality' and 'service' to determine 'tip' level. The .view() method can be used to visualize individual rules. ```python rule1 = ctrl.Rule(quality['poor'] | service['poor'], tip['low']) rule2 = ctrl.Rule(service['average'], tip['medium']) rule3 = ctrl.Rule(service['good'] | quality['good'], tip['high']) rule1.view() ``` -------------------------------- ### Generate a triangular membership function Source: https://scikit-fuzzy.github.io/scikit-fuzzy/userguide/getting_started.html This example demonstrates how to generate a triangular membership function using numpy for the x-axis values and scikit-fuzzy's trimf function. The output shows the input array and the corresponding membership function values. ```python >>> import numpy as np >>> import skfuzzy as fuzz >>> x = np.arange(11) >>> mfx = fuzz.trimf(x, [0, 5, 10]) >>> x array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) >>> mfx array([ 0. , 0.2, 0.4, 0.6, 0.8, 1. , 0.8, 0.6, 0.4, 0.2, 0. ]) ``` -------------------------------- ### Initialize Control System Simulation Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_downloads/8602739f4db656fd0145795ecb773c5e/plot_control_system_advanced.ipynb Assemble rules into a ControlSystem and initialize the simulation engine. ```python system = ctrl.ControlSystem(rules=[rule0, rule1, rule2, rule3, rule4]) # Later we intend to run this system with a 21*21 set of inputs, so we allow # that many plus one unique runs before results are flushed. # Subsequent runs would return in 1/8 the time! sim = ctrl.ControlSystemSimulation(system, flush_after_run=21 * 21 + 1) ``` -------------------------------- ### Configure Control System Simulation Source: https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_control_system_advanced.html Initializes the ControlSystem with defined rules and prepares a simulation instance with a specified flush threshold. ```python system = ctrl.ControlSystem(rules=[rule0, rule1, rule2, rule3, rule4]) # Later we intend to run this system with a 21*21 set of inputs, so we allow # that many plus one unique runs before results are flushed. # Subsequent runs would return in 1/8 the time! sim = ctrl.ControlSystemSimulation(system, flush_after_run=21 * 21 + 1) ``` -------------------------------- ### Clone the repository Source: https://scikit-fuzzy.github.io/scikit-fuzzy/contribute.html Initial step to create a local copy of the project from your fork. ```bash git clone git@github.com:your-username/scikit-fuzzy.git ``` -------------------------------- ### View as Windows Function Implementation Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_modules/skfuzzy/image/shape.html The core implementation of the `view_as_windows` function, including argument validation and the use of `as_strided` for efficient window creation. ```python # -- basic checks on arguments if not isinstance(arr_in, np.ndarray): raise TypeError("'arr_in' must be a numpy ndarray") if not isinstance(window_shape, tuple): raise TypeError("'window_shape' must be a tuple") if not (len(window_shape) == arr_in.ndim): raise ValueError("'window_shape' is incompatible with 'arr_in.shape'") arr_shape = np.array(arr_in.shape) window_shape = np.array(window_shape, dtype=arr_shape.dtype) if ((arr_shape - window_shape) < 0).any(): raise ValueError("'window_shape' is too large") if ((window_shape - 1) < 0).any(): raise ValueError("'window_shape' is too small") # -- build rolling window view arr_in = np.ascontiguousarray(arr_in) new_shape = tuple(arr_shape - window_shape + 1) + tuple(window_shape) new_strides = arr_in.strides + arr_in.strides arr_out = as_strided(arr_in, shape=new_shape, strides=new_strides) return arr_out ``` -------------------------------- ### GET /interp_universe Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_modules/skfuzzy/fuzzymath/fuzzy_ops.html Finds interpolated universe value(s) for a given fuzzy membership value using linear interpolation. ```APIDOC ## GET /interp_universe ### Description Finds interpolated universe value(s) for a given fuzzy membership value. This function computes the value (or values) of xx such that u(xx) == y using linear interpolation. ### Method GET ### Parameters #### Query Parameters - **x** (1d array) - Required - Independent discrete variable vector. - **xmf** (1d array) - Required - Fuzzy membership function for x. Same length as x. - **y** (float) - Required - Specific fuzzy membership value. ### Response #### Success Response (200) - **xx** (list) - List of discrete singleton values on universe x whose membership function value is y. ``` -------------------------------- ### Create Rolling Window Views with view_as_windows Source: https://scikit-fuzzy.github.io/scikit-fuzzy/api/index.html Demonstrates creating overlapping window views for 2D and 1D arrays using the skfuzzy.view_as_windows function. ```python >>> import numpy as np >>> from skfuzzy import view_as_windows >>> A = np.arange(4*4).reshape(4,4) >>> A array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> window_shape = (2, 2) >>> B = view_as_windows(A, window_shape) >>> B[0, 0] array([[0, 1], [4, 5]]) >>> B[0, 1] array([[1, 2], [5, 6]]) ``` ```python >>> A = np.arange(10) >>> A array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> window_shape = (3,) >>> B = view_as_windows(A, window_shape) >>> B.shape (8, 3) >>> B array([[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]]) ``` ```python >>> A = np.arange(5*4).reshape(5, 4) >>> A array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19]]) >>> window_shape = (4, 3) >>> B = view_as_windows(A, window_shape) >>> B.shape (2, 2, 4, 3) >>> B array([[[[ 0, 1, 2], [ 4, 5, 6], [ 8, 9, 10], [12, 13, 14]], [[ 1, 2, 3], [ 5, 6, 7], [ 9, 10, 11], [13, 14, 15]]], [[[ 4, 5, 6], [ 8, 9, 10], [12, 13, 14], [16, 17, 18]], [[ 5, 6, 7], [ 9, 10, 11], [13, 14, 15], [17, 18, 19]]]]) ``` -------------------------------- ### Generate S-function Membership Function Source: https://scikit-fuzzy.github.io/scikit-fuzzy/api/index.html Generates an S-shaped fuzzy membership function. 'a' defines where the function starts climbing from zero, and 'b' is where it levels off at 1. ```python y = skfuzzy.smf(x, a, b) ``` -------------------------------- ### Configure Merge Summaries Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/configure_git.html Enabling merge logs via configuration file or command line. ```ini [merge] log = true ``` ```bash git config --global merge.log true ``` -------------------------------- ### Visualize Tip Membership Functions Source: https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html Visualizes all membership functions defined for the 'tip' Consequent. This shows the fuzzy sets for low, medium, and high tips. ```python tip.view() ``` -------------------------------- ### Create a feature branch Source: https://scikit-fuzzy.github.io/scikit-fuzzy/contribute.html Initialize a new branch for specific development tasks. ```bash git checkout -b transform-speedups ``` -------------------------------- ### Clone and configure upstream remote Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/set_up_fork.html Initial commands to clone a fork and add the upstream repository as a remote. ```bash git clone git@github.com:your-user-name/scikit-fuzzy.git cd scikit-fuzzy git remote add upstream git://github.com/scikit-fuzzy/scikit-fuzzy.git ``` -------------------------------- ### Apply Fuzzy Rules and Visualize Output Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_downloads/32bc9a350d105ab8730471aae5c8fa2d/plot_tipping_problem.ipynb Calculates membership levels for inputs, applies fuzzy rules using min/max operators, and visualizes the resulting output membership activity. ```python # We need the activation of our fuzzy membership functions at these values. # The exact values 6.5 and 9.8 do not exist on our universes... # This is what fuzz.interp_membership exists for! qual_level_lo = fuzz.interp_membership(x_qual, qual_lo, 6.5) qual_level_md = fuzz.interp_membership(x_qual, qual_md, 6.5) qual_level_hi = fuzz.interp_membership(x_qual, qual_hi, 6.5) serv_level_lo = fuzz.interp_membership(x_serv, serv_lo, 9.8) serv_level_md = fuzz.interp_membership(x_serv, serv_md, 9.8) serv_level_hi = fuzz.interp_membership(x_serv, serv_hi, 9.8) # Now we take our rules and apply them. Rule 1 concerns bad food OR service. # The OR operator means we take the maximum of these two. active_rule1 = np.fmax(qual_level_lo, serv_level_lo) # Now we apply this by clipping the top off the corresponding output # membership function with `np.fmin` tip_activation_lo = np.fmin(active_rule1, tip_lo) # removed entirely to 0 # For rule 2 we connect acceptable service to medium tipping tip_activation_md = np.fmin(serv_level_md, tip_md) # For rule 3 we connect high service OR high food with high tipping active_rule3 = np.fmax(qual_level_hi, serv_level_hi) tip_activation_hi = np.fmin(active_rule3, tip_hi) tip0 = np.zeros_like(x_tip) # Visualize this fig, ax0 = plt.subplots(figsize=(8, 3)) ax0.fill_between(x_tip, tip0, tip_activation_lo, facecolor='b', alpha=0.7) ax0.plot(x_tip, tip_lo, 'b', linewidth=0.5, linestyle='--', ) ax0.fill_between(x_tip, tip0, tip_activation_md, facecolor='g', alpha=0.7) ax0.plot(x_tip, tip_md, 'g', linewidth=0.5, linestyle='--') ax0.fill_between(x_tip, tip0, tip_activation_hi, facecolor='r', alpha=0.7) ax0.plot(x_tip, tip_hi, 'r', linewidth=0.5, linestyle='--') ax0.set_title('Output membership activity') # Turn off top/right axes for ax in (ax0,): ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) ax.get_xaxis().tick_bottom() ax.get_yaxis().tick_left() plt.tight_layout() ``` -------------------------------- ### Create Control System Simulation Instance Source: https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html Creates a ControlSystemSimulation instance from the defined control system. This object is used to provide specific inputs and compute the fuzzy system's output. ```python tipping = ctrl.ControlSystemSimulation(tipping_ctrl) ``` -------------------------------- ### Configure Git Aliases Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/configure_git.html Commands to create command aliases and the resulting configuration file section. ```bash git config --global alias.ci "commit -a" git config --global alias.co checkout git config --global alias.st "status -a" git config --global alias.stat "status -a" git config --global alias.br branch git config --global alias.wdiff "diff --color-words" ``` ```ini [alias] ci = commit -a co = checkout st = status -a stat = status -a br = branch wdiff = diff --color-words ``` -------------------------------- ### Global Git Configuration Commands Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/configure_git.html Commands to set global git configurations via the command line. ```bash git config --global user.name "Your Name" git config --global user.email you@yourdomain.example.com git config --global alias.ci "commit -a" git config --global alias.co checkout git config --global alias.st "status -a" git config --global alias.stat "status -a" git config --global alias.br branch git config --global alias.wdiff "diff --color-words" git config --global core.editor vim git config --global merge.summary true ``` -------------------------------- ### Explore repository history Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/development_workflow.html Tools for visualizing branches, commits, and repository history. ```bash gitk --all ``` ```bash git log ``` -------------------------------- ### Convert continuous-time system to discrete-time Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_modules/skfuzzy/fuzzymath/_continuous_to_discrete.html Uses matrix exponentiation and pseudo-inverse to calculate discrete system coefficients. Requires numpy and scipy.linalg. ```python import numpy as np import scipy.linalg [docs]def continuous_to_discrete(a, b, sampling_rate): """ Converts a continuous-time system to its equivalent discrete-time version. Parameters ---------- a : (N, N) array of floats State variable coefficients describing the continuous-time system. b : (N,) or (N, 1) array of floats Constant coefficients describing the continuous-time system. Can be either a rank-1 array or a rank-2 array of shape (N, 1). sampling_rate : float Rate in Hz at which the continuous-time system is to be sampled. Returns ------- phi : (N, N) array of floats Variable coefficients describing the discrete-time system. gamma : (N,) or (N, 1) array of floats Constant coefficients describing the discrete-time system. Shape of this output maintains the shape passed as `b`. """ a = a.astype(float) b = b.astype(float) phi = scipy.linalg.expm(a * sampling_rate) a_pinv = scipy.linalg.pinv2(a) gamma = np.dot(np.dot(a_pinv, phi - np.eye(a.shape[0])), b) return phi, gamma ``` -------------------------------- ### Execute fuzzy c-means clustering Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_modules/skfuzzy/cluster/_cmeans.html Main entry point for the fuzzy c-means clustering algorithm. Handles initialization and iterative optimization. ```python [docs]def cmeans(data, c, m, error, maxiter, metric='euclidean', init=None, seed=None): """ Fuzzy c-means clustering algorithm [1]. Parameters ---------- data : 2d array, size (S, N) Data to be clustered. N is the number of data sets; S is the number of features within each sample vector. c : int Desired number of clusters or classes. m : float Array exponentiation applied to the membership function u_old at each iteration, where U_new = u_old ** m. error : float Stopping criterion; stop early if the norm of (u[p] - u[p-1]) < error. maxiter : int Maximum number of iterations allowed. metric: string By default is set to euclidean. Passes any option accepted by ``scipy.spatial.distance.cdist``. init : 2d array, size (c, N) Initial fuzzy c-partitioned matrix. If none provided, algorithm is randomly initialized. seed : int If provided, sets random seed of init. No effect if init is provided. Mainly for debug/testing purposes. Returns ------- cntr : 2d array, size (c, S) Cluster centers. Data for each center along each feature provided for every cluster (of the `c` requested clusters). u : 2d array, (c, N) Final fuzzy c-partitioned matrix. u0 : 2d array, (c, N) Initial guess at fuzzy c-partitioned matrix (either provided init or random guess used if init was not provided). d : 2d array, (c, N) Final Euclidian distance matrix. jm : 1d array, length P Objective function history. p : int Number of iterations run. fpc : float Final fuzzy partition coefficient. Notes ----- The algorithm implemented is from Ross et al. [1]_. Fuzzy C-Means has a known problem with high dimensionality datasets, where the majority of cluster centers are pulled into the overall center of gravity. If you are clustering data with very high dimensionality and encounter this issue, another clustering method may be required. For more information and the theory behind this, see Winkler et al. [2]_. References ---------- .. [1] Ross, Timothy J. Fuzzy Logic With Engineering Applications, 3rd ed. Wiley. 2010. ISBN 978-0-470-74376-8 pp 352-353, eq 10.28 - 10.35. .. [2] Winkler, R., Klawonn, F., & Kruse, R. Fuzzy c-means in high dimensional spaces. 2012. Contemporary Theory and Pragmatic Approaches in Fuzzy Computing Utilization, 1. """ # Setup u0 if init is None: if seed is not None: np.random.seed(seed=seed) n = data.shape[1] u0 = np.random.rand(c, n) u0 = normalize_columns(u0) init = u0.copy() ``` -------------------------------- ### Verify remote repository URLs Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/set_up_fork.html Displays the configured fetch and push URLs for all remotes. ```bash upstream git://github.com/scikit-fuzzy/scikit-fuzzy.git (fetch) upstream git://github.com/scikit-fuzzy/scikit-fuzzy.git (push) origin git@github.com:your-user-name/scikit-fuzzy.git (fetch) origin git@github.com:your-user-name/scikit-fuzzy.git (push) ``` -------------------------------- ### Create 1D Sliding Windows Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_modules/skfuzzy/image/shape.html Shows how to create sliding windows from a 1D NumPy array. The output shape depends on the array length and window size. ```python >>> A = np.arange(10) >>> A array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> window_shape = (3,) >>> B = view_as_windows(A, window_shape) >>> B.shape (8, 3) >>> B array([[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]]) ``` -------------------------------- ### Import scikit-fuzzy Source: https://scikit-fuzzy.github.io/scikit-fuzzy/userguide/getting_started.html Import the scikit-fuzzy package. The recommended alias is 'fuzz'. ```python >>> import skfuzzy ``` ```python >>> import skfuzzy as fuzz ``` -------------------------------- ### Print and Visualize Fuzzy System Output Source: https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html Prints the computed crisp output value for 'tip' and visualizes the output membership function with the simulation results overlaid. This shows the aggregated fuzzy output and the final defuzzified crisp value. ```python print(tipping.output['tip']) tip.view(sim=tipping) ``` -------------------------------- ### view_as_windows Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_modules/skfuzzy/image/shape.html Creates a rolling window view of an n-dimensional array, where windows can overlap. ```APIDOC ## view_as_windows ### Description Provides a rolling window view of the input n-dimensional array. Windows are overlapping views of the input array, with adjacent windows shifted by a single element along one or more dimensions. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **arr_in** (ndarray) - The n-dimensional input array. - **window_shape** (tuple) - Defines the shape of the elementary n-dimensional orthotope (hyperrectangle) of the rolling window view. ### Request Example ```python import numpy as np from skfuzzy import view_as_windows A = np.arange(4*4).reshape(4,4) # Example usage would follow, but is truncated in the source. ``` ### Response #### Success Response (200) - **arr_out** (ndarray) - Rolling window view of the input array. #### Response Example (Example not fully provided in source) ### Notes Be cautious with memory usage, as rolling views can significantly increase the apparent size of data during computations compared to the original array. ``` -------------------------------- ### List local and remote branches Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/set_up_fork.html Displays the current branch and available remote connections. ```bash * master remotes/origin/master ``` -------------------------------- ### Link repository to upstream Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/set_up_fork.html Explicit commands to navigate to the repository and add the upstream remote. ```bash cd scikit-fuzzy git remote add upstream git://github.com/scikit-fuzzy/scikit-fuzzy.git ``` -------------------------------- ### Set User Identity Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/configure_git.html Commands and resulting configuration snippet for setting user name and email. ```bash git config --global user.name "Your Name" git config --global user.email you@yourdomain.example.com ``` ```ini [user] name = Your Name email = you@yourdomain.example.com ``` -------------------------------- ### Create and checkout a new feature branch Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/development_workflow.html Initializes a new branch based on the current upstream master and switches to it. ```bash # Update the mirror of trunk git fetch upstream # Make new feature branch starting at current trunk git branch my-new-feature upstream/master git checkout my-new-feature ``` -------------------------------- ### Create 2D Sliding Windows Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_modules/skfuzzy/image/shape.html Demonstrates creating sliding windows of a specified shape from a 2D NumPy array. Useful for operations requiring local neighborhoods. ```python >>> A = np.arange(5*4).reshape(5, 4) >>> A array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19]]) >>> window_shape = (4, 3) >>> B = view_as_windows(A, window_shape) >>> B.shape (2, 2, 4, 3) >>> B # doctest: +NORMALIZE_WHITESPACE array([[[[ 0, 1, 2], [ 4, 5, 6], [ 8, 9, 10], [12, 13, 14]], [[ 1, 2, 3], [ 5, 6, 7], [ 9, 10, 11], [13, 14, 15]]], [[[ 4, 5, 6], [ 8, 9, 10], [12, 13, 14], [16, 17, 18]], [[ 5, 6, 7], [ 9, 10, 11], [13, 14, 15], [17, 18, 19]]]]) ``` -------------------------------- ### Switch Back to Master Branch Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/patching.html Return to the main branch of the repository after completing your work. ```bash git checkout master ``` -------------------------------- ### Clone scikit-fuzzy Repository Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/patching.html Obtain a local copy of the scikit-fuzzy repository if you don't already have one. Navigate into the cloned directory. ```bash git clone git://github.com/scikit-fuzzy/scikit-fuzzy.git cd scikit-fuzzy ``` -------------------------------- ### Accessing Sliding Windows Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_modules/skfuzzy/image/shape.html Illustrates how to access individual sliding windows from a 2D array after they have been created. This is useful for inspecting specific local regions. ```python >>> A = np.arange(16).reshape(4, 4) >>> A array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> window_shape = (2, 2) >>> B = view_as_windows(A, window_shape) >>> B[0, 0] array([[0, 1], [4, 5]]) >>> B[0, 1] array([[1, 2], [5, 6]]) ``` -------------------------------- ### Simulate Control System Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_downloads/73d25e9f2afeb5023afbb7a96cf89e33/plot_tipping_problem_newapi.ipynb Create a ControlSystemSimulation object to represent the controller applied to specific circumstances. Inputs can be set using Antecedent labels, and the .compute() method runs the simulation. ```python tipping = ctrl.ControlSystemSimulation(tipping_ctrl) tipping.input['quality'] = 6.5 tipping.input['service'] = 9.8 # Crunch the numbers tipping.compute() ``` -------------------------------- ### Visualize Service Membership Functions Source: https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html Visualizes all membership functions defined for the 'service' Antecedent. This provides a graphical representation of the fuzzy sets for service quality. ```python service.view() ``` -------------------------------- ### Visualize Output Membership Activity Source: https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_tipping_problem.html Visualizes the activity of different output membership functions. Ensure matplotlib and numpy are imported. ```python fig, ax0 = plt.subplots(figsize=(8, 3)) ax0.fill_between(x_tip, tip0, tip_activation_lo, facecolor='b', alpha=0.7) ax0.plot(x_tip, tip_lo, 'b', linewidth=0.5, linestyle='--', ) ax0.fill_between(x_tip, tip0, tip_activation_md, facecolor='g', alpha=0.7) ax0.plot(x_tip, tip_md, 'g', linewidth=0.5, linestyle='--') ax0.fill_between(x_tip, tip0, tip_activation_hi, facecolor='r', alpha=0.7) ax0.plot(x_tip, tip_hi, 'r', linewidth=0.5, linestyle='--') ax0.set_title('Output membership activity') # Turn off top/right axes for ax in (ax0,): ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) ax.get_xaxis().tick_bottom() ax.get_yaxis().tick_left() plt.tight_layout() ``` -------------------------------- ### Add Fork as Origin Remote Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/patching.html Configure your local repository to point to your fork on GitHub as the 'origin' remote for pushing changes. ```bash # point your repo to default read / write to your fork on github git remote add origin git@github.com:your-user-name/scikit-fuzzy.git ``` -------------------------------- ### Standard editing and commit workflow Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/development_workflow.html Common sequence for staging changes, committing them with a message, and pushing to the remote repository. ```bash # hack hack git add my_new_file git commit -am 'NF - some message' git push ``` -------------------------------- ### Stage and Commit Changes Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/patching.html Add new files to Git tracking and commit your work in progress. Use the '-am' flags to add all changes and provide a commit message. ```bash # hack, hack, hack # Tell git about any new files you've made git add somewhere/tests/test_my_bug.py # commit work in progress as you go git commit -am 'BF - added tests for Funny bug' # hack hack, hack git commit -am 'BF - added fix for Funny bug' ``` -------------------------------- ### Initialize Fuzzy Control Variables Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_downloads/8602739f4db656fd0145795ecb773c5e/plot_control_system_advanced.ipynb Sets up the universe of discourse and defines fuzzy Antecedent and Consequent variables with automated membership functions. ```python import numpy as np import skfuzzy.control as ctrl # Sparse universe makes calculations faster, without sacrifice accuracy. # Only the critical points are included here; making it higher resolution is # unnecessary. universe = np.linspace(-2, 2, 5) # Create the three fuzzy variables - two inputs, one output error = ctrl.Antecedent(universe, 'error') delta = ctrl.Antecedent(universe, 'delta') output = ctrl.Consequent(universe, 'output') # Here we use the convenience `automf` to populate the fuzzy variables with # terms. The optional kwarg `names=` lets us specify the names of our Terms. names = ['nb', 'ns', 'ze', 'ps', 'pb'] error.automf(names=names) delta.automf(names=names) output.automf(names=names) ``` -------------------------------- ### Initialize Fuzzy Variables Source: https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_control_system_advanced.html Sets up the universe of discourse and defines antecedent and consequent fuzzy variables using the scikit-fuzzy control API. ```python import numpy as np import skfuzzy.control as ctrl # Sparse universe makes calculations faster, without sacrifice accuracy. # Only the critical points are included here; making it higher resolution is # unnecessary. universe = np.linspace(-2, 2, 5) # Create the three fuzzy variables - two inputs, one output error = ctrl.Antecedent(universe, 'error') delta = ctrl.Antecedent(universe, 'delta') output = ctrl.Consequent(universe, 'output') # Here we use the convenience `automf` to populate the fuzzy variables with # terms. The optional kwarg `names=` lets us specify the names of our Terms. names = ['nb', 'ns', 'ze', 'ps', 'pb'] error.automf(names=names) delta.automf(names=names) output.automf(names=names) ``` -------------------------------- ### Clone and commit to a shared repository Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/development_workflow.html Commands for cloning a shared repository and pushing commits directly to the master branch. ```bash git clone git@githhub.com:your-user-name/scikit-fuzzy.git ``` ```bash git commit -am 'ENH - much better code' git push origin master # pushes directly into your repo ``` -------------------------------- ### Configure Git User Information Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/patching.html Set your email and name for Git commits. This is essential for identifying your contributions. ```bash git config --global user.email you@yourdomain.example.com git config --global user.name "Your Name Comes Here" ``` -------------------------------- ### Print and Visualize Fuzzy Output Source: https://scikit-fuzzy.github.io/scikit-fuzzy/_downloads/73d25e9f2afeb5023afbb7a96cf89e33/plot_tipping_problem_newapi.ipynb Displays the numerical output of the tipping simulation and generates a plot of the result. ```python print(tipping.output['tip']) tip.view(sim=tipping) ``` -------------------------------- ### Import Scikit-Fuzzy Source: https://scikit-fuzzy.github.io/scikit-fuzzy/api/index.html Standard import for accessing the library functionality. ```python >>> import skfuzzy as fuzz ``` -------------------------------- ### Push Local Branches to Fork Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/patching.html Upload any feature branches you have created and wish to keep to your fork on GitHub. ```bash # push up any branches you've made and want to keep git push origin the-fix-im-thinking-of ``` -------------------------------- ### Interactive Rebase Configuration Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/development_workflow.html The default text displayed in the editor during an interactive rebase session. ```text pick 13d7934 First implementation pick 2dec1ac Fix a few bugs + disable pick a815645 Modify it so that it works pick eadc391 Fix some remaining bugs # Rebase 6ad92e5..eadc391 onto 6ad92e5 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. # ``` -------------------------------- ### Generate Patch Files Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/patching.html Create patch files from your commits since the 'master' branch. These files can be sent for review. ```bash git format-patch -M -C master ``` -------------------------------- ### View Commit History Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/development_workflow.html Display a concise list of recent commits. ```bash git log --oneline ``` -------------------------------- ### Set Default Editor Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/configure_git.html Command to set the default text editor for git. ```bash git config --global core.editor vim ``` -------------------------------- ### Create Fuzzy Control System Source: https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html Creates a control system object by passing a list of defined fuzzy rules. This aggregates the rules into a single system that can be simulated. ```python tipping_ctrl = ctrl.ControlSystem([rule1, rule2, rule3]) ``` -------------------------------- ### Fancy Log Alias Source: https://scikit-fuzzy.github.io/scikit-fuzzy/gitwash/configure_git.html Configuration and usage for a custom graph-based log output. ```ini lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)[%an]%Creset' --abbrev-commit --date=relative ``` ```bash git lg ``` ```text * 6d8e1ee - (HEAD, origin/my-fancy-feature, my-fancy-feature) NF - a fancy file (45 minutes ago) [Matthew Brett] * d304a73 - (origin/placeholder, placeholder) Merge pull request #48 from hhuuggoo/master (2 weeks ago) [Jonathan Terhorst] |\ | * 4aff2a8 - fixed bug 35, and added a test in test_bugfixes (2 weeks ago) [Hugo] |/ * a7ff2e5 - Added notes on discussion/proposal made during Data Array Summit. (2 weeks ago) [Corran Webster] * 68f6752 - Initial implimentation of AxisIndexer - uses 'index_by' which needs to be changed to a call on an Axes object - this is all very sketchy right now. (2 weeks ago) [Corr * 376adbd - Merge pull request #46 from terhorst/master (2 weeks ago) [Jonathan Terhorst] |\ | * b605216 - updated joshu example to current api (3 weeks ago) [Jonathan Terhorst] | * 2e991e8 - add testing for outer ufunc (3 weeks ago) [Jonathan Terhorst] | * 7beda5a - prevent axis from throwing an exception if testing equality with non-axis object (3 weeks ago) [Jonathan Terhorst] | * 65af65e - convert unit testing code to assertions (3 weeks ago) [Jonathan Terhorst] | * 956fbab - Merge remote-tracking branch 'upstream/master' (3 weeks ago) [Jonathan Terhorst] | |\ | |/ ``` -------------------------------- ### Pad array with reflection Source: https://scikit-fuzzy.github.io/scikit-fuzzy/api/index.html Pads an array using reflection, with optional even or odd types. ```python >>> a = [1, 2, 3, 4, 5] >>> np.pad(a, (2, 3), 'reflect') array([3, 2, 1, 2, 3, 4, 5, 4, 3, 2]) ``` ```python >>> np.pad(a, (2, 3), 'reflect', reflect_type='odd') array([-1, 0, 1, 2, 3, 4, 5, 6, 7, 8]) ```