<jupyter_start><jupyter_text>INT 246 Project By <NAME> (11903126)<jupyter_code>!pip install scikit-fuzzy

import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl
pH = ctrl.Antecedent(np.arange(0,15,1),'pH')
flowrate = ctrl.Antecedent(np.arange(0,110,10),'flowrate')
acidvalve = ctrl.Consequent(np.arange(0,15,1),'acidvalve')
basevalve = ctrl.Consequent(np.arange(0,15,1),'basevalve')
pH['Acid'] = fuzz.trimf(pH.universe,[0,1,7])
pH['Good'] = fuzz.trimf(pH.universe,[6,7,8])
pH['Base'] = fuzz.trimf(pH.universe,[7,13,14])
pH.view()
flowrate.automf(3)
flowrate.view()
basevalve['Close'] = fuzz.trimf(pH.universe,[6,7,14])
basevalve['LittleOpen'] = fuzz.trimf(pH.universe,[4,5,7])
basevalve['HalfOpen'] = fuzz.trimf(pH.universe,[2,3,6])
basevalve['FullOpen'] = fuzz.trimf(pH.universe,[0,1,4])
basevalve.view()
acidvalve['Close'] = fuzz.trimf(pH.universe,[0,7,8])
acidvalve['LittleOpen'] = fuzz.trimf(pH.universe,[8,9,10])
acidvalve['HalfOpen'] = fuzz.trimf(pH.universe,[8,11,12])
acidvalve['FullOpen'] = fuzz.trimf(pH.universe,[10,12,14])
acidvalve.view()
rule1 = ctrl.Rule(pH['Acid'] & flowrate['poor'] , (basevalve['LittleOpen'] , acidvalve['Close']))
rule2 = ctrl.Rule(pH['Acid'] & flowrate['average'] , (basevalve['HalfOpen'], acidvalve['Close']))
rule3 = ctrl.Rule(pH['Acid'] & flowrate['good'], (basevalve['FullOpen'], acidvalve['Close']))
rule4 = ctrl.Rule(pH['Good'] & flowrate['poor'], (basevalve['Close'], acidvalve['Close']))
rule5 = ctrl.Rule(pH['Good'] & flowrate['average'], (basevalve['Close'], acidvalve['Close']))
rule6 = ctrl.Rule(pH['Good'] & flowrate['good'], (basevalve['Close'], acidvalve['Close']))
rule7 = ctrl.Rule(pH['Base'] & flowrate['poor'], (basevalve['Close'], acidvalve['LittleOpen']))
rule8 = ctrl.Rule(pH['Base'] & flowrate['average'],( basevalve['Close'], acidvalve['HalfOpen']))
rule9 = ctrl.Rule(pH['Base'] & flowrate['good'], (basevalve['Close'], acidvalve['FullOpen']))
pH_ctrl = ctrl.ControlSystem([rule1,rule2,rule3,rule4,rule5,rule6,rule7,rule8,rule9])
pH_controling = ctrl.ControlSystemSimulation(pH_ctrl)
pH_controling.input['pH'] = 2
pH_controling.input['flowrate'] = 90
pH_controling.compute()
print(pH_controling.output)<jupyter_output>OrderedDict([('basevalve', 2.2293785310734457), ('acidvalve', 4.9333333333333345)])
{'fraction_non_alphanumeric': 0.22275711159737419, 'fraction_numerical': 0.05557986870897155, 'mean_word_length': 9.937799043062201, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '574057', 'license': 'MIT', 'n_tokens_mistral': 1030, 'n_tokens_neox': 903, 'n_words': 115, 'path': 'ph_Nutralisation.ipynb', 'repo_name': 'ssharanyab/ph-Nutralisation', 'size': '2300'}