pucktrick 0.1__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.
pucktrick-0.1/LICENCE ADDED
@@ -0,0 +1,79 @@
1
+ Attribution-NonCommercial 4.0 International
2
+ By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
3
+
4
+ Section 1 – Definitions.
5
+ Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
6
+ Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
7
+ Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
8
+ Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
9
+ Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
10
+ Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
11
+ Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
12
+ Licensor means the individual(s) or entity(ies) granting rights under this Public License.
13
+ NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
14
+ Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
15
+ Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
16
+ You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
17
+ Section 2 – Scope.
18
+ License grant .
19
+ Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
20
+ reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
21
+ produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
22
+ Exceptions and Limitations . For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
23
+ Term . The term of this Public License is specified in Section 6(a) .
24
+ Media and formats; technical modifications allowed . The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
25
+ Downstream recipients .
26
+ Offer from the Licensor – Licensed Material . Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
27
+ No downstream restrictions . You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
28
+ No endorsement . Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i) .
29
+ Other rights .
30
+ Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
31
+ Patent and trademark rights are not licensed under this Public License.
32
+ To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
33
+ Section 3 – License Conditions.
34
+ Your exercise of the Licensed Rights is expressly made subject to the following conditions.
35
+
36
+ Attribution .
37
+ If You Share the Licensed Material (including in modified form), You must:
38
+
39
+ retain the following if it is supplied by the Licensor with the Licensed Material:
40
+ identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
41
+ a copyright notice;
42
+ a notice that refers to this Public License;
43
+ a notice that refers to the disclaimer of warranties;
44
+ a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
45
+ indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
46
+ indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
47
+ You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
48
+ If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
49
+ If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
50
+ Section 4 – Sui Generis Database Rights.
51
+ Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
52
+
53
+ for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
54
+ if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
55
+ You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
56
+ For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
57
+
58
+ Section 5 – Disclaimer of Warranties and Limitation of Liability.
59
+ Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
60
+ To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
61
+ The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
62
+ Section 6 – Term and Termination.
63
+ This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
64
+ Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
65
+
66
+ automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
67
+ upon express reinstatement by the Licensor.
68
+ For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
69
+
70
+ For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
71
+ Sections 1 , 5 , 6 , 7 , and 8 survive termination of this Public License.
72
+ Section 7 – Other Terms and Conditions.
73
+ The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
74
+ Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
75
+ Section 8 – Interpretation.
76
+ For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
77
+ To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
78
+ No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
79
+ Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
pucktrick-0.1/PKG-INFO ADDED
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.1
2
+ Name: pucktrick
3
+ Version: 0.1
4
+ Summary: A python library for error genration in dataset for machine learning
5
+ Home-page: https://github.com/andreamaurino/pucktrick
6
+ Author: Andrea Maurino
7
+ Author-email: andrea.maurino@unimib.it
8
+ License: CC BY-NC 4.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: Other/Proprietary License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENCE
15
+
16
+ # pucktrick
17
+
18
+ Pucktrick is a Python library that provides various utility functions to introduce errors in your dataframe.
19
+ The name of library is based on Puck. Puck is the name of the elf in the “A midsummer Night’s dream” of William Shakespeare that is very famous to enjoys causing trouble and playing tricks on mortals and other fairies alike.
20
+
21
+
22
+ ## Features
23
+ pucktrick is organized in modules, one per evary error type
24
+
25
+ each module inlude function whose name follows this syntax
26
+ errornametypeDataTYpeTypePercentuageOther where
27
+ - errornameType: noisy, inconsitency labels, outlier,
28
+ - DataTYpe: continous, discrete, ….
29
+ - Typepercentuage, (New add new error in the dataframe, Extend add more errors in a prexisting dataframe made dirty by pucktrick,
30
+ - Other: eg. fakeValues in case the function add fake values, and so on
31
+
32
+
33
+ ## Version
34
+ version 0.1
35
+
36
+ - error type inserted: noisy error and inconsistencylabels
37
+
38
+
39
+ ## Installation
40
+
41
+ You can install pucktrick using pip:
42
+
43
+ pip install pucktrick
44
+
45
+ ## Usage
46
+ to be done
47
+
48
+ ## References
49
+
50
+ ## Contributing
51
+ We welcome contributions from the community. To contribute:
52
+
53
+ Fork the repository
54
+ Create a new branch (git checkout -b feature/your-feature)
55
+ Commit your changes (git commit -am 'Add new feature')
56
+ Push to the branch (git push origin feature/your-feature)
57
+ Create a new Pull Request
58
+ Please ensure your code adheres to our coding standards and includes appropriate tests.
59
+
60
+ License
61
+ This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) - see the LICENSE file for details.
62
+
63
+ Acknowledgements
64
+ Thanks to the contributors and open-source community for their support.
@@ -0,0 +1,49 @@
1
+ # pucktrick
2
+
3
+ Pucktrick is a Python library that provides various utility functions to introduce errors in your dataframe.
4
+ The name of library is based on Puck. Puck is the name of the elf in the “A midsummer Night’s dream” of William Shakespeare that is very famous to enjoys causing trouble and playing tricks on mortals and other fairies alike.
5
+
6
+
7
+ ## Features
8
+ pucktrick is organized in modules, one per evary error type
9
+
10
+ each module inlude function whose name follows this syntax
11
+ errornametypeDataTYpeTypePercentuageOther where
12
+ - errornameType: noisy, inconsitency labels, outlier,
13
+ - DataTYpe: continous, discrete, ….
14
+ - Typepercentuage, (New add new error in the dataframe, Extend add more errors in a prexisting dataframe made dirty by pucktrick,
15
+ - Other: eg. fakeValues in case the function add fake values, and so on
16
+
17
+
18
+ ## Version
19
+ version 0.1
20
+
21
+ - error type inserted: noisy error and inconsistencylabels
22
+
23
+
24
+ ## Installation
25
+
26
+ You can install pucktrick using pip:
27
+
28
+ pip install pucktrick
29
+
30
+ ## Usage
31
+ to be done
32
+
33
+ ## References
34
+
35
+ ## Contributing
36
+ We welcome contributions from the community. To contribute:
37
+
38
+ Fork the repository
39
+ Create a new branch (git checkout -b feature/your-feature)
40
+ Commit your changes (git commit -am 'Add new feature')
41
+ Push to the branch (git push origin feature/your-feature)
42
+ Create a new Pull Request
43
+ Please ensure your code adheres to our coding standards and includes appropriate tests.
44
+
45
+ License
46
+ This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) - see the LICENSE file for details.
47
+
48
+ Acknowledgements
49
+ Thanks to the contributors and open-source community for their support.
File without changes
@@ -0,0 +1,26 @@
1
+ from pucktrick.utils import *
2
+ from pucktrick.binary import *
3
+ from pucktrick.categorical import *
4
+
5
+ def wrongLabelsBinaryExtended(original_df, train_df,column,percentage):
6
+ noise_df= train_df.copy()
7
+ noise_df['id1'] = range(len(noise_df))
8
+ new_df,newPercentage=generateSubdf(original_df, noise_df,column,percentage)
9
+ if newPercentage==0:
10
+ return train_df
11
+ modified_df= noiseBinaryNew(new_df,column,newPercentage)
12
+ noise_df=mergeDataframe(noise_df,modified_df)
13
+ noise_df[column] = noise_df[column].fillna(0)
14
+ return noise_df
15
+
16
+ def wrongLabelsBinaryNew(train_df,target,percentage):
17
+ noise_df=noiseBinaryNew(train_df,target,percentage)
18
+ return noise_df
19
+
20
+ def wrongLabelsCategoricalNew(train_df,target,percentage):
21
+ noise_df=noiseCategoricalIntNewExistingValues(train_df,target,percentage)
22
+ return noise_df
23
+
24
+ def wrongLabelsBinaryNew(train_df,target,percentage):
25
+ noise_df=noiseCategoricalIntExtendedExistingValues(train_df,target,percentage)
26
+ return noise_df
@@ -0,0 +1,144 @@
1
+ from pucktrick.utils import *
2
+ from pucktrick.noisy import *
3
+ import pandas as pd
4
+
5
+
6
+ def noiseCategoricalStringNewExistingValues(train_df,column,percentage):
7
+ extracted_list=sampleList(percentage,len(train_df[column]))
8
+ noise_df= train_df.copy()
9
+ unique_values = noise_df[column].unique()
10
+ for i, value in enumerate(extracted_list):
11
+ while True:
12
+ new_value=np.random.choice(unique_values)
13
+ if new_value != noise_df.loc[i, column]:
14
+ noise_df.loc[i, column] = new_value
15
+ break
16
+ return noise_df
17
+
18
+
19
+
20
+
21
+ def noiseCategoricalStringExtendedExistingValues(original_df, train_df,column,percentage):
22
+ noise_df= train_df.copy()
23
+ noise_df['id1'] = range(len(noise_df))
24
+ new_df,newPercentage=generateSubdf(original_df, noise_df,column,percentage)
25
+ if newPercentage==0:
26
+ return train_df
27
+ modified_df= noiseCategoricalStringNewExistingValues(new_df,column,newPercentage)
28
+ noise_df=mergeDataframe(noise_df,modified_df)
29
+ return noise_df
30
+
31
+ def noiseCategoricalStringNewFakeValues(train_df,column,percentage):
32
+ extracted_list=sampleList(percentage,len(train_df[column]))
33
+ noise_df= train_df.copy()
34
+ unique_values = noise_df[column].unique()
35
+ for i, value in enumerate(extracted_list):
36
+ noise_df.loc[i, column] = ''.join(np.random.choice(list('abcdefghijklmnopqrstuvwxyz'), size=5))
37
+ return noise_df
38
+
39
+ def noiseCategoricalStringExstendedFakeValues(original_df, train_df,column,percentage):
40
+ noise_df= train_df.copy()
41
+ noise_df['id1'] = range(len(noise_df))
42
+ new_df,newPercentage=generateSubdf(original_df, noise_df,column,percentage)
43
+ if newPercentage==0:
44
+ return train_df
45
+ modified_df= noiseCategoricalStringNewFakeValues(new_df,column,newPercentage)
46
+ noise_df=mergeDataframe(noise_df,modified_df)
47
+ return noise_df
48
+
49
+ def noiseCategoricalIntNewExistingValues(train_df,column,percentage):
50
+ extracted_list=sampleList(percentage,len(train_df[column]))
51
+ noise_df= train_df.copy()
52
+ unique_values = noise_df[column].unique()
53
+ for i, value in enumerate(extracted_list):
54
+ while True:
55
+ new_value=np.random.choice(unique_values)
56
+ if new_value != noise_df.loc[i, column]:
57
+ noise_df.loc[i, column] = new_value
58
+ break
59
+ return noise_df
60
+
61
+ def noiseCategoricalIntExtendedExistingValues(original_df, train_df,column,percentage):
62
+ noise_df= train_df.copy()
63
+ noise_df['id1'] = range(len(noise_df))
64
+ new_df,newPercentage=generateSubdf(original_df, noise_df,column,percentage)
65
+ if newPercentage==0:
66
+ return train_df
67
+ modified_df= noiseCategoricalStringNewExistingValues(new_df,column,newPercentage)
68
+ noise_df=mergeDataframe(noise_df,modified_df)
69
+ return noise_df
70
+
71
+
72
+
73
+ def noiseDiscreteExtended(original_df, train_df,column,percentage):
74
+ noise_df= train_df.copy()
75
+ noise_df['id1'] = range(len(noise_df))
76
+ new_df,newPercentage=generateSubdf(original_df, noise_df,column,percentage)
77
+ if newPercentage==0:
78
+ return train_df
79
+ modified_df= noiseDiscreteNew(new_df,column,newPercentage)
80
+ noise_df=mergeDataframe(noise_df,modified_df)
81
+ return noise_df
82
+
83
+
84
+ def noiseDiscreteNew(train_df,column,percentage):
85
+ extracted_list=sampleList(percentage,len(train_df[column]))
86
+ noise_df= train_df.copy()
87
+ min = noise_df[column].min()
88
+ max = noise_df[column].max()
89
+
90
+ for i, value in enumerate(extracted_list):
91
+ while True:
92
+ new_value=random.randint(min,max)
93
+ if new_value != noise_df.loc[i, column]:
94
+ noise_df.loc[i, column] = new_value
95
+ break
96
+ return noise_df
97
+
98
+
99
+ def noiseBinaryNew(train_df,target,percentage):
100
+ noise_df= train_df.copy()
101
+ extracted_list=sampleList(percentage,len(noise_df[target])-1)
102
+ for i, value in enumerate(extracted_list):
103
+ if pd.isna(noise_df.loc[i, target]):
104
+ noise_df.loc[i, target]=0
105
+ else:
106
+ existingValue=noise_df.loc[i, target]
107
+ noise_df.loc[i, target]=1-existingValue
108
+ return noise_df
109
+
110
+ def noiseBinaryExtended(original_df, train_df,column,percentage):
111
+ noise_df= train_df.copy()
112
+ noise_df['id1'] = range(len(noise_df))
113
+ new_df,newPercentage=generateSubdf(original_df, noise_df,column,percentage)
114
+ if newPercentage==0:
115
+ return train_df
116
+ modified_df= noiseBinaryNew(new_df,column,newPercentage)
117
+ noise_df=mergeDataframe(noise_df,modified_df)
118
+ return noise_df
119
+ def noiseContinueExtended(original_df, train_df,column,percentage):
120
+ noise_df= train_df.copy()
121
+ noise_df['id1'] = range(len(noise_df))
122
+ new_df,newPercentage=generateSubdf(original_df, noise_df,column,percentage)
123
+ if newPercentage==0:
124
+ return train_df
125
+ modified_df= noiseContinueNew(new_df,column,newPercentage)
126
+ noise_df=mergeDataframe(noise_df,modified_df)
127
+ return noise_df
128
+
129
+
130
+ def noiseContinueNew(train_df,column,percentage):
131
+ extracted_list=sampleList(percentage,len(train_df[column]))
132
+ noise_df= train_df.copy()
133
+ min = noise_df[column].min()
134
+ max = noise_df[column].max()
135
+
136
+ for i, value in enumerate(extracted_list):
137
+ while True:
138
+ new_value=random.uniform(min,max)
139
+ if new_value != noise_df.loc[i, column]:
140
+ noise_df.loc[i, column] = new_value
141
+ break
142
+ return noise_df
143
+
144
+
@@ -0,0 +1,35 @@
1
+ import random
2
+ import numpy as np
3
+
4
+
5
+ def sampleList(percentage, maxValueList ):
6
+ values = int(maxValueList * (percentage))
7
+ extracted_List= random.sample(range(1, maxValueList+ 1), values)
8
+ return extracted_List
9
+
10
+ def generateSubdf(original_df, train_df,column,percentage ):
11
+ rowsToChange=len(original_df[column])*percentage
12
+ dif = original_df[column] != train_df[column]
13
+ diff_number = dif.sum()
14
+ new_rowsToChange=rowsToChange-diff_number
15
+ if new_rowsToChange<=0:
16
+ newPercentage=0
17
+ return train_df,newPercentage
18
+ noise_df= train_df.copy()
19
+ noise_df['id1'] = range(len(noise_df))
20
+ or_df=original_df.copy()
21
+ or_df['id1'] = range(len(or_df))
22
+ mask = or_df[column] == noise_df[column]
23
+ new_df = noise_df[mask]
24
+ new_df = new_df.reset_index(drop=True)
25
+ newPercentage=new_rowsToChange/len(new_df)
26
+ return new_df,newPercentage
27
+
28
+ def mergeDataframe(noise_df,modified_df):
29
+
30
+ merged_df = noise_df.merge(modified_df, on='id1', how='left', suffixes=('_df1', '_df2'))
31
+ new_array = [string for string in noise_df.columns if string != 'id1']
32
+ for col in new_array:
33
+ noise_df[col] = merged_df[col + '_df2'].fillna(merged_df[col + '_df1'])
34
+ noise_df = noise_df.drop('id1', axis=1)
35
+ return noise_df
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.1
2
+ Name: pucktrick
3
+ Version: 0.1
4
+ Summary: A python library for error genration in dataset for machine learning
5
+ Home-page: https://github.com/andreamaurino/pucktrick
6
+ Author: Andrea Maurino
7
+ Author-email: andrea.maurino@unimib.it
8
+ License: CC BY-NC 4.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: Other/Proprietary License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENCE
15
+
16
+ # pucktrick
17
+
18
+ Pucktrick is a Python library that provides various utility functions to introduce errors in your dataframe.
19
+ The name of library is based on Puck. Puck is the name of the elf in the “A midsummer Night’s dream” of William Shakespeare that is very famous to enjoys causing trouble and playing tricks on mortals and other fairies alike.
20
+
21
+
22
+ ## Features
23
+ pucktrick is organized in modules, one per evary error type
24
+
25
+ each module inlude function whose name follows this syntax
26
+ errornametypeDataTYpeTypePercentuageOther where
27
+ - errornameType: noisy, inconsitency labels, outlier,
28
+ - DataTYpe: continous, discrete, ….
29
+ - Typepercentuage, (New add new error in the dataframe, Extend add more errors in a prexisting dataframe made dirty by pucktrick,
30
+ - Other: eg. fakeValues in case the function add fake values, and so on
31
+
32
+
33
+ ## Version
34
+ version 0.1
35
+
36
+ - error type inserted: noisy error and inconsistencylabels
37
+
38
+
39
+ ## Installation
40
+
41
+ You can install pucktrick using pip:
42
+
43
+ pip install pucktrick
44
+
45
+ ## Usage
46
+ to be done
47
+
48
+ ## References
49
+
50
+ ## Contributing
51
+ We welcome contributions from the community. To contribute:
52
+
53
+ Fork the repository
54
+ Create a new branch (git checkout -b feature/your-feature)
55
+ Commit your changes (git commit -am 'Add new feature')
56
+ Push to the branch (git push origin feature/your-feature)
57
+ Create a new Pull Request
58
+ Please ensure your code adheres to our coding standards and includes appropriate tests.
59
+
60
+ License
61
+ This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) - see the LICENSE file for details.
62
+
63
+ Acknowledgements
64
+ Thanks to the contributors and open-source community for their support.
@@ -0,0 +1,13 @@
1
+ LICENCE
2
+ README.md
3
+ setup.py
4
+ pucktrick/__init__.py
5
+ pucktrick/labels.py
6
+ pucktrick/noisy.py
7
+ pucktrick/utils.py
8
+ pucktrick.egg-info/PKG-INFO
9
+ pucktrick.egg-info/SOURCES.txt
10
+ pucktrick.egg-info/dependency_links.txt
11
+ pucktrick.egg-info/requires.txt
12
+ pucktrick.egg-info/top_level.txt
13
+ tests/test_categorical.py
@@ -0,0 +1 @@
1
+ numpy
@@ -0,0 +1 @@
1
+ pucktrick
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
pucktrick-0.1/setup.py ADDED
@@ -0,0 +1,22 @@
1
+ # setup.py
2
+ from setuptools import setup, find_packages
3
+
4
+ setup(
5
+ name="pucktrick",
6
+ version="0.1",
7
+ packages=find_packages(),
8
+ install_requires=["numpy"],
9
+ author="Andrea Maurino",
10
+ author_email="andrea.maurino@unimib.it",
11
+ description="A python library for error genration in dataset for machine learning",
12
+ long_description=open("README.md", encoding="utf-8").read(),
13
+ long_description_content_type="text/markdown",
14
+ url="https://github.com/andreamaurino/pucktrick",
15
+ classifiers=[
16
+ "Programming Language :: Python :: 3",
17
+ "License :: Other/Proprietary License",
18
+ "Operating System :: OS Independent",
19
+ ],
20
+ python_requires='>=3.6',
21
+ license="CC BY-NC 4.0",
22
+ )
@@ -0,0 +1,46 @@
1
+ import unittest
2
+ from pucktrick.noisy import *
3
+ import pandas as pd
4
+ from pandas.testing import assert_frame_equal
5
+ class TestCategorical(unittest.TestCase):
6
+ def test_saluta(self):
7
+ percentage=0.5
8
+ num_rows = 1000
9
+ fake_df=create_fake_table()
10
+ column='f2'
11
+ noise_df=noiseCategoricalStringNewFakeValues(fake_df,column,percentage)
12
+ print(noise_df)
13
+ dif = fake_df[column] != noise_df[column]
14
+ diff_number = dif.sum()
15
+ noise_df=noiseCategoricalStringExstendedFakeValues(fake_df,noise_df,column,percentage)
16
+ dif = fake_df[column] != noise_df[column]
17
+ diff_number = dif.sum()
18
+ diff_p=diff_number/num_rows
19
+
20
+ # Verifica che il numero di modifiche sia corretto
21
+ self.assertEqual(diff_p, percentage)
22
+
23
+
24
+ def create_fake_table():
25
+ num_rows = 1000
26
+ # Generate data for each column
27
+ f1 = np.random.uniform(-100, 100, num_rows) # Continuous values between -100 and 100
28
+ f2 = np.random.randint(-100, 101, num_rows) # Discrete values between -100 and 100
29
+ f3 = np.random.choice(['apple', 'banana', 'cherry'], num_rows) # String values
30
+ f4 = np.random.choice(['apple', 'banana', 'cherry'], num_rows) # String values
31
+ f5 = np.random.choice([0, 1], num_rows) # Binary values (0 or 1)
32
+ target = np.random.choice([0, 1], num_rows) # Binary target (0 or 1)
33
+
34
+ # Create the DataFrame
35
+ df = pd.DataFrame({
36
+ 'f1': f1,
37
+ 'f2': f2,
38
+ 'f3': f3,
39
+ 'f4': f4,
40
+ 'f5': f5,
41
+ 'target': target
42
+ })
43
+ return df
44
+
45
+ if __name__ == "__main__":
46
+ unittest.main()